chenjiahe
2022-04-06 a48817ffcb840ed803c813c010f3730eb7e9cb87
src/main/java/com/hx/mybatis/aes/springbean/InitMysqlData.java
@@ -3,7 +3,7 @@
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.hx.common.annotations.MysqlHexAes;
import com.hx.common.dao.CommonMapper;
import com.hx.common.dao.mapper.CommonMapper;
import com.hx.common.service.CommonService;
import com.hx.exception.ServiceException;
import com.hx.mybatisTool.SqlSentence;
@@ -41,6 +41,7 @@
                for(FieldData fieldData:fieldDatas){
                    //获取条数
                    sqlSentence.sqlSentence("SELECT COUNT(0) FROM "+fieldData.getTableName(),values);
                    System.out.println("sqlSentence3:"+sqlSentence.getSqlSentence());
                    int total = commonService.selectCountSql(sqlSentence);
                    if(total ==0 ){
                        continue;
@@ -77,6 +78,7 @@
            selectField.append(","+fieldName);
        }
        sqlSentence.sqlSentence("SELECT "+selectField.toString()+" FROM "+fieldData.getTableName()+" LIMIT "+pageNum+","+pageSize,values);
        System.out.println("sqlSentence:"+sqlSentence.getSqlSentence());
        List<Map<String,Object>> list = commonService.selectListMap(CommonMapper.class,sqlSentence);
        for (Map<String,Object> map:list){
@@ -101,6 +103,8 @@
            values = map;
            sqlSentence.sqlSentence("UPDATE "+fieldData.getTableName()+" SET "+setField.toString()+" WHERE "+fieldData.getId()+" = #{m."+fieldData.getId()+"}",values);
            System.out.println("sqlSentence2:"+sqlSentence.getSqlSentence());
            if(commonService.updateSentence(sqlSentence)!=1){
                throw new ServiceException("更新超过1条,更新失败!");
            }