使用mybatis-flex重构“字典管理”模块代码
This commit is contained in:
parent
5212d4fb68
commit
7a4a0d926d
@ -18,12 +18,12 @@ mybatis-flex:
|
||||
# NONE:不做处理 WARNING:打印相关警告 FAILING:抛出异常和详细信息
|
||||
autoMappingUnknownColumnBehavior: WARNING
|
||||
# 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
# 关闭日志记录 (可单纯使用 p6spy 分析) org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||
# 关闭日志记录 org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||
# 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||||
logImpl: org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||||
cacheEnabled: true
|
||||
useGeneratedKeys: true
|
||||
defaultExecutorType: SIMPLE
|
||||
#useGeneratedKeys: true
|
||||
#defaultExecutorType: SIMPLE
|
||||
|
||||
# MyBatis-Flex全局配置
|
||||
global-config:
|
||||
|
@ -5,11 +5,13 @@ import java.util.List;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.ruoyi.common.core.core.domain.R;
|
||||
import com.ruoyi.common.excel.utils.ExcelUtil;
|
||||
import com.ruoyi.common.log.annotation.Log;
|
||||
import com.ruoyi.common.log.enums.BusinessType;
|
||||
import com.ruoyi.common.orm.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.security.utils.LoginHelper;
|
||||
import com.ruoyi.system.domain.SysDictData;
|
||||
import com.ruoyi.system.domain.bo.SysDictDataBo;
|
||||
import com.ruoyi.system.domain.vo.SysDictDataVo;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -23,9 +25,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.web.core.BaseController;
|
||||
import com.ruoyi.common.core.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.system.service.ISysDictDataService;
|
||||
import com.ruoyi.system.service.ISysDictTypeService;
|
||||
|
||||
@ -38,8 +38,7 @@ import com.ruoyi.system.service.ISysDictTypeService;
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/system/dict/data")
|
||||
public class SysDictDataController extends BaseController
|
||||
{
|
||||
public class SysDictDataController extends BaseController {
|
||||
@Resource
|
||||
private ISysDictDataService dictDataService;
|
||||
|
||||
@ -48,11 +47,8 @@ public class SysDictDataController extends BaseController
|
||||
|
||||
@SaCheckPermission("system:dict:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysDictData dictData)
|
||||
{
|
||||
startPage();
|
||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||
return getDataTable(list);
|
||||
public TableDataInfo<SysDictDataVo> list(SysDictDataBo dictDataBo) {
|
||||
return dictDataService.selectPage(dictDataBo);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,11 +57,9 @@ public class SysDictDataController extends BaseController
|
||||
@SaCheckPermission("system:dict:export")
|
||||
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysDictData dictData)
|
||||
{
|
||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||
ExcelUtil<SysDictData> util = new ExcelUtil<>(SysDictData.class);
|
||||
util.exportExcel(response, list, "字典数据");
|
||||
public void export(HttpServletResponse response, SysDictDataBo dictDataBo) {
|
||||
List<SysDictDataVo> list = dictDataService.selectDictDataList(dictDataBo);
|
||||
ExcelUtil.exportExcel(list, "字典数据", SysDictDataVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,9 +67,8 @@ public class SysDictDataController extends BaseController
|
||||
*/
|
||||
@SaCheckPermission("system:dict:query")
|
||||
@GetMapping(value = "/{dictCode}")
|
||||
public AjaxResult getInfo(@PathVariable Long dictCode)
|
||||
{
|
||||
return success(dictDataService.selectDictDataById(dictCode));
|
||||
public R<SysDictDataVo> getInfo(@PathVariable Long dictCode) {
|
||||
return R.ok(dictDataService.selectDictDataById(dictCode));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,14 +76,12 @@ public class SysDictDataController extends BaseController
|
||||
*/
|
||||
@SaIgnore
|
||||
@GetMapping(value = "/type/{dictType}")
|
||||
public AjaxResult dictType(@PathVariable String dictType)
|
||||
{
|
||||
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
|
||||
if (StringUtils.isNull(data))
|
||||
{
|
||||
public R<List<SysDictDataVo>> dictType(@PathVariable String dictType) {
|
||||
List<SysDictDataVo> data = dictTypeService.selectDictDataByType(dictType);
|
||||
if (StringUtils.isNull(data)) {
|
||||
data = new ArrayList<>();
|
||||
}
|
||||
return success(data);
|
||||
return R.ok(data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -99,10 +90,12 @@ public class SysDictDataController extends BaseController
|
||||
@SaCheckPermission("system:dict:add")
|
||||
@Log(title = "字典数据", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysDictData dict)
|
||||
{
|
||||
dict.setCreateBy(LoginHelper.getUserId());
|
||||
return toAjax(dictDataService.insertDictData(dict));
|
||||
public R<Void> add(@Validated @RequestBody SysDictDataBo dictDataBo) {
|
||||
int insertedRows = dictDataService.insertDictData(dictDataBo);
|
||||
if (insertedRows == 0) {
|
||||
return R.fail("新增字典数据记录失败!");
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,10 +104,12 @@ public class SysDictDataController extends BaseController
|
||||
@SaCheckPermission("system:dict:edit")
|
||||
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysDictData dict)
|
||||
{
|
||||
dict.setUpdateBy(LoginHelper.getUserId());
|
||||
return toAjax(dictDataService.updateDictData(dict));
|
||||
public R<Void> edit(@Validated @RequestBody SysDictDataBo dictDataBo) {
|
||||
boolean updated = dictDataService.updateDictData(dictDataBo);
|
||||
if (!updated) {
|
||||
return R.fail("修改字典数据记录失败!");
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -123,9 +118,11 @@ public class SysDictDataController extends BaseController
|
||||
@SaCheckPermission("system:dict:remove")
|
||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{dictCodes}")
|
||||
public AjaxResult remove(@PathVariable Long[] dictCodes)
|
||||
{
|
||||
dictDataService.deleteDictDataByIds(dictCodes);
|
||||
return success();
|
||||
public R<Void> remove(@PathVariable Long[] dictCodes) {
|
||||
boolean deleted = dictDataService.deleteDictDataByIds(dictCodes);
|
||||
if (!deleted) {
|
||||
return R.fail("删除字典数据记录失败!");
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,13 @@ package com.ruoyi.system.controller.system;
|
||||
import java.util.List;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import com.ruoyi.common.core.core.domain.R;
|
||||
import com.ruoyi.common.excel.utils.ExcelUtil;
|
||||
import com.ruoyi.common.log.annotation.Log;
|
||||
import com.ruoyi.common.log.enums.BusinessType;
|
||||
import com.ruoyi.common.orm.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.security.utils.LoginHelper;
|
||||
import com.ruoyi.system.domain.SysDictType;
|
||||
import com.ruoyi.system.domain.bo.SysDictTypeBo;
|
||||
import com.ruoyi.system.domain.vo.SysDictTypeVo;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -21,8 +23,6 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.web.core.BaseController;
|
||||
import com.ruoyi.common.core.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.system.service.ISysDictTypeService;
|
||||
|
||||
/**
|
||||
@ -41,21 +41,18 @@ public class SysDictTypeController extends BaseController
|
||||
|
||||
@SaCheckPermission("system:dict:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysDictType dictType)
|
||||
public TableDataInfo<SysDictTypeVo> list(SysDictTypeBo dictTypeBo)
|
||||
{
|
||||
startPage();
|
||||
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||
return getDataTable(list);
|
||||
return dictTypeService.selectPage(dictTypeBo);
|
||||
}
|
||||
|
||||
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
|
||||
@SaCheckPermission("system:dict:export")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysDictType dictType)
|
||||
public void export(HttpServletResponse response, SysDictTypeBo dictTypeBo)
|
||||
{
|
||||
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||
ExcelUtil<SysDictType> util = new ExcelUtil<>(SysDictType.class);
|
||||
util.exportExcel(response, list, "字典类型");
|
||||
List<SysDictTypeVo> list = dictTypeService.selectDictTypeList(dictTypeBo);
|
||||
ExcelUtil.exportExcel(list, "数据字典类型信息数据", SysDictTypeVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,9 +60,9 @@ public class SysDictTypeController extends BaseController
|
||||
*/
|
||||
@SaCheckPermission("system:dict:query")
|
||||
@GetMapping(value = "/{dictId}")
|
||||
public AjaxResult getInfo(@PathVariable Long dictId)
|
||||
public R<SysDictTypeVo> getInfo(@PathVariable Long dictId)
|
||||
{
|
||||
return success(dictTypeService.selectDictTypeById(dictId));
|
||||
return R.ok(dictTypeService.selectDictTypeById(dictId));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -74,14 +71,14 @@ public class SysDictTypeController extends BaseController
|
||||
@SaCheckPermission("system:dict:add")
|
||||
@Log(title = "字典类型", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysDictType dict)
|
||||
public R<Void> add(@Validated @RequestBody SysDictTypeBo dictTypeBo)
|
||||
{
|
||||
if (!dictTypeService.checkDictTypeUnique(dict))
|
||||
if (!dictTypeService.checkDictTypeUnique(dictTypeBo))
|
||||
{
|
||||
return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||
return R.fail("新增字典'" + dictTypeBo.getDictName() + "'失败,字典类型已存在");
|
||||
}
|
||||
dict.setCreateBy(LoginHelper.getUserId());
|
||||
return toAjax(dictTypeService.insertDictType(dict));
|
||||
dictTypeService.insertDictType(dictTypeBo);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,14 +87,14 @@ public class SysDictTypeController extends BaseController
|
||||
@SaCheckPermission("system:dict:edit")
|
||||
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysDictType dict)
|
||||
public R<Void> edit(@Validated @RequestBody SysDictTypeBo dictTypeBo)
|
||||
{
|
||||
if (!dictTypeService.checkDictTypeUnique(dict))
|
||||
if (!dictTypeService.checkDictTypeUnique(dictTypeBo))
|
||||
{
|
||||
return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
|
||||
return R.fail("修改字典'" + dictTypeBo.getDictName() + "'失败,字典类型已存在");
|
||||
}
|
||||
dict.setUpdateBy(LoginHelper.getUserId());
|
||||
return toAjax(dictTypeService.updateDictType(dict));
|
||||
dictTypeService.updateDictType(dictTypeBo);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -106,10 +103,13 @@ public class SysDictTypeController extends BaseController
|
||||
@SaCheckPermission("system:dict:remove")
|
||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{dictIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] dictIds)
|
||||
public R<Void> remove(@PathVariable Long[] dictIds)
|
||||
{
|
||||
dictTypeService.deleteDictTypeByIds(dictIds);
|
||||
return success();
|
||||
boolean deleted = dictTypeService.deleteDictTypeByIds(dictIds);
|
||||
if (!deleted) {
|
||||
R.fail("删除字典类型记录失败!");
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -118,19 +118,19 @@ public class SysDictTypeController extends BaseController
|
||||
@SaCheckPermission("system:dict:remove")
|
||||
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/refreshCache")
|
||||
public AjaxResult refreshCache()
|
||||
public R<Void> refreshCache()
|
||||
{
|
||||
dictTypeService.resetDictCache();
|
||||
return success();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典选择框列表
|
||||
*/
|
||||
@GetMapping("/optionselect")
|
||||
public AjaxResult optionselect()
|
||||
public R<List<SysDictTypeVo>> optionselect()
|
||||
{
|
||||
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
|
||||
return success(dictTypes);
|
||||
List<SysDictTypeVo> dictTypes = dictTypeService.selectDictTypeAll();
|
||||
return R.ok(dictTypes);
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class SysNoticeController extends BaseController
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<SysNoticeVo> list(SysNoticeBo noticeBo)
|
||||
{
|
||||
return noticeService.selectConfigPage(noticeBo);
|
||||
return noticeService.selectPage(noticeBo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -47,7 +47,7 @@ public class SysPostController extends BaseController
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<SysPostVo> list(SysPostBo postBo)
|
||||
{
|
||||
return postService.selectConfigPage(postBo);
|
||||
return postService.selectPage(postBo);
|
||||
}
|
||||
|
||||
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
||||
|
@ -1,44 +1,37 @@
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.core.annotation.Excel;
|
||||
import com.ruoyi.common.core.annotation.Excel.ColumnType;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.ruoyi.common.core.constant.UserConstants;
|
||||
import com.ruoyi.common.orm.core.domain.BaseEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 字典数据表 sys_dict_data
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table(value = "sys_dict_data")
|
||||
public class SysDictData extends BaseEntity
|
||||
{
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 字典编码 */
|
||||
@Excel(name = "字典编码", cellType = ColumnType.NUMERIC)
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long dictCode;
|
||||
|
||||
/** 字典排序 */
|
||||
@Excel(name = "字典排序", cellType = ColumnType.NUMERIC)
|
||||
private Long dictSort;
|
||||
|
||||
/** 字典标签 */
|
||||
@Excel(name = "字典标签")
|
||||
private String dictLabel;
|
||||
|
||||
/** 字典键值 */
|
||||
@Excel(name = "字典键值")
|
||||
private String dictValue;
|
||||
|
||||
/** 字典类型 */
|
||||
@Excel(name = "字典类型")
|
||||
private String dictType;
|
||||
|
||||
/** 样式属性(其他样式扩展) */
|
||||
@ -48,130 +41,12 @@ public class SysDictData extends BaseEntity
|
||||
private String listClass;
|
||||
|
||||
/** 是否默认(Y是 N否) */
|
||||
@Excel(name = "是否默认", readConverterExp = "Y=是,N=否")
|
||||
private String isDefault;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
public Long getDictCode()
|
||||
{
|
||||
return dictCode;
|
||||
}
|
||||
|
||||
public void setDictCode(Long dictCode)
|
||||
{
|
||||
this.dictCode = dictCode;
|
||||
}
|
||||
|
||||
public Long getDictSort()
|
||||
{
|
||||
return dictSort;
|
||||
}
|
||||
|
||||
public void setDictSort(Long dictSort)
|
||||
{
|
||||
this.dictSort = dictSort;
|
||||
}
|
||||
|
||||
@NotBlank(message = "字典标签不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典标签长度不能超过100个字符")
|
||||
public String getDictLabel()
|
||||
{
|
||||
return dictLabel;
|
||||
}
|
||||
|
||||
public void setDictLabel(String dictLabel)
|
||||
{
|
||||
this.dictLabel = dictLabel;
|
||||
}
|
||||
|
||||
@NotBlank(message = "字典键值不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典键值长度不能超过100个字符")
|
||||
public String getDictValue()
|
||||
{
|
||||
return dictValue;
|
||||
}
|
||||
|
||||
public void setDictValue(String dictValue)
|
||||
{
|
||||
this.dictValue = dictValue;
|
||||
}
|
||||
|
||||
@NotBlank(message = "字典类型不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典类型长度不能超过100个字符")
|
||||
public String getDictType()
|
||||
{
|
||||
return dictType;
|
||||
}
|
||||
|
||||
public void setDictType(String dictType)
|
||||
{
|
||||
this.dictType = dictType;
|
||||
}
|
||||
|
||||
@Size(min = 0, max = 100, message = "样式属性长度不能超过100个字符")
|
||||
public String getCssClass()
|
||||
{
|
||||
return cssClass;
|
||||
}
|
||||
|
||||
public void setCssClass(String cssClass)
|
||||
{
|
||||
this.cssClass = cssClass;
|
||||
}
|
||||
|
||||
public String getListClass()
|
||||
{
|
||||
return listClass;
|
||||
}
|
||||
|
||||
public void setListClass(String listClass)
|
||||
{
|
||||
this.listClass = listClass;
|
||||
}
|
||||
|
||||
public boolean getDefault()
|
||||
{
|
||||
return UserConstants.YES.equals(this.isDefault) ? true : false;
|
||||
}
|
||||
|
||||
public String getIsDefault()
|
||||
{
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
public void setIsDefault(String isDefault)
|
||||
{
|
||||
this.isDefault = isDefault;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("dictCode", getDictCode())
|
||||
.append("dictSort", getDictSort())
|
||||
.append("dictLabel", getDictLabel())
|
||||
.append("dictValue", getDictValue())
|
||||
.append("dictType", getDictType())
|
||||
.append("cssClass", getCssClass())
|
||||
.append("listClass", getListClass())
|
||||
.append("isDefault", getIsDefault())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
public boolean getDefault() {
|
||||
return UserConstants.YES.equals(this.isDefault);
|
||||
}
|
||||
}
|
||||
|
@ -1,95 +1,32 @@
|
||||
package com.ruoyi.system.domain;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.core.annotation.Excel;
|
||||
import com.ruoyi.common.core.annotation.Excel.ColumnType;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.ruoyi.common.orm.core.domain.BaseEntity;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 字典类型表 sys_dict_type
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table(value = "sys_dict_type")
|
||||
public class SysDictType extends BaseEntity
|
||||
{
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 字典主键 */
|
||||
@Excel(name = "字典主键", cellType = ColumnType.NUMERIC)
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long dictId;
|
||||
|
||||
/** 字典名称 */
|
||||
@Excel(name = "字典名称")
|
||||
private String dictName;
|
||||
|
||||
/** 字典类型 */
|
||||
@Excel(name = "字典类型")
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
public Long getDictId()
|
||||
{
|
||||
return dictId;
|
||||
}
|
||||
|
||||
public void setDictId(Long dictId)
|
||||
{
|
||||
this.dictId = dictId;
|
||||
}
|
||||
|
||||
@NotBlank(message = "字典名称不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典类型名称长度不能超过100个字符")
|
||||
public String getDictName()
|
||||
{
|
||||
return dictName;
|
||||
}
|
||||
|
||||
public void setDictName(String dictName)
|
||||
{
|
||||
this.dictName = dictName;
|
||||
}
|
||||
|
||||
@NotBlank(message = "字典类型不能为空")
|
||||
@Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符")
|
||||
public String getDictType()
|
||||
{
|
||||
return dictType;
|
||||
}
|
||||
|
||||
public void setDictType(String dictType)
|
||||
{
|
||||
this.dictType = dictType;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("dictId", getDictId())
|
||||
.append("dictName", getDictName())
|
||||
.append("dictType", getDictType())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ import java.util.Date;
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = SysDictData.class)
|
||||
public class SysDictDataVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
|
@ -2,10 +2,6 @@ package com.ruoyi.system.domain.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.ruoyi.common.excel.annotation.ExcelDictFormat;
|
||||
import com.ruoyi.common.excel.convert.ExcelDictConvert;
|
||||
import com.ruoyi.system.domain.SysDictType;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
@ -20,7 +16,6 @@ import java.util.Date;
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = SysDictType.class)
|
||||
public class SysDictTypeVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
|
@ -2,7 +2,9 @@ package com.ruoyi.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.ruoyi.system.domain.SysDictData;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
@ -10,87 +12,8 @@ import org.apache.ibatis.annotations.Param;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface SysDictDataMapper
|
||||
@Mapper
|
||||
public interface SysDictDataMapper extends BaseMapper<SysDictData>
|
||||
{
|
||||
/**
|
||||
* 根据条件分页查询字典数据
|
||||
*
|
||||
* @param dictData 字典数据信息
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
List<SysDictData> selectDictDataList(SysDictData dictData);
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
List<SysDictData> selectDictDataByType(String dictType);
|
||||
|
||||
/**
|
||||
* 根据字典类型和字典键值查询字典数据信息
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param dictValue 字典键值
|
||||
* @return 字典标签
|
||||
*/
|
||||
String selectDictLabel(@Param("dictType") String dictType, @Param("dictValue") String dictValue);
|
||||
|
||||
/**
|
||||
* 根据字典数据ID查询信息
|
||||
*
|
||||
* @param dictCode 字典数据ID
|
||||
* @return 字典数据
|
||||
*/
|
||||
SysDictData selectDictDataById(Long dictCode);
|
||||
|
||||
/**
|
||||
* 查询字典数据
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 字典数据
|
||||
*/
|
||||
int countDictDataByType(String dictType);
|
||||
|
||||
/**
|
||||
* 通过字典ID删除字典数据信息
|
||||
*
|
||||
* @param dictCode 字典数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteDictDataById(Long dictCode);
|
||||
|
||||
/**
|
||||
* 批量删除字典数据信息
|
||||
*
|
||||
* @param dictCodes 需要删除的字典数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteDictDataByIds(Long[] dictCodes);
|
||||
|
||||
/**
|
||||
* 新增字典数据信息
|
||||
*
|
||||
* @param dictData 字典数据信息
|
||||
* @return 结果
|
||||
*/
|
||||
int insertDictData(SysDictData dictData);
|
||||
|
||||
/**
|
||||
* 修改字典数据信息
|
||||
*
|
||||
* @param dictData 字典数据信息
|
||||
* @return 结果
|
||||
*/
|
||||
int updateDictData(SysDictData dictData);
|
||||
|
||||
/**
|
||||
* 同步修改字典类型
|
||||
*
|
||||
* @param oldDictType 旧字典类型
|
||||
* @param newDictType 新旧字典类型
|
||||
* @return 结果
|
||||
*/
|
||||
int updateDictDataType(@Param("oldDictType") String oldDictType, @Param("newDictType") String newDictType);
|
||||
}
|
||||
|
@ -1,84 +1,86 @@
|
||||
package com.ruoyi.system.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.ruoyi.system.domain.SysDictType;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典表 数据层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface SysDictTypeMapper
|
||||
@Mapper
|
||||
public interface SysDictTypeMapper extends BaseMapper<SysDictType>
|
||||
{
|
||||
/**
|
||||
* 根据条件分页查询字典类型
|
||||
*
|
||||
* @param dictType 字典类型信息
|
||||
* @return 字典类型集合信息
|
||||
*/
|
||||
List<SysDictType> selectDictTypeList(SysDictType dictType);
|
||||
|
||||
/**
|
||||
* 根据所有字典类型
|
||||
*
|
||||
* @return 字典类型集合信息
|
||||
*/
|
||||
List<SysDictType> selectDictTypeAll();
|
||||
|
||||
/**
|
||||
* 根据字典类型ID查询信息
|
||||
*
|
||||
* @param dictId 字典类型ID
|
||||
* @return 字典类型
|
||||
*/
|
||||
SysDictType selectDictTypeById(Long dictId);
|
||||
|
||||
/**
|
||||
* 根据字典类型查询信息
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 字典类型
|
||||
*/
|
||||
SysDictType selectDictTypeByType(String dictType);
|
||||
|
||||
/**
|
||||
* 通过字典ID删除字典信息
|
||||
*
|
||||
* @param dictId 字典ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteDictTypeById(Long dictId);
|
||||
|
||||
/**
|
||||
* 批量删除字典类型信息
|
||||
*
|
||||
* @param dictIds 需要删除的字典ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteDictTypeByIds(Long[] dictIds);
|
||||
|
||||
/**
|
||||
* 新增字典类型信息
|
||||
*
|
||||
* @param dictType 字典类型信息
|
||||
* @return 结果
|
||||
*/
|
||||
int insertDictType(SysDictType dictType);
|
||||
|
||||
/**
|
||||
* 修改字典类型信息
|
||||
*
|
||||
* @param dictType 字典类型信息
|
||||
* @return 结果
|
||||
*/
|
||||
int updateDictType(SysDictType dictType);
|
||||
|
||||
/**
|
||||
* 校验字典类型称是否唯一
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 结果
|
||||
*/
|
||||
SysDictType checkDictTypeUnique(String dictType);
|
||||
// /**
|
||||
// * 根据条件分页查询字典类型
|
||||
// *
|
||||
// * @param dictType 字典类型信息
|
||||
// * @return 字典类型集合信息
|
||||
// */
|
||||
// List<SysDictType> selectDictTypeList(SysDictType dictType);
|
||||
//
|
||||
// /**
|
||||
// * 根据所有字典类型
|
||||
// *
|
||||
// * @return 字典类型集合信息
|
||||
// */
|
||||
// List<SysDictType> selectDictTypeAll();
|
||||
//
|
||||
// /**
|
||||
// * 根据字典类型ID查询信息
|
||||
// *
|
||||
// * @param dictId 字典类型ID
|
||||
// * @return 字典类型
|
||||
// */
|
||||
// SysDictType selectDictTypeById(Long dictId);
|
||||
//
|
||||
// /**
|
||||
// * 根据字典类型查询信息
|
||||
// *
|
||||
// * @param dictType 字典类型
|
||||
// * @return 字典类型
|
||||
// */
|
||||
// SysDictType selectDictTypeByType(String dictType);
|
||||
//
|
||||
// /**
|
||||
// * 通过字典ID删除字典信息
|
||||
// *
|
||||
// * @param dictId 字典ID
|
||||
// * @return 结果
|
||||
// */
|
||||
// int deleteDictTypeById(Long dictId);
|
||||
//
|
||||
// /**
|
||||
// * 批量删除字典类型信息
|
||||
// *
|
||||
// * @param dictIds 需要删除的字典ID
|
||||
// * @return 结果
|
||||
// */
|
||||
// int deleteDictTypeByIds(Long[] dictIds);
|
||||
//
|
||||
// /**
|
||||
// * 新增字典类型信息
|
||||
// *
|
||||
// * @param dictType 字典类型信息
|
||||
// * @return 结果
|
||||
// */
|
||||
// int insertDictType(SysDictType dictType);
|
||||
//
|
||||
// /**
|
||||
// * 修改字典类型信息
|
||||
// *
|
||||
// * @param dictType 字典类型信息
|
||||
// * @return 结果
|
||||
// */
|
||||
// int updateDictType(SysDictType dictType);
|
||||
//
|
||||
// /**
|
||||
// * 校验字典类型称是否唯一
|
||||
// *
|
||||
// * @param dictType 字典类型
|
||||
// * @return 结果
|
||||
// */
|
||||
// SysDictType checkDictTypeUnique(String dictType);
|
||||
}
|
||||
|
@ -1,6 +1,10 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.ruoyi.common.orm.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.orm.core.service.IBaseService;
|
||||
import com.ruoyi.system.domain.SysDictData;
|
||||
import com.ruoyi.system.domain.bo.SysDictDataBo;
|
||||
import com.ruoyi.system.domain.vo.SysDictDataVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -9,15 +13,23 @@ import java.util.List;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface ISysDictDataService
|
||||
public interface ISysDictDataService extends IBaseService<SysDictData>
|
||||
{
|
||||
/**
|
||||
* 根据条件分页查询字典数据
|
||||
*
|
||||
* @param dictData 字典数据信息
|
||||
* @param dictDataBo 字典数据信息
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
List<SysDictData> selectDictDataList(SysDictData dictData);
|
||||
List<SysDictDataVo> selectDictDataList(SysDictDataBo dictDataBo);
|
||||
|
||||
/**
|
||||
* 分页查询字典数据
|
||||
*
|
||||
* @param dictDataBo 字典类型信息
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
TableDataInfo<SysDictDataVo> selectPage(SysDictDataBo dictDataBo);
|
||||
|
||||
/**
|
||||
* 根据字典类型和字典键值查询字典数据信息
|
||||
@ -34,28 +46,55 @@ public interface ISysDictDataService
|
||||
* @param dictCode 字典数据ID
|
||||
* @return 字典数据
|
||||
*/
|
||||
SysDictData selectDictDataById(Long dictCode);
|
||||
SysDictDataVo selectDictDataById(Long dictCode);
|
||||
|
||||
/**
|
||||
* 查询字典数据记录数量
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 字典数据
|
||||
*/
|
||||
Integer countDictDataByType(String dictType);
|
||||
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
List<SysDictDataVo> selectDictDataByType(String dictType);
|
||||
|
||||
/**
|
||||
* 批量删除字典数据信息
|
||||
*
|
||||
* @param dictCodes 需要删除的字典数据ID
|
||||
* @return 结果:true 删除成功,false 删除失败。
|
||||
*/
|
||||
void deleteDictDataByIds(Long[] dictCodes);
|
||||
boolean deleteDictDataByIds(Long[] dictCodes);
|
||||
|
||||
/**
|
||||
* 新增保存字典数据信息
|
||||
*
|
||||
* @param dictData 字典数据信息
|
||||
* @return 结果
|
||||
* @param dataBo 字典数据信息
|
||||
* @return 结果:受影响的行数
|
||||
*/
|
||||
int insertDictData(SysDictData dictData);
|
||||
int insertDictData(SysDictDataBo dataBo);
|
||||
|
||||
/**
|
||||
* 修改保存字典数据信息
|
||||
*
|
||||
* @param dictData 字典数据信息
|
||||
* @param dataBo 字典数据信息
|
||||
* @return 结果:true 更新成功,false 更新失败。
|
||||
*/
|
||||
boolean updateDictData(SysDictDataBo dataBo);
|
||||
|
||||
/**
|
||||
* 同步修改字典类型
|
||||
*
|
||||
* @param oldDictType 旧字典类型
|
||||
* @param newDictType 新旧字典类型
|
||||
* @return 结果
|
||||
*/
|
||||
int updateDictData(SysDictData dictData);
|
||||
boolean updateDictDataType(String oldDictType, String newDictType);
|
||||
}
|
||||
|
@ -1,7 +1,12 @@
|
||||
package com.ruoyi.system.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.ruoyi.common.orm.core.page.TableDataInfo;
|
||||
import com.ruoyi.system.domain.SysDictData;
|
||||
import com.ruoyi.system.domain.SysDictType;
|
||||
import com.ruoyi.system.domain.bo.SysDictTypeBo;
|
||||
import com.ruoyi.system.domain.vo.SysDictDataVo;
|
||||
import com.ruoyi.system.domain.vo.SysDictTypeVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -10,7 +15,7 @@ import java.util.List;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface ISysDictTypeService
|
||||
public interface ISysDictTypeService extends IService<SysDictType>
|
||||
{
|
||||
/**
|
||||
* 根据条件分页查询字典类型
|
||||
@ -18,14 +23,22 @@ public interface ISysDictTypeService
|
||||
* @param dictType 字典类型信息
|
||||
* @return 字典类型集合信息
|
||||
*/
|
||||
List<SysDictType> selectDictTypeList(SysDictType dictType);
|
||||
List<SysDictTypeVo> selectDictTypeList(SysDictTypeBo dictType);
|
||||
|
||||
/**
|
||||
* 分页查询公告列表
|
||||
*
|
||||
* @param dictTypeBo 字典类型信息
|
||||
* @return 分页字典类型集合信息
|
||||
*/
|
||||
TableDataInfo<SysDictTypeVo> selectPage(SysDictTypeBo dictTypeBo);
|
||||
|
||||
/**
|
||||
* 根据所有字典类型
|
||||
*
|
||||
* @return 字典类型集合信息
|
||||
*/
|
||||
List<SysDictType> selectDictTypeAll();
|
||||
List<SysDictTypeVo> selectDictTypeAll();
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据
|
||||
@ -33,7 +46,7 @@ public interface ISysDictTypeService
|
||||
* @param dictType 字典类型
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
List<SysDictData> selectDictDataByType(String dictType);
|
||||
List<SysDictDataVo> selectDictDataByType(String dictType);
|
||||
|
||||
/**
|
||||
* 根据字典类型ID查询信息
|
||||
@ -41,7 +54,7 @@ public interface ISysDictTypeService
|
||||
* @param dictId 字典类型ID
|
||||
* @return 字典类型
|
||||
*/
|
||||
SysDictType selectDictTypeById(Long dictId);
|
||||
SysDictTypeVo selectDictTypeById(Long dictId);
|
||||
|
||||
/**
|
||||
* 根据字典类型查询信息
|
||||
@ -49,14 +62,15 @@ public interface ISysDictTypeService
|
||||
* @param dictType 字典类型
|
||||
* @return 字典类型
|
||||
*/
|
||||
SysDictType selectDictTypeByType(String dictType);
|
||||
SysDictTypeVo selectDictTypeByType(String dictType);
|
||||
|
||||
/**
|
||||
* 批量删除字典信息
|
||||
*
|
||||
* @param dictIds 需要删除的字典ID
|
||||
* @return true 删除成功,false 删除失败。
|
||||
*/
|
||||
void deleteDictTypeByIds(Long[] dictIds);
|
||||
boolean deleteDictTypeByIds(Long[] dictIds);
|
||||
|
||||
/**
|
||||
* 加载字典缓存数据
|
||||
@ -76,26 +90,26 @@ public interface ISysDictTypeService
|
||||
/**
|
||||
* 新增保存字典类型信息
|
||||
*
|
||||
* @param dictType 字典类型信息
|
||||
* @param sysDictTypeBo 字典类型信息
|
||||
* @return 结果
|
||||
*/
|
||||
int insertDictType(SysDictType dictType);
|
||||
List<SysDictDataVo> insertDictType(SysDictTypeBo sysDictTypeBo);
|
||||
|
||||
/**
|
||||
* 修改保存字典类型信息
|
||||
*
|
||||
* @param dictType 字典类型信息
|
||||
* @param dictTypeBo 字典类型信息
|
||||
* @return 结果
|
||||
*/
|
||||
int updateDictType(SysDictType dictType);
|
||||
public List<SysDictDataVo> updateDictType(SysDictTypeBo dictTypeBo);
|
||||
|
||||
/**
|
||||
* 校验字典类型称是否唯一
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param dictTypeBo 字典类型
|
||||
* @return 结果
|
||||
*/
|
||||
boolean checkDictTypeUnique(SysDictType dictType);
|
||||
boolean checkDictTypeUnique(SysDictTypeBo dictTypeBo);
|
||||
|
||||
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public interface ISysNoticeService extends IService<SysNotice>
|
||||
* @param noticeBo 公告信息
|
||||
* @return 公告集合
|
||||
*/
|
||||
TableDataInfo<SysNoticeVo> selectConfigPage(SysNoticeBo noticeBo);
|
||||
TableDataInfo<SysNoticeVo> selectPage(SysNoticeBo noticeBo);
|
||||
|
||||
/**
|
||||
* 新增公告
|
||||
|
@ -29,7 +29,7 @@ public interface ISysPostService extends IService<SysPost>
|
||||
* @param postBo 公告信息
|
||||
* @return 公告集合
|
||||
*/
|
||||
TableDataInfo<SysPostVo> selectConfigPage(SysPostBo postBo);
|
||||
TableDataInfo<SysPostVo> selectPage(SysPostBo postBo);
|
||||
|
||||
/**
|
||||
* 查询所有岗位
|
||||
|
@ -4,21 +4,20 @@ import java.util.List;
|
||||
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.ruoyi.common.core.constant.CacheNames;
|
||||
import com.ruoyi.common.core.core.page.PageDomain;
|
||||
import com.ruoyi.common.core.core.page.TableSupport;
|
||||
import com.ruoyi.common.core.service.ConfigService;
|
||||
import com.ruoyi.common.core.utils.MapstructUtils;
|
||||
import com.ruoyi.common.core.utils.SpringUtils;
|
||||
import com.ruoyi.common.core.utils.sql.SqlUtil;
|
||||
import com.ruoyi.common.orm.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
|
||||
import com.ruoyi.common.redis.utils.CacheUtils;
|
||||
import com.ruoyi.system.domain.bo.SysConfigBo;
|
||||
import com.ruoyi.system.domain.vo.SysConfigVo;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.core.constant.UserConstants;
|
||||
@ -39,7 +38,7 @@ import static com.ruoyi.system.domain.table.SysConfigTableDef.SYS_CONFIG;
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig> implements ISysConfigService, ConfigService {
|
||||
public class SysConfigServiceImpl extends BaseServiceImpl<SysConfigMapper, SysConfig> implements ISysConfigService, ConfigService {
|
||||
@Resource
|
||||
private SysConfigMapper configMapper;
|
||||
|
||||
@ -92,12 +91,11 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
||||
/**
|
||||
* 构造查询条件
|
||||
* @param config
|
||||
* @return
|
||||
* @return 查询条件
|
||||
*/
|
||||
|
||||
private QueryWrapper buildQueryWrapper(SysConfigBo config) {
|
||||
QueryWrapper queryWrapper = query();
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
|
||||
|
||||
if (StringUtils.isNotEmpty(config.getConfigName())) {
|
||||
queryWrapper.and(SYS_CONFIG.CONFIG_NAME.like(config.getConfigName()));
|
||||
@ -116,11 +114,6 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
||||
queryWrapper.and(SYS_CONFIG.CREATE_TIME.le(config.getParams().get("endTime")));
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(pageDomain.getOrderBy())) {
|
||||
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||
queryWrapper.orderBy(orderBy);
|
||||
}
|
||||
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
@ -141,7 +134,7 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
||||
* 分页查询参数配置
|
||||
*
|
||||
* @param config 参数配置信息
|
||||
* @return
|
||||
* @return 分页数据
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<SysConfigVo> selectConfigPage(SysConfigBo config) {
|
||||
@ -159,7 +152,7 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
||||
* @param configBo 参数配置信息
|
||||
* @return 插入行数
|
||||
*/
|
||||
@CachePut(cacheNames = CacheNames.SYS_CONFIG, key = "#configBo.configKey")
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_CONFIG, key = "#configBo.configKey")
|
||||
@Override
|
||||
public int insertConfig(SysConfigBo configBo) {
|
||||
SysConfig sysConfig = MapstructUtils.convert(configBo, SysConfig.class);
|
||||
@ -177,15 +170,10 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
||||
* @param configBo 参数配置信息
|
||||
* @return true 更新成功,false 更新失败。
|
||||
*/
|
||||
@CachePut(cacheNames = CacheNames.SYS_CONFIG, key = "#configBo.configKey")
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_CONFIG, key = "#configBo.configKey")
|
||||
@Override
|
||||
public boolean updateConfig(SysConfigBo configBo) {
|
||||
SysConfig config = MapstructUtils.convert(configBo, SysConfig.class);
|
||||
SysConfig temp = this.getById(config.getConfigId());
|
||||
if (!StringUtils.equals(temp.getConfigKey(), config.getConfigKey())) {
|
||||
CacheUtils.evict(CacheNames.SYS_CONFIG, temp.getConfigKey());
|
||||
}
|
||||
|
||||
return this.updateById(config);
|
||||
}
|
||||
|
||||
|
@ -1,16 +1,32 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryMethods;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.core.update.UpdateChain;
|
||||
import com.ruoyi.common.core.constant.CacheNames;
|
||||
import com.ruoyi.common.core.core.page.PageDomain;
|
||||
import com.ruoyi.common.core.core.page.TableSupport;
|
||||
import com.ruoyi.common.core.utils.MapstructUtils;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.orm.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
|
||||
import com.ruoyi.common.redis.utils.CacheUtils;
|
||||
import com.ruoyi.system.domain.SysDictData;
|
||||
import com.ruoyi.system.domain.bo.SysDictDataBo;
|
||||
import com.ruoyi.system.domain.vo.SysDictDataVo;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.system.mapper.SysDictDataMapper;
|
||||
import com.ruoyi.system.service.ISysDictDataService;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
|
||||
import static com.ruoyi.system.domain.table.SysDictDataTableDef.SYS_DICT_DATA;
|
||||
|
||||
/**
|
||||
* 字典 业务层处理
|
||||
@ -19,21 +35,61 @@ import org.springframework.cache.annotation.CachePut;
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysDictDataServiceImpl implements ISysDictDataService
|
||||
public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataMapper, SysDictData> implements ISysDictDataService
|
||||
{
|
||||
@Resource
|
||||
private SysDictDataMapper dictDataMapper;
|
||||
|
||||
@Override
|
||||
public QueryWrapper query() {
|
||||
return super.query().from(SYS_DICT_DATA);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件分页查询字典数据
|
||||
* 构造查询条件
|
||||
* @param dictDataBo
|
||||
* @return QueryWrapper
|
||||
*/
|
||||
private QueryWrapper buildQueryWrapper(SysDictDataBo dictDataBo) {
|
||||
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
|
||||
if (StringUtils.isNotEmpty(dictDataBo.getDictType())) {
|
||||
queryWrapper.and(SYS_DICT_DATA.DICT_TYPE.eq(dictDataBo.getDictType()));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(dictDataBo.getDictLabel())) {
|
||||
queryWrapper.and(SYS_DICT_DATA.DICT_LABEL.eq(dictDataBo.getDictLabel()));
|
||||
}
|
||||
queryWrapper.orderBy(SYS_DICT_DATA.DICT_SORT.asc());
|
||||
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件查询字典数据
|
||||
*
|
||||
* @param dictData 字典数据信息
|
||||
* @param dictDataBo 字典数据信息
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
@Override
|
||||
public List<SysDictData> selectDictDataList(SysDictData dictData)
|
||||
public List<SysDictDataVo> selectDictDataList(SysDictDataBo dictDataBo)
|
||||
{
|
||||
return dictDataMapper.selectDictDataList(dictData);
|
||||
QueryWrapper queryWrapper = buildQueryWrapper(dictDataBo);
|
||||
return this.listAs(queryWrapper, SysDictDataVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询字典数据
|
||||
*
|
||||
* @param dictDataBo 字典类型信息
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<SysDictDataVo> selectPage(SysDictDataBo dictDataBo) {
|
||||
QueryWrapper queryWrapper = buildQueryWrapper(dictDataBo);
|
||||
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
|
||||
Page<SysDictDataVo> page = this.getMapper().paginateAs(pageDomain.getPageNum(), pageDomain.getPageSize(), queryWrapper, SysDictDataVo.class);
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,7 +102,13 @@ public class SysDictDataServiceImpl implements ISysDictDataService
|
||||
@Override
|
||||
public String selectDictLabel(String dictType, String dictValue)
|
||||
{
|
||||
return dictDataMapper.selectDictLabel(dictType, dictValue);
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.select(SYS_DICT_DATA.DICT_LABEL)
|
||||
.from(SYS_DICT_DATA)
|
||||
.where(SYS_DICT_DATA.DICT_TYPE.eq(dictType))
|
||||
.and(SYS_DICT_DATA.DICT_VALUE.eq(dictValue));
|
||||
|
||||
return dictDataMapper.selectObjectByQueryAs(queryWrapper,String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,64 +118,91 @@ public class SysDictDataServiceImpl implements ISysDictDataService
|
||||
* @return 字典数据
|
||||
*/
|
||||
@Override
|
||||
public SysDictData selectDictDataById(Long dictCode)
|
||||
public SysDictDataVo selectDictDataById(Long dictCode)
|
||||
{
|
||||
return dictDataMapper.selectDictDataById(dictCode);
|
||||
return this.getOneAs(query().where(SYS_DICT_DATA.DICT_CODE.eq(dictCode)),SysDictDataVo.class);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询字典数据记录数量
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 字典数据
|
||||
*/
|
||||
@Override
|
||||
public Integer countDictDataByType(String dictType) {
|
||||
QueryWrapper queryWrapper = QueryWrapper.create()
|
||||
.select(QueryMethods.count(SYS_DICT_DATA.DICT_CODE))
|
||||
.from(SYS_DICT_DATA)
|
||||
.where(SYS_DICT_DATA.DICT_TYPE.eq(dictType));
|
||||
|
||||
return dictDataMapper.selectObjectByQueryAs(queryWrapper,Integer.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
@Cacheable(cacheNames = CacheNames.SYS_DICT, key = "#dictType")
|
||||
@Override
|
||||
public List<SysDictDataVo> selectDictDataByType(String dictType){
|
||||
QueryWrapper queryWrapper=query().and(SYS_DICT_DATA.DICT_TYPE.eq(dictType)).orderBy(SYS_DICT_DATA.DICT_CODE.desc());
|
||||
return this.listAs(queryWrapper, SysDictDataVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除字典数据信息
|
||||
*
|
||||
* @param dictCodes 需要删除的字典数据ID
|
||||
* @return 结果:true 删除成功,false 删除失败。
|
||||
*/
|
||||
@Override
|
||||
public void deleteDictDataByIds(Long[] dictCodes)
|
||||
public boolean deleteDictDataByIds(Long[] dictCodes)
|
||||
{
|
||||
for (Long dictCode : dictCodes)
|
||||
{
|
||||
SysDictData data = selectDictDataById(dictCode);
|
||||
dictDataMapper.deleteDictDataById(dictCode);
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType());
|
||||
//DictUtils.setDictCache(data.getDictType(), dictDatas);
|
||||
SysDictDataVo data = selectDictDataById(dictCode);
|
||||
CacheUtils.evict(CacheNames.SYS_DICT, data.getDictType());
|
||||
}
|
||||
return this.removeByIds(Arrays.asList(dictCodes));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增保存字典数据信息
|
||||
*
|
||||
* @param data 字典数据信息
|
||||
* @return 结果
|
||||
* @param dataBo 字典数据信息
|
||||
* @return 结果:受影响的行数
|
||||
*/
|
||||
@CachePut(cacheNames = CacheNames.SYS_DICT, key = "#data.dictType")
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DICT, key = "#dataBo.dictType")
|
||||
@Override
|
||||
public int insertDictData(SysDictData data)
|
||||
public int insertDictData(SysDictDataBo dataBo)
|
||||
{
|
||||
int row = dictDataMapper.insertDictData(data);
|
||||
if (row > 0)
|
||||
{
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType());
|
||||
//DictUtils.setDictCache(data.getDictType(), dictDatas);
|
||||
}
|
||||
return row;
|
||||
SysDictData data = MapstructUtils.convert(dataBo, SysDictData.class);
|
||||
return dictDataMapper.insert(data,false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存字典数据信息
|
||||
*
|
||||
* @param data 字典数据信息
|
||||
* @return 结果
|
||||
* @param dataBo 字典数据信息
|
||||
* @return 结果:true 更新成功,false 更新失败。
|
||||
*/
|
||||
@CachePut(cacheNames = CacheNames.SYS_DICT, key = "#data.dictType")
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DICT, key = "#dataBo.dictType")
|
||||
@Override
|
||||
public int updateDictData(SysDictData data)
|
||||
public boolean updateDictData(SysDictDataBo dataBo)
|
||||
{
|
||||
int row = dictDataMapper.updateDictData(data);
|
||||
if (row > 0)
|
||||
{
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(data.getDictType());
|
||||
//DictUtils.setDictCache(data.getDictType(), dictDatas);
|
||||
}
|
||||
return row;
|
||||
SysDictData data = MapstructUtils.convert(dataBo, SysDictData.class);
|
||||
return this.updateById(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateDictDataType(String oldDictType, String newDictType){
|
||||
return UpdateChain.of(SysDictData.class)
|
||||
.set(SysDictData::getDictType, newDictType)
|
||||
.where(SysDictData::getDictType).eq(oldDictType)
|
||||
.update();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -7,14 +8,24 @@ import java.util.stream.Collectors;
|
||||
|
||||
import cn.dev33.satoken.context.SaHolder;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.ruoyi.common.core.constant.CacheConstants;
|
||||
import com.ruoyi.common.core.constant.CacheNames;
|
||||
import com.ruoyi.common.core.core.page.PageDomain;
|
||||
import com.ruoyi.common.core.core.page.TableSupport;
|
||||
import com.ruoyi.common.core.service.DictService;
|
||||
import com.ruoyi.common.core.utils.MapstructUtils;
|
||||
import com.ruoyi.common.core.utils.SpringUtils;
|
||||
import com.ruoyi.common.core.utils.StreamUtils;
|
||||
import com.ruoyi.common.orm.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
|
||||
import com.ruoyi.common.redis.utils.CacheUtils;
|
||||
import com.ruoyi.system.domain.SysDictData;
|
||||
import com.ruoyi.system.domain.SysDictType;
|
||||
import com.ruoyi.system.domain.bo.SysDictTypeBo;
|
||||
import com.ruoyi.system.domain.vo.SysDictDataVo;
|
||||
import com.ruoyi.system.domain.vo.SysDictTypeVo;
|
||||
import com.ruoyi.system.service.ISysDictDataService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
@ -23,43 +34,82 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import com.ruoyi.common.core.constant.UserConstants;
|
||||
import com.ruoyi.common.core.exception.ServiceException;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.system.mapper.SysDictDataMapper;
|
||||
import com.ruoyi.system.mapper.SysDictTypeMapper;
|
||||
import com.ruoyi.system.service.ISysDictTypeService;
|
||||
|
||||
import static com.ruoyi.system.domain.table.SysDictTypeTableDef.SYS_DICT_TYPE;
|
||||
|
||||
/**
|
||||
* 字典 业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeMapper, SysDictType> implements ISysDictTypeService, DictService
|
||||
{
|
||||
@Resource
|
||||
private SysDictTypeMapper dictTypeMapper;
|
||||
|
||||
@Resource
|
||||
private SysDictDataMapper dictDataMapper;
|
||||
private ISysDictDataService sysDictDataService;
|
||||
|
||||
@Override
|
||||
public QueryWrapper query() {
|
||||
return super.query().from(SYS_DICT_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 项目启动时,初始化字典到缓存
|
||||
* 构造查询条件
|
||||
* @param dictTypeBo
|
||||
* @return QueryWrapper
|
||||
*/
|
||||
// @PostConstruct
|
||||
// public void init()
|
||||
// {
|
||||
// loadingDictCache();
|
||||
// }
|
||||
|
||||
private QueryWrapper buildQueryWrapper(SysDictTypeBo dictTypeBo){
|
||||
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
|
||||
if (StringUtils.isNotEmpty(dictTypeBo.getDictName())) {
|
||||
queryWrapper.and(SYS_DICT_TYPE.DICT_NAME.like(dictTypeBo.getDictName()));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(dictTypeBo.getDictType())) {
|
||||
queryWrapper.and(SYS_DICT_TYPE.DICT_TYPE.eq(dictTypeBo.getDictType()));
|
||||
}
|
||||
if (StringUtils.isNotEmpty((String) dictTypeBo.getParams().get("beginTime")) ) {
|
||||
queryWrapper.and(SYS_DICT_TYPE.CREATE_TIME.ge(dictTypeBo.getParams().get("beginTime")));
|
||||
}
|
||||
if (StringUtils.isNotEmpty((String) dictTypeBo.getParams().get("endTime")) ) {
|
||||
queryWrapper.and(SYS_DICT_TYPE.CREATE_TIME.le(dictTypeBo.getParams().get("endTime")));
|
||||
}
|
||||
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件分页查询字典类型
|
||||
*
|
||||
* @param dictType 字典类型信息
|
||||
* @param dictTypeBo 字典类型信息
|
||||
* @return 字典类型集合信息
|
||||
*/
|
||||
@Override
|
||||
public List<SysDictType> selectDictTypeList(SysDictType dictType)
|
||||
public List<SysDictTypeVo> selectDictTypeList(SysDictTypeBo dictTypeBo)
|
||||
{
|
||||
return dictTypeMapper.selectDictTypeList(dictType);
|
||||
QueryWrapper queryWrapper = buildQueryWrapper(dictTypeBo);
|
||||
|
||||
return this.listAs(queryWrapper, SysDictTypeVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询字典类型
|
||||
*
|
||||
* @param dictTypeBo 字典类型信息
|
||||
* @return 字典类型集合信息
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<SysDictTypeVo> selectPage(SysDictTypeBo dictTypeBo) {
|
||||
QueryWrapper queryWrapper = buildQueryWrapper(dictTypeBo);
|
||||
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
|
||||
Page<SysDictTypeVo> page = this.getMapper().paginateAs(pageDomain.getPageNum(), pageDomain.getPageSize(), queryWrapper, SysDictTypeVo.class);
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -68,9 +118,9 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
* @return 字典类型集合信息
|
||||
*/
|
||||
@Override
|
||||
public List<SysDictType> selectDictTypeAll()
|
||||
public List<SysDictTypeVo> selectDictTypeAll()
|
||||
{
|
||||
return dictTypeMapper.selectDictTypeAll();
|
||||
return this.listAs(query(), SysDictTypeVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,13 +131,12 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
*/
|
||||
@Cacheable(cacheNames = CacheNames.SYS_DICT, key = "#dictType")
|
||||
@Override
|
||||
public List<SysDictData> selectDictDataByType(String dictType)
|
||||
public List<SysDictDataVo> selectDictDataByType(String dictType)
|
||||
{
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictType);
|
||||
if (StringUtils.isNotEmpty(dictDatas))
|
||||
List<SysDictDataVo> lists = sysDictDataService.selectDictDataByType(dictType);
|
||||
if (StringUtils.isNotEmpty(lists))
|
||||
{
|
||||
//DictUtils.setDictCache(dictType, dictDatas);
|
||||
return dictDatas;
|
||||
return lists;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -99,9 +148,9 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
* @return 字典类型
|
||||
*/
|
||||
@Override
|
||||
public SysDictType selectDictTypeById(Long dictId)
|
||||
public SysDictTypeVo selectDictTypeById(Long dictId)
|
||||
{
|
||||
return dictTypeMapper.selectDictTypeById(dictId);
|
||||
return this.getOneAs(query().where(SYS_DICT_TYPE.DICT_ID.eq(dictId)),SysDictTypeVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,30 +160,30 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
* @return 字典类型
|
||||
*/
|
||||
@Override
|
||||
public SysDictType selectDictTypeByType(String dictType)
|
||||
public SysDictTypeVo selectDictTypeByType(String dictType)
|
||||
{
|
||||
return dictTypeMapper.selectDictTypeByType(dictType);
|
||||
return this.getOneAs(query().where(SYS_DICT_TYPE.DICT_TYPE.eq(dictType)),SysDictTypeVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除字典类型信息
|
||||
*
|
||||
* @param dictIds 需要删除的字典ID
|
||||
* @return true 删除成功,false 删除失败。
|
||||
*/
|
||||
@Override
|
||||
public void deleteDictTypeByIds(Long[] dictIds)
|
||||
public boolean deleteDictTypeByIds(Long[] dictIds)
|
||||
{
|
||||
for (Long dictId : dictIds)
|
||||
{
|
||||
SysDictType dictType = selectDictTypeById(dictId);
|
||||
if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0)
|
||||
SysDictTypeVo dictType = selectDictTypeById(dictId);
|
||||
if (sysDictDataService.countDictDataByType(dictType.getDictType()) > 0)
|
||||
{
|
||||
throw new ServiceException(String.format("%1$s已分配,不能删除", dictType.getDictName()));
|
||||
}
|
||||
dictTypeMapper.deleteDictTypeById(dictId);
|
||||
//DictUtils.removeDictCache(dictType.getDictType());
|
||||
CacheUtils.evict(CacheNames.SYS_DICT, dictType.getDictType());
|
||||
}
|
||||
return this.removeByIds(Arrays.asList(dictIds));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -149,56 +198,60 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
/**
|
||||
* 新增保存字典类型信息
|
||||
*
|
||||
* @param dict 字典类型信息
|
||||
* @param sysDictTypeBo 字典类型信息
|
||||
* @return 结果
|
||||
*/
|
||||
@CachePut(cacheNames = CacheNames.SYS_DICT, key = "#dict.dictType")
|
||||
@CachePut(cacheNames = CacheNames.SYS_DICT, key = "#sysDictTypeBo.dictType")
|
||||
@Override
|
||||
public int insertDictType(SysDictType dict)
|
||||
public List<SysDictDataVo> insertDictType(SysDictTypeBo sysDictTypeBo)
|
||||
{
|
||||
int row = dictTypeMapper.insertDictType(dict);
|
||||
SysDictType dict = MapstructUtils.convert(sysDictTypeBo, SysDictType.class);
|
||||
int row = dictTypeMapper.insert(dict,false);
|
||||
if (row > 0)
|
||||
{
|
||||
//DictUtils.setDictCache(dict.getDictType(), null);
|
||||
return row;
|
||||
// 新增 type 下无 data 数据 返回空防止缓存穿透
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return 0;
|
||||
throw new ServiceException("插入操作失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存字典类型信息
|
||||
*
|
||||
* @param dict 字典类型信息
|
||||
* @param dictTypeBo 字典类型信息
|
||||
* @return 结果
|
||||
*/
|
||||
@CachePut(cacheNames = CacheNames.SYS_DICT, key = "#dict.dictType")
|
||||
@CachePut(cacheNames = CacheNames.SYS_DICT, key = "#dictTypeBo.dictType")
|
||||
@Override
|
||||
@Transactional
|
||||
public int updateDictType(SysDictType dict)
|
||||
public List<SysDictDataVo> updateDictType(SysDictTypeBo dictTypeBo)
|
||||
{
|
||||
SysDictType oldDict = dictTypeMapper.selectDictTypeById(dict.getDictId());
|
||||
dictDataMapper.updateDictDataType(oldDict.getDictType(), dict.getDictType());
|
||||
int row = dictTypeMapper.updateDictType(dict);
|
||||
if (row > 0)
|
||||
{
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dict.getDictType());
|
||||
//DictUtils.setDictCache(dict.getDictType(), dictDatas);
|
||||
CacheUtils.evict(CacheNames.SYS_DICT, oldDict.getDictType());
|
||||
SysDictType dict = MapstructUtils.convert(dictTypeBo, SysDictType.class);
|
||||
SysDictTypeVo oldDict = selectDictTypeById(dict.getDictId());
|
||||
if (!oldDict.getDictType().equals(dict.getDictType())) {
|
||||
sysDictDataService.updateDictDataType(oldDict.getDictType(), dict.getDictType());
|
||||
}
|
||||
return row;
|
||||
|
||||
boolean updated = this.updateById(dict);
|
||||
if (updated)
|
||||
{
|
||||
CacheUtils.evict(CacheNames.SYS_DICT, oldDict.getDictType());
|
||||
return sysDictDataService.selectDictDataByType(dict.getDictType());
|
||||
}
|
||||
throw new ServiceException("修改操作失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验字典类型称是否唯一
|
||||
*
|
||||
* @param dict 字典类型
|
||||
* @param dictTypeBo 字典类型
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean checkDictTypeUnique(SysDictType dict)
|
||||
public boolean checkDictTypeUnique(SysDictTypeBo dictTypeBo)
|
||||
{
|
||||
Long dictId = StringUtils.isNull(dict.getDictId()) ? -1L : dict.getDictId();
|
||||
SysDictType dictType = dictTypeMapper.checkDictTypeUnique(dict.getDictType());
|
||||
Long dictId = StringUtils.isNull(dictTypeBo.getDictId()) ? -1L : dictTypeBo.getDictId();
|
||||
SysDictType dictType = this.getOne(query().where(SYS_DICT_TYPE.DICT_TYPE.eq(dictTypeBo.getDictType())));
|
||||
if (StringUtils.isNotNull(dictType) && dictType.getDictId().longValue() != dictId.longValue())
|
||||
{
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
@ -218,13 +271,13 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
@Override
|
||||
public String getDictLabel(String dictType, String dictValue, String separator) {
|
||||
// 优先从本地缓存获取
|
||||
List<SysDictData> datas = (List<SysDictData>) SaHolder.getStorage().get(CacheConstants.SYS_DICT_KEY + dictType);
|
||||
if (ObjectUtil.isNull(datas)) {
|
||||
datas = SpringUtils.getAopProxy(this).selectDictDataByType(dictType);
|
||||
SaHolder.getStorage().set(CacheConstants.SYS_DICT_KEY + dictType, datas);
|
||||
List<SysDictDataVo> lists = (List<SysDictDataVo>) SaHolder.getStorage().get(CacheConstants.SYS_DICT_KEY + dictType);
|
||||
if (ObjectUtil.isNull(lists)) {
|
||||
lists = SpringUtils.getAopProxy(this).selectDictDataByType(dictType);
|
||||
SaHolder.getStorage().set(CacheConstants.SYS_DICT_KEY + dictType, lists);
|
||||
}
|
||||
|
||||
Map<String, String> map = StreamUtils.toMap(datas, SysDictData::getDictValue, SysDictData::getDictLabel);
|
||||
Map<String, String> map = StreamUtils.toMap(lists, SysDictDataVo::getDictValue, SysDictDataVo::getDictLabel);
|
||||
if (StringUtils.containsAny(dictValue, separator)) {
|
||||
return Arrays.stream(dictValue.split(separator))
|
||||
.map(v -> map.getOrDefault(v, StringUtils.EMPTY))
|
||||
@ -246,13 +299,13 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
@Override
|
||||
public String getDictValue(String dictType, String dictLabel, String separator) {
|
||||
// 优先从本地缓存获取
|
||||
List<SysDictData> datas = (List<SysDictData>) SaHolder.getStorage().get(CacheConstants.SYS_DICT_KEY + dictType);
|
||||
if (ObjectUtil.isNull(datas)) {
|
||||
datas = SpringUtils.getAopProxy(this).selectDictDataByType(dictType);
|
||||
SaHolder.getStorage().set(CacheConstants.SYS_DICT_KEY + dictType, datas);
|
||||
List<SysDictDataVo> lists = (List<SysDictDataVo>) SaHolder.getStorage().get(CacheConstants.SYS_DICT_KEY + dictType);
|
||||
if (ObjectUtil.isNull(lists)) {
|
||||
lists = SpringUtils.getAopProxy(this).selectDictDataByType(dictType);
|
||||
SaHolder.getStorage().set(CacheConstants.SYS_DICT_KEY + dictType, lists);
|
||||
}
|
||||
|
||||
Map<String, String> map = StreamUtils.toMap(datas, SysDictData::getDictLabel, SysDictData::getDictValue);
|
||||
Map<String, String> map = StreamUtils.toMap(lists, SysDictDataVo::getDictLabel, SysDictDataVo::getDictValue);
|
||||
if (StringUtils.containsAny(dictLabel, separator)) {
|
||||
return Arrays.stream(dictLabel.split(separator))
|
||||
.map(l -> map.getOrDefault(l, StringUtils.EMPTY))
|
||||
@ -264,7 +317,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
||||
|
||||
@Override
|
||||
public Map<String, String> getAllDictByDictType(String dictType) {
|
||||
List<SysDictData> list = selectDictDataByType(dictType);
|
||||
return StreamUtils.toMap(list, SysDictData::getDictValue, SysDictData::getDictLabel);
|
||||
List<SysDictDataVo> list = selectDictDataByType(dictType);
|
||||
return StreamUtils.toMap(list, SysDictDataVo::getDictValue, SysDictDataVo::getDictLabel);
|
||||
}
|
||||
}
|
||||
|
@ -5,13 +5,13 @@ import java.util.List;
|
||||
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.ruoyi.common.core.core.page.PageDomain;
|
||||
import com.ruoyi.common.core.core.page.TableSupport;
|
||||
import com.ruoyi.common.core.utils.MapstructUtils;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.core.utils.sql.SqlUtil;
|
||||
import com.ruoyi.common.orm.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
|
||||
import com.ruoyi.system.domain.bo.SysNoticeBo;
|
||||
import com.ruoyi.system.domain.vo.SysNoticeVo;
|
||||
import jakarta.annotation.Resource;
|
||||
@ -29,7 +29,7 @@ import static com.ruoyi.system.domain.table.SysNoticeTableDef.SYS_NOTICE;
|
||||
* @author 数据小王子
|
||||
*/
|
||||
@Service
|
||||
public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice> implements ISysNoticeService {
|
||||
public class SysNoticeServiceImpl extends BaseServiceImpl<SysNoticeMapper, SysNotice> implements ISysNoticeService {
|
||||
@Resource
|
||||
private SysNoticeMapper noticeMapper;
|
||||
|
||||
@ -53,10 +53,10 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
||||
* 根据noticeBo构建QueryWrapper查询条件
|
||||
*
|
||||
* @param noticeBo
|
||||
* @return
|
||||
* @return 查询条件
|
||||
*/
|
||||
private QueryWrapper buildQueryWrapper(SysNoticeBo noticeBo) {
|
||||
QueryWrapper queryWrapper = query();
|
||||
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
|
||||
if (StringUtils.isNotEmpty(noticeBo.getNoticeTitle())) {
|
||||
@ -95,7 +95,7 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
||||
* @return 公告集合
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<SysNoticeVo> selectConfigPage(SysNoticeBo noticeBo) {
|
||||
public TableDataInfo<SysNoticeVo> selectPage(SysNoticeBo noticeBo) {
|
||||
QueryWrapper queryWrapper = buildQueryWrapper(noticeBo);
|
||||
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
|
@ -5,12 +5,12 @@ import java.util.List;
|
||||
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.ruoyi.common.core.core.page.PageDomain;
|
||||
import com.ruoyi.common.core.core.page.TableSupport;
|
||||
import com.ruoyi.common.core.utils.MapstructUtils;
|
||||
import com.ruoyi.common.core.utils.sql.SqlUtil;
|
||||
import com.ruoyi.common.orm.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
|
||||
import com.ruoyi.system.domain.bo.SysPostBo;
|
||||
import com.ruoyi.system.domain.vo.SysPostVo;
|
||||
import jakarta.annotation.Resource;
|
||||
@ -31,7 +31,7 @@ import static com.ruoyi.system.domain.table.SysPostTableDef.SYS_POST;
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> implements ISysPostService
|
||||
public class SysPostServiceImpl extends BaseServiceImpl<SysPostMapper, SysPost> implements ISysPostService
|
||||
{
|
||||
@Resource
|
||||
private SysPostMapper postMapper;
|
||||
@ -47,10 +47,10 @@ public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> imp
|
||||
/**
|
||||
* 根据postBo构建QueryWrapper查询条件
|
||||
* @param postBo
|
||||
* @return
|
||||
* @return 查询条件
|
||||
*/
|
||||
private QueryWrapper buildQueryWrapper(SysPostBo postBo) {
|
||||
QueryWrapper queryWrapper = query();
|
||||
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
|
||||
if (StringUtils.isNotEmpty(postBo.getPostCode())) {
|
||||
@ -90,7 +90,7 @@ public class SysPostServiceImpl extends ServiceImpl<SysPostMapper, SysPost> imp
|
||||
* @return 公告集合
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<SysPostVo> selectConfigPage(SysPostBo postBo) {
|
||||
public TableDataInfo<SysPostVo> selectPage(SysPostBo postBo) {
|
||||
QueryWrapper queryWrapper = buildQueryWrapper(postBo);
|
||||
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
|
@ -24,94 +24,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
from sys_dict_data
|
||||
</sql>
|
||||
|
||||
<select id="selectDictDataList" parameterType="SysDictData" resultMap="SysDictDataResult">
|
||||
<include refid="selectDictDataVo"/>
|
||||
<where>
|
||||
<if test="dictType != null and dictType != ''">
|
||||
AND dict_type = #{dictType}
|
||||
</if>
|
||||
<if test="dictLabel != null and dictLabel != ''">
|
||||
AND dict_label like concat('%', #{dictLabel}, '%')
|
||||
</if>
|
||||
</where>
|
||||
order by dict_sort asc
|
||||
</select>
|
||||
|
||||
<select id="selectDictDataByType" parameterType="SysDictData" resultMap="SysDictDataResult">
|
||||
<include refid="selectDictDataVo"/>
|
||||
where dict_type = #{dictType} order by dict_sort asc
|
||||
</select>
|
||||
|
||||
<select id="selectDictLabel" resultType="String">
|
||||
select dict_label from sys_dict_data
|
||||
where dict_type = #{dictType} and dict_value = #{dictValue}
|
||||
</select>
|
||||
|
||||
<select id="selectDictDataById" parameterType="Long" resultMap="SysDictDataResult">
|
||||
<include refid="selectDictDataVo"/>
|
||||
where dict_code = #{dictCode}
|
||||
</select>
|
||||
|
||||
<select id="countDictDataByType" resultType="Integer">
|
||||
select count(1) from sys_dict_data where dict_type=#{dictType}
|
||||
</select>
|
||||
|
||||
<delete id="deleteDictDataById" parameterType="Long">
|
||||
delete from sys_dict_data where dict_code = #{dictCode}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteDictDataByIds" parameterType="Long">
|
||||
delete from sys_dict_data where dict_code in
|
||||
<foreach collection="array" item="dictCode" open="(" separator="," close=")">
|
||||
#{dictCode}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<update id="updateDictData" parameterType="SysDictData">
|
||||
update sys_dict_data
|
||||
<set>
|
||||
<if test="dictSort != null">dict_sort = #{dictSort},</if>
|
||||
<if test="dictLabel != null and dictLabel != ''">dict_label = #{dictLabel},</if>
|
||||
<if test="dictValue != null and dictValue != ''">dict_value = #{dictValue},</if>
|
||||
<if test="dictType != null and dictType != ''">dict_type = #{dictType},</if>
|
||||
<if test="cssClass != null">css_class = #{cssClass},</if>
|
||||
<if test="listClass != null">list_class = #{listClass},</if>
|
||||
<if test="isDefault != null and isDefault != ''">is_default = #{isDefault},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where dict_code = #{dictCode}
|
||||
</update>
|
||||
|
||||
<update id="updateDictDataType" parameterType="String">
|
||||
update sys_dict_data set dict_type = #{newDictType} where dict_type = #{oldDictType}
|
||||
</update>
|
||||
|
||||
<insert id="insertDictData" parameterType="SysDictData">
|
||||
insert into sys_dict_data(
|
||||
<if test="dictSort != null">dict_sort,</if>
|
||||
<if test="dictLabel != null and dictLabel != ''">dict_label,</if>
|
||||
<if test="dictValue != null and dictValue != ''">dict_value,</if>
|
||||
<if test="dictType != null and dictType != ''">dict_type,</if>
|
||||
<if test="cssClass != null and cssClass != ''">css_class,</if>
|
||||
<if test="listClass != null and listClass != ''">list_class,</if>
|
||||
<if test="isDefault != null and isDefault != ''">is_default,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
create_time
|
||||
)values(
|
||||
<if test="dictSort != null">#{dictSort},</if>
|
||||
<if test="dictLabel != null and dictLabel != ''">#{dictLabel},</if>
|
||||
<if test="dictValue != null and dictValue != ''">#{dictValue},</if>
|
||||
<if test="dictType != null and dictType != ''">#{dictType},</if>
|
||||
<if test="cssClass != null and cssClass != ''">#{cssClass},</if>
|
||||
<if test="listClass != null and listClass != ''">#{listClass},</if>
|
||||
<if test="isDefault != null and isDefault != ''">#{isDefault},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
@ -19,80 +19,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
from sys_dict_type
|
||||
</sql>
|
||||
|
||||
<select id="selectDictTypeList" parameterType="SysDictType" resultMap="SysDictTypeResult">
|
||||
<include refid="selectDictTypeVo"/>
|
||||
<where>
|
||||
<if test="dictName != null and dictName != ''">
|
||||
AND dict_name like concat('%', #{dictName}, '%')
|
||||
</if>
|
||||
<if test="dictType != null and dictType != ''">
|
||||
AND dict_type like concat('%', #{dictType}, '%')
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||
and date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
and date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectDictTypeAll" resultMap="SysDictTypeResult">
|
||||
<include refid="selectDictTypeVo"/>
|
||||
</select>
|
||||
|
||||
<select id="selectDictTypeById" parameterType="Long" resultMap="SysDictTypeResult">
|
||||
<include refid="selectDictTypeVo"/>
|
||||
where dict_id = #{dictId}
|
||||
</select>
|
||||
|
||||
<select id="selectDictTypeByType" parameterType="String" resultMap="SysDictTypeResult">
|
||||
<include refid="selectDictTypeVo"/>
|
||||
where dict_type = #{dictType}
|
||||
</select>
|
||||
|
||||
<select id="checkDictTypeUnique" parameterType="String" resultMap="SysDictTypeResult">
|
||||
<include refid="selectDictTypeVo"/>
|
||||
where dict_type = #{dictType} limit 1
|
||||
</select>
|
||||
|
||||
<delete id="deleteDictTypeById" parameterType="Long">
|
||||
delete from sys_dict_type where dict_id = #{dictId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteDictTypeByIds" parameterType="Long">
|
||||
delete from sys_dict_type where dict_id in
|
||||
<foreach collection="array" item="dictId" open="(" separator="," close=")">
|
||||
#{dictId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<update id="updateDictType" parameterType="SysDictType">
|
||||
update sys_dict_type
|
||||
<set>
|
||||
<if test="dictName != null and dictName != ''">dict_name = #{dictName},</if>
|
||||
<if test="dictType != null and dictType != ''">dict_type = #{dictType},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where dict_id = #{dictId}
|
||||
</update>
|
||||
|
||||
<insert id="insertDictType" parameterType="SysDictType">
|
||||
insert into sys_dict_type(
|
||||
<if test="dictName != null and dictName != ''">dict_name,</if>
|
||||
<if test="dictType != null and dictType != ''">dict_type,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
create_time
|
||||
)values(
|
||||
<if test="dictName != null and dictName != ''">#{dictName},</if>
|
||||
<if test="dictType != null and dictType != ''">#{dictType},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue
Block a user