0%

2022-04

Mysql 查看表最全结构

https://blog.csdn.net/weixin_39603604/article/details/113270950

1
2
3
show create table +表名\G;

例如:show create table customer_register_promotion\G;

MyBatis 对 map 入参的更新

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<update id="updateBusinessPeopleCustomerName" parameterType="java.util.Map">
<foreach collection="customerNameByCodeMap.entrySet()" item="customerName" index="customerCode" open="" close="" separator=";">
<if test="customerCode != null and customerName != null">
update people
<set>
customer_name = #{customerName}
</set>
<where>
customer_code = #{customerCode}
</where>
</if>
</foreach>
</update>

1
Integer updateBusinessPeopleCustomerName(@Param("customerNameByCodeMap") Map<Long,String> customerNameByCodeMap);

Java 方法多返回值问题(类似 Groovy 中的元组 Tuple)

https://blog.csdn.net/weixin_43274002/article/details/120464358
使用 commons-lang3 工具包下的 Pair 或 Triple 类

1
2
3
4
5
6
7
8
9
10
11
12
13
14
      // 双返回值
Pair<Integer, Integer> pair = new ImmutablePair<>(1, 2);
System.out.println(pair.getLeft());
System.out.println(pair.getRight());

// 三返回值
Triple<String, String, String> triple =
new ImmutableTriple<>("我是第一个结果",
"我是第二个结果",
"我是第三个结果");
System.out.println(triple.getLeft());
System.out.println(triple.getMiddle());
System.out.println(triple.getRight());

复杂 SQL 鉴赏

(非公司系统表)

1
2
3
4
select t1.id t1_id,t2.id t2_id,t1.file_id t1_file_id,t2.file_id t2_file_id,t2.file_name file_name from (select * from attachments where file_id=0) t1 left join
(select * from attachments where id in (
select max(id) max_id from attachments where file_id!=0 and contract_id in
(select contract_id from attachments where file_id=0) group by contract_id )) t2 on t1.contract_id =t2.contract_id ;
1
2
3
4
select concat('update attachments set file_id=',t2_file_id,'where id=',t1_id,';') from (select t1.id t1_id,t2.id t2_id,t1.file_id t1_file_id,t2.file_id t2_file_id,t2.file_name file_name from (select * from attachments where file_id=0) t1 left join
(select * from attachments where id in (
select max(id) max_id from attachments where file_id!=0 and contract_id in
(select contract_id from attachments where file_id=0) group by personnel_contract_id )) t2 on t1.contract_id =t2.contract_id ) as t3;

查看端口进程和杀死进程

1
2
3
4
5
# 查找端口进程
lsof -i:8080

# 杀死进程
kill -9 pid(进程号)

Long 类型的比较方法源码

1
2
3
4
5
6
7
8
// 实现比较器接口Comparable,重写里面的compareTo方法
public int compareTo(Long anotherLong) {
return compare(this.value, anotherLong.value);
}

public static int compare(long x, long y) {
return (x < y) ? -1 : ((x == y) ? 0 : 1);
}