1、时间查询 AND DATE_FORMAT(fp.CreateTime, '%Y%m%d') >= DATE_FORMAT(#{stDate}, '%Y%m%d')
2、模查询 LIKE CONCAT('%',#{param.interfaceName},'%'))
3、js数字格式化、格式化float、金额格式化、js格式化float、js金额格式化
function fmoney(s, n)
{
n = n > 0 && n <= 20 ? n : 2;
s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(n) + "";
var l = s.split(".")[0].split("").reverse(),
r = s.split(".")[1];
t = "";
for(i = 0; i < l.length; i ++ )
{
t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : "");
}
return t.split("").reverse().join("") + "." + r;
}
4、Java 编码 解码
java.net.URLEncoder.encode(String s)
java.net.URLDecoder.decode(String s);
5、JavaScript 编码 解码
interName = encodeURIComponent(interName);
interName = encodeURIComponent(interName);
interName = decoderURIComponent(interName);
interName = decoderURIComponent(interName);
6、mybatis 添加返回主键 useGeneratedKeys="true" keyProperty="UserId"
7、sql 条件查询 (case when type = '单价收费' then unit_pice else buy_income_ratio end)
8、全转接 UNION ALL
9、Mybatis 驼峰命名转换 <setting name="mapUnderscoreToCamelCase" value="true"/>
10、Mybatis insert ignore 主键冲突不报错 返回 0
11、CONVERT(repository.unit_pice, char) mysql中采用concat来拼接中文字符乱码解决方式
12、-- 上个月的第一天
select date_sub(date_sub(date_format(now(),'%y-%m-%d'),interval extract(day from now())-1 day),interval 1 month)
-- 上个月的第最后一天
select date_sub(date_sub(date_format(now(),'%y-%m-%d'),interval extract(day from now()) day),interval 0 month) as date
13、MySql 排序 0 1 2 3 4 5 让 0 3 的放在前面
select * from test order by id = 2,id = 1,id ASC
14、删除重复数据
delete from test_gulj where id NOT IN(select id from (select max(id) as id,count(name) as count from test_gulj group by name,age having count > 1 order by count desc) as tab )
15、判断字符串中是否包含中文:
Pattern p = Pattern.compile("[\u4e00-\u9fa5]");
Matcher userNameMatch = p.matcher(userName);
if (userNameMatch.find())//用户名包含中文
16、
/**
* 中国电信号码格式验证 手机段: 133,153,180,181,189,177,1700
* **/
private static final String CHINA_TELECOM_PATTERN = "(^1(33|53|77|8[019])\\d{8}$)|(^1700\\d{7}$)";
/**
* 中国联通号码格式验证 手机段:130,131,132,155,156,185,186,145,176,1709
* **/
private static final String CHINA_UNICOM_PATTERN = "(^1(3[0-2]|4[5]|5[56]|7[6]|8[56])\\d{8}$)|(^1709\\d{7}$)";
/**
* 中国移动号码格式验证
* 手机段:134,135,136,137,138,139,150,151,152,157,158,159,182,183,184
* ,187,188,147,178,1705
* **/
private static final String CHINA_MOBILE_PATTERN = "(^1(3[4-9]|4[7]|5[0-27-9]|7[8]|8[2-478])\\d{8}$)|(^1705\\d{7}$)";
2、模查询 LIKE CONCAT('%',#{param.interfaceName},'%'))
3、js数字格式化、格式化float、金额格式化、js格式化float、js金额格式化
function fmoney(s, n)
{
n = n > 0 && n <= 20 ? n : 2;
s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(n) + "";
var l = s.split(".")[0].split("").reverse(),
r = s.split(".")[1];
t = "";
for(i = 0; i < l.length; i ++ )
{
t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : "");
}
return t.split("").reverse().join("") + "." + r;
}
4、Java 编码 解码
java.net.URLEncoder.encode(String s)
java.net.URLDecoder.decode(String s);
5、JavaScript 编码 解码
interName = encodeURIComponent(interName);
interName = encodeURIComponent(interName);
interName = decoderURIComponent(interName);
interName = decoderURIComponent(interName);
6、mybatis 添加返回主键 useGeneratedKeys="true" keyProperty="UserId"
7、sql 条件查询 (case when type = '单价收费' then unit_pice else buy_income_ratio end)
8、全转接 UNION ALL
9、Mybatis 驼峰命名转换 <setting name="mapUnderscoreToCamelCase" value="true"/>
10、Mybatis insert ignore 主键冲突不报错 返回 0
11、CONVERT(repository.unit_pice, char) mysql中采用concat来拼接中文字符乱码解决方式
12、-- 上个月的第一天
select date_sub(date_sub(date_format(now(),'%y-%m-%d'),interval extract(day from now())-1 day),interval 1 month)
-- 上个月的第最后一天
select date_sub(date_sub(date_format(now(),'%y-%m-%d'),interval extract(day from now()) day),interval 0 month) as date
13、MySql 排序 0 1 2 3 4 5 让 0 3 的放在前面
select * from test order by id = 2,id = 1,id ASC
14、删除重复数据
delete from test_gulj where id NOT IN(select id from (select max(id) as id,count(name) as count from test_gulj group by name,age having count > 1 order by count desc) as tab )
15、判断字符串中是否包含中文:
Pattern p = Pattern.compile("[\u4e00-\u9fa5]");
Matcher userNameMatch = p.matcher(userName);
if (userNameMatch.find())//用户名包含中文
16、
/**
* 中国电信号码格式验证 手机段: 133,153,180,181,189,177,1700
* **/
private static final String CHINA_TELECOM_PATTERN = "(^1(33|53|77|8[019])\\d{8}$)|(^1700\\d{7}$)";
/**
* 中国联通号码格式验证 手机段:130,131,132,155,156,185,186,145,176,1709
* **/
private static final String CHINA_UNICOM_PATTERN = "(^1(3[0-2]|4[5]|5[56]|7[6]|8[56])\\d{8}$)|(^1709\\d{7}$)";
/**
* 中国移动号码格式验证
* 手机段:134,135,136,137,138,139,150,151,152,157,158,159,182,183,184
* ,187,188,147,178,1705
* **/
private static final String CHINA_MOBILE_PATTERN = "(^1(3[4-9]|4[7]|5[0-27-9]|7[8]|8[2-478])\\d{8}$)|(^1705\\d{7}$)";