99-generate

1. insertBatch

@Test
public void sm2() {
    Ooxx ooxx = new Ooxx();
    StringBuilder insString = new StringBuilder();
    Field[] declaredFields = ooxx.getClass().getDeclaredFields();
    for (Field field : declaredFields) {
        insString.append("#{one.").append(field.getName()).append("}, ");
    }
    System.out.println(insString);
}
<!--批量插入-->
<insert id="insertBatch">
    insert into ooxx (
    <include refid="Insert_Column_List"/>
    ) values
    <foreach collection="list" item="one" separator=",">
        (#{one.id}, #{one.loginName}, #{one.userName}, #{one.authKey})
    </foreach>
</insert>

2. updateBatch

image-20240401200441056
<update id="updateBatch">
    <foreach collection="list" item="one" index="index" open="" close="" separator=";">
        UPDATE ooxx
        SET APP_ID            = '6101657204559872',
            LOGIN_NAME        = 'ooxx',
            USER_NAME         = 'songsong',
            AUTH_KEY          = 'f579dabc28bca0be262665a35b614fb62d',
            DEL_FLAG          = 1
        WHERE ID = '5c27d0dd-143e-11eb-883c-f875a40986ed';
    </foreach>
</update>

3. rowDefault

const rowDefault = {
  id : null,
  appId : null,
  loginName : null,
  ooxxId : null,
  ooxxName : null,
  userName : null
  ...
}
@Test
public void rowDefault() {
    Ooxx ooxx = new Ooxx();
    JSONConfig jsonConfig = JSONConfig.create();
    jsonConfig.setIgnoreNullValue(false);
    String jsonStr = JSONUtil.toJsonStr(ooxx, jsonConfig);
    System.out.println("jsonStr = " + jsonStr);
}
jsonStr = {"name":null,"id":null}
  • "批量删除即可