0. Tips

1. Prevent frequent text messages

redis.save(mobile,count,time);

每次count++  超过十次,屏蔽它,等时间自动过期。

但是这种方式会有一个问题,就是每次count++ time都会被重新设置,也就是 用户会在最后一次操作的基础上等time长时间。

需求是一天限制10次,可以从key上下功夫,将key设置为:

new java.sql.Date(System.currentTimeMillis()).toString()+mobile

也就是2018-02-01+mobile

第二天就是2018-02-02+mobile   就获取不到原来的数据了,默认为0次,等待原来的数据自动过期就好啦!

2. Serialize the form

 //序列化表单
    function serializeObject(form){
        var o={};
        $.each(form.serializeArray(),function(index){
            if(o[this['name'] ]){
                o[this['name'] ] = o[this['name'] ] + "," + this['value'];
            }else{
                o[this['name'] ]=this['value'];
            }
        })
        return o;
    }

 

3. Form parameters are spliced ​​into strings

//表单拼接成字符串
function serializeString(form){
   var o = "";
   $.each(form.serializeArray(),function(index){
        o = o+"&"+this['name']+"="+this['value'];
   })
     return o.substring(1,o.length);
}

4. MySQL sorts according to the pinyin of Chinese characters

MySQL按照汉字的拼音排序
按照汉字的拼音排序,用的比较多是在人名的排序中,按照姓氏的拼音字母,从A到Z排序;

如果存储姓名的字段采用的是GBK字符集,那就好办了,因为GBK内码编码时本身就采用了拼音排序的方法(常用一级汉字3755个采用拼音排序,二级汉字就不是了,但考虑到人名等都是常用汉字,因此只是针对一级汉字能正确排序也够用了)。

直接在查询语句后面 添加 order by name asc; 查询结果按照姓氏的升序排序;

如果存储姓名的字段采用的是 utf8字符集,需要在排序的时候对字段进行转码;对于的代码是  order by convert(name using gbk) asc; 同样,查询的结果也是按照姓氏的升序排序;

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324438055&siteId=291194637