parent
23a0c7fd48
commit
23d1028e13
|
@ -53,6 +53,10 @@ public class SysDictData extends BaseEntity
|
|||
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 父级ID标志
|
||||
*/
|
||||
@Excel(name = "父级ID标志")
|
||||
private Integer partId;
|
||||
|
||||
public Integer getPartId() {
|
||||
|
|
|
@ -31,7 +31,13 @@ public class DictInit implements ApplicationRunner {
|
|||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
this.dict();
|
||||
}
|
||||
|
||||
//初始化防擦
|
||||
public void dict(){
|
||||
|
||||
long startTime = System.currentTimeMillis(); // 记录开始时间
|
||||
log.info("初始化字典数据...");
|
||||
|
||||
SysDictData dictData = new SysDictData();
|
||||
|
@ -53,7 +59,8 @@ public class DictInit implements ApplicationRunner {
|
|||
));
|
||||
dictCache.put(type, subMap);
|
||||
});
|
||||
log.info("字典数据初始化完成...");
|
||||
long cost = System.currentTimeMillis() - startTime; // 计算耗时
|
||||
log.info("字典数据初始化完成,耗时 {} 毫秒", cost); // 打印耗时
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package com.mcwl.system.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.mcwl.common.core.domain.entity.SysDictData;
|
||||
import com.mcwl.common.utils.DictUtils;
|
||||
import com.mcwl.system.init.DictInit;
|
||||
import com.mcwl.system.mapper.SysDictDataMapper;
|
||||
import com.mcwl.system.service.ISysDictDataService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典 业务层处理
|
||||
|
@ -19,6 +21,9 @@ public class SysDictDataServiceImpl implements ISysDictDataService
|
|||
@Autowired
|
||||
private SysDictDataMapper dictDataMapper;
|
||||
|
||||
@Autowired
|
||||
private DictInit dictInit;
|
||||
|
||||
/**
|
||||
* 根据条件分页查询字典数据
|
||||
*
|
||||
|
@ -70,6 +75,8 @@ public class SysDictDataServiceImpl implements ISysDictDataService
|
|||
dictDataMapper.deleteDictDataById(dictCode);
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType());
|
||||
DictUtils.setDictCache(data.getDictType(), dictDatas);
|
||||
//初始化字典
|
||||
dictInit.dict();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,6 +94,8 @@ public class SysDictDataServiceImpl implements ISysDictDataService
|
|||
{
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType());
|
||||
DictUtils.setDictCache(data.getDictType(), dictDatas);
|
||||
//初始化字典
|
||||
dictInit.dict();
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
@ -105,6 +114,8 @@ public class SysDictDataServiceImpl implements ISysDictDataService
|
|||
{
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType());
|
||||
DictUtils.setDictCache(data.getDictType(), dictDatas);
|
||||
//初始化字典表
|
||||
dictInit.dict();
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="dictType != null and dictType != ''">
|
||||
AND dict_type = #{dictType}
|
||||
</if>
|
||||
<if test="partId != null and partId != ''">
|
||||
AND part_id = #{partId}
|
||||
</if>
|
||||
<if test="dictLabel != null and dictLabel != ''">
|
||||
AND dict_label like concat('%', #{dictLabel}, '%')
|
||||
</if>
|
||||
|
@ -106,6 +109,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="status != null">status,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
<if test="partId != null and partId != ''">part_id,</if>
|
||||
create_time
|
||||
)values(
|
||||
<if test="dictSort != null">#{dictSort},</if>
|
||||
|
@ -118,6 +122,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="status != null">#{status},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
<if test="partId != null and partId != ''">#{partId},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
|
Loading…
Reference in New Issue