Merge branch 'caihaohan' into lixuetao
# Conflicts: # adc-da-report/src/main/java/com/adc/da/report/controller/ReportManageConroller.java
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package com.adc.da.eo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ThinkBook
|
||||
* @TableName ts_config
|
||||
*/
|
||||
@TableName(value ="ts_config")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ConfigEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 23487320957329L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.INPUT)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 配置名
|
||||
*/
|
||||
@TableField(value = "config_key")
|
||||
private String configKey;
|
||||
|
||||
/**
|
||||
* 配置信息
|
||||
*/
|
||||
@TableField(value = "config_value")
|
||||
private String configValue;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.adc.da.eo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ThinkBook
|
||||
* @TableName ts_dict
|
||||
*/
|
||||
@TableName(value ="ts_dict")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DictEntity implements Serializable {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.INPUT)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
@TableField(value = "dic_name")
|
||||
private String dicName;
|
||||
|
||||
/**
|
||||
* 字典编码
|
||||
*/
|
||||
@TableField(value = "dic_code")
|
||||
private String dicCode;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@TableField(value = "description")
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 创建用户id
|
||||
*/
|
||||
@TableField(value = "create_user")
|
||||
private String createUser;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新用户id
|
||||
*/
|
||||
@TableField(value = "update_user")
|
||||
private String updateUser;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 删除标志 0存在 1删除
|
||||
*/
|
||||
@TableField(value = "del_flag")
|
||||
private Integer delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1564756474576568768L;
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.adc.da.eo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Caihaohan
|
||||
* @TableName ts_dict_item
|
||||
*/
|
||||
@TableName(value ="ts_dict_item")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class DictItemEntity implements Serializable {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.INPUT)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 字典id
|
||||
*/
|
||||
@TableField(value = "type_id")
|
||||
private String typeId;
|
||||
|
||||
/**
|
||||
* 数据名称
|
||||
*/
|
||||
@TableField(value = "item_name")
|
||||
private String itemName;
|
||||
|
||||
/**
|
||||
* 数据值
|
||||
*/
|
||||
@TableField(value = "item_value")
|
||||
private String itemValue;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@TableField(value = "item_description")
|
||||
private String itemDescription;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@TableField(value = "item_order")
|
||||
private Double itemOrder;
|
||||
|
||||
/**
|
||||
* 启用标志 0不启用 1启用
|
||||
*/
|
||||
@TableField(value = "item_status")
|
||||
private Integer itemStatus;
|
||||
|
||||
/**
|
||||
* 创建用户id
|
||||
*/
|
||||
@TableField(value = "create_user")
|
||||
private String createUser;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新用户id
|
||||
*/
|
||||
@TableField(value = "update_user")
|
||||
private String updateUser;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 删除标志 0存在 1删除
|
||||
*/
|
||||
@TableField(value = "del_flag")
|
||||
private Integer delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 12134213414324536L;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.adc.da.sys.constant;
|
||||
|
||||
/**
|
||||
* @author CaiHaohan
|
||||
*/
|
||||
|
||||
public enum TsConfigKeyEnum {
|
||||
|
||||
/**
|
||||
* 水印前缀
|
||||
*/
|
||||
WATERMARK_PREFIX("WATERMARK_PREFIX", "水印前缀");
|
||||
|
||||
|
||||
/**
|
||||
* 对应Key
|
||||
*/
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 代表意义
|
||||
*/
|
||||
private String label;
|
||||
|
||||
TsConfigKeyEnum(String value, String label) {
|
||||
this.value = value;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.adc.da.sys.controller;
|
||||
|
||||
import com.adc.da.sys.service.iservice.IConfigService;
|
||||
import com.adc.da.sys.vo.ConfigVo;
|
||||
import com.adc.da.util.http.ResponseMessage;
|
||||
import com.adc.da.util.http.Result;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author Caihaohan
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/${restPath}/sys/config")
|
||||
@Api(tags = {"Sys-基础设置"})
|
||||
public class ConfigController {
|
||||
|
||||
@Resource
|
||||
private IConfigService iConfigService;
|
||||
|
||||
/**
|
||||
* 获取一个基本设置项
|
||||
*/
|
||||
@ApiOperation(value = "获取一个基本设置项")
|
||||
@GetMapping("/{key}")
|
||||
public ResponseMessage findConfig(@NotNull @PathVariable String key) {
|
||||
return iConfigService.findConfig(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有基本设置项
|
||||
*/
|
||||
@ApiOperation(value = "获取所有基本设置项")
|
||||
@GetMapping("/all")
|
||||
public ResponseMessage findAllConfig() {
|
||||
try {
|
||||
return Result.success(iConfigService.findAllConfig());
|
||||
} catch (Exception e) {
|
||||
log.error("获取所有基本设置项", e);
|
||||
return Result.error("获取失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存基本设置项
|
||||
*/
|
||||
@ApiOperation(value = "保存/更新 基本设置项")
|
||||
@PostMapping("/save")
|
||||
public ResponseMessage saveConfig(@RequestBody ConfigVo configVo) {
|
||||
return iConfigService.saveOrUpdateConfig(configVo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.adc.da.sys.controller;
|
||||
|
||||
|
||||
import com.adc.da.sys.service.iservice.IDictService;
|
||||
import com.adc.da.sys.vo.DictQueryVo;
|
||||
import com.adc.da.sys.vo.DictVo;
|
||||
import com.adc.da.util.http.ResponseMessage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author CaiHaohan
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/${restPath}/sys/dict")
|
||||
@Api(tags = {"Sys-数据字典"})
|
||||
public class DictController {
|
||||
|
||||
@Resource
|
||||
private IDictService dictService;
|
||||
|
||||
/**
|
||||
* 获取一个基本设置项
|
||||
*/
|
||||
@ApiOperation(value = "分页获取所有数据字典")
|
||||
@GetMapping("/page")
|
||||
public ResponseMessage page(@Valid DictQueryVo dictQueryVo) {
|
||||
return dictService.pageByCondition(dictQueryVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改一个字典
|
||||
*/
|
||||
@ApiOperation(value = "修改数据字典")
|
||||
@PutMapping("/edit")
|
||||
public ResponseMessage edit(@RequestBody DictVo dictVo) {
|
||||
return dictService.edit(dictVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除一个字典
|
||||
*/
|
||||
@ApiOperation(value = "删除数据字典")
|
||||
@DeleteMapping("/delete")
|
||||
public ResponseMessage delete(@RequestParam("ids") List<String> ids) {
|
||||
return dictService.delete(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除一个字典
|
||||
*/
|
||||
@ApiOperation(value = "新增数据字典")
|
||||
@PostMapping("/add")
|
||||
public ResponseMessage add(@RequestBody DictVo dictVo) {
|
||||
return dictService.add(dictVo);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.adc.da.sys.controller;
|
||||
|
||||
import com.adc.da.sys.service.iservice.IDictItemService;
|
||||
import com.adc.da.sys.vo.DictItemQueryVo;
|
||||
import com.adc.da.sys.vo.DictItemVo;
|
||||
import com.adc.da.util.http.ResponseMessage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author CaiHaohan
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/${restPath}/sys/dictItem")
|
||||
@Api(tags = {"Sys-数据字典记录"})
|
||||
public class DictItemController {
|
||||
|
||||
@Resource
|
||||
private IDictItemService dictItemService;
|
||||
|
||||
/**
|
||||
* 根据字典编码获取所有选项
|
||||
*/
|
||||
@ApiOperation(value = "根据字典编码获取所有选项")
|
||||
@GetMapping("/{dicCode}")
|
||||
public ResponseMessage listByPageCode(@PathVariable String dicCode) {
|
||||
return dictItemService.listByPageCode(dicCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页获取所有数据字典记录
|
||||
*/
|
||||
@ApiOperation(value = "分页获取所有数据字典记录")
|
||||
@GetMapping("/page")
|
||||
public ResponseMessage pageByDicId(@Valid DictItemQueryVo dictItemQueryVo) {
|
||||
return dictItemService.pageById(dictItemQueryVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据字典记录
|
||||
*/
|
||||
@ApiOperation(value = "修改数据字典记录")
|
||||
@PutMapping("/edit")
|
||||
public ResponseMessage edit(@RequestBody DictItemVo dictItemVo) {
|
||||
return dictItemService.edit(dictItemVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据字典记录
|
||||
*/
|
||||
@ApiOperation(value = "删除数据字典记录")
|
||||
@DeleteMapping("/delete")
|
||||
public ResponseMessage delete(@RequestParam List<String> ids) {
|
||||
return dictItemService.delete(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据字典记录
|
||||
*/
|
||||
@ApiOperation(value = "新增数据字典记录")
|
||||
@PostMapping("/add")
|
||||
public ResponseMessage add(@RequestBody DictItemVo dictItemVo) {
|
||||
return dictItemService.add(dictItemVo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.adc.da.sys.dao.mysql;
|
||||
|
||||
|
||||
import com.adc.da.eo.ConfigEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author ThinkBook
|
||||
* @description 针对表【ts_config】的数据库操作Mapper
|
||||
* @createDate 2023-05-04 09:45:30
|
||||
* @Entity generator.eo.ConfigEntity
|
||||
*/
|
||||
public interface ConfigDao extends BaseMapper<ConfigEntity> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.adc.da.sys.dao.mysql;
|
||||
|
||||
import com.adc.da.eo.DictEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author ThinkBook
|
||||
* @description 针对表【ts_dict】的数据库操作Mapper
|
||||
* @createDate 2023-05-05 10:28:12
|
||||
* @Entity com.adc.da.eo.DictEntity
|
||||
*/
|
||||
public interface DictDao extends BaseMapper<DictEntity> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.adc.da.sys.dao.mysql;
|
||||
|
||||
import com.adc.da.eo.DictItemEntity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author ThinkBook
|
||||
* @description 针对表【ts_dict_item】的数据库操作Mapper
|
||||
* @createDate 2023-05-05 10:28:25
|
||||
* @Entity com.adc.da.eo.DictItemEntity
|
||||
*/
|
||||
public interface DictItemDao extends BaseMapper<DictItemEntity> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.adc.da.sys.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.adc.da.sys.constant.TsConfigKeyEnum;
|
||||
import com.adc.da.sys.vo.ConfigVo;
|
||||
import com.adc.da.util.http.ResponseMessage;
|
||||
import com.adc.da.util.http.Result;
|
||||
import com.adc.da.util.utils.UUID;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.adc.da.eo.ConfigEntity;
|
||||
import com.adc.da.sys.service.iservice.IConfigService;
|
||||
import com.adc.da.sys.dao.mysql.ConfigDao;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author ThinkBook
|
||||
* @description 针对表【ts_config】的数据库操作Service实现
|
||||
* @createDate 2023-05-04 09:45:30
|
||||
*/
|
||||
@Service
|
||||
public class ConfigServiceImpl extends ServiceImpl<ConfigDao, ConfigEntity>
|
||||
implements IConfigService {
|
||||
|
||||
@Override
|
||||
public ResponseMessage saveOrUpdateConfig(ConfigVo configVo) {
|
||||
try {
|
||||
// 先查询
|
||||
ConfigEntity configEntity = new ConfigEntity();
|
||||
BeanUtil.copyProperties(configVo, configEntity);
|
||||
|
||||
//判断Key是否是后端预设好的
|
||||
if (isKeyValid(configEntity.getConfigKey())) {
|
||||
List<ConfigEntity> configEntityList = query().eq("config_key", configEntity.getConfigKey()).list();
|
||||
if (!configEntityList.isEmpty()){
|
||||
ConfigEntity existDbConfig = configEntityList.get(0);
|
||||
configEntity.setId(existDbConfig.getId());
|
||||
updateById(configEntity);
|
||||
} else {
|
||||
configEntity.setId(UUID.randomUUID10());
|
||||
save(configEntity);
|
||||
}
|
||||
return Result.success("保存成功");
|
||||
}
|
||||
return Result.error("配置项Key不存在");
|
||||
} catch (Exception e) {
|
||||
log.error("保存基本设置项失败", e);
|
||||
return Result.error("保存失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ConfigVo> findAllConfig() {
|
||||
List<ConfigVo> result = new ArrayList<>();
|
||||
for (TsConfigKeyEnum configKey : TsConfigKeyEnum.values()) {
|
||||
List<ConfigEntity> configEntityList = query().eq("config_key", configKey.getValue()).list();
|
||||
if (!configEntityList.isEmpty()){
|
||||
ConfigVo configVo = new ConfigVo();
|
||||
BeanUtil.copyProperties(configEntityList.get(0), configVo);
|
||||
result.add(configVo);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseMessage findConfig(String key) {
|
||||
if (isKeyValid(key)) {
|
||||
ConfigEntity configEntity = query().eq("config_key", key).one();
|
||||
ConfigVo configVo = new ConfigVo();
|
||||
BeanUtil.copyProperties(configEntity, configVo);
|
||||
return Result.success(configVo);
|
||||
}
|
||||
return Result.error("配置项Key不存在");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String findConfigValueByKey(String key) {
|
||||
if (isKeyValid(key)) {
|
||||
ConfigEntity configEntity = query().eq("config_key", key).one();
|
||||
return configEntity.getConfigValue();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断传入的key是否是后端预设好的key
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
private boolean isKeyValid(String key) {
|
||||
for (TsConfigKeyEnum configKey : TsConfigKeyEnum.values()) {
|
||||
if (configKey.getValue().equals(key)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
package com.adc.da.sys.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.adc.da.eo.DictEntity;
|
||||
import com.adc.da.eo.DictItemEntity;
|
||||
import com.adc.da.sys.dao.mysql.DictDao;
|
||||
import com.adc.da.sys.service.iservice.IDictItemService;
|
||||
import com.adc.da.sys.util.BeanCopyUtils;
|
||||
import com.adc.da.sys.vo.DictItemQueryVo;
|
||||
import com.adc.da.sys.vo.DictItemVo;
|
||||
import com.adc.da.util.http.ResponseMessage;
|
||||
import com.adc.da.util.http.Result;
|
||||
import com.adc.da.util.utils.UUID;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import com.adc.da.sys.dao.mysql.DictItemDao;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author ThinkBook
|
||||
* @description 针对表【ts_dict_item】的数据库操作Service实现
|
||||
* @createDate 2023-05-05 10:28:25
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class DictItemServiceImpl extends ServiceImpl<DictItemDao, DictItemEntity>
|
||||
implements IDictItemService {
|
||||
|
||||
@Resource
|
||||
private DictItemDao dictItemDao;
|
||||
|
||||
@Resource
|
||||
private DictDao dictDao;
|
||||
|
||||
@Override
|
||||
public ResponseMessage pageById(DictItemQueryVo dictItemQueryVo) {
|
||||
LambdaQueryWrapper<DictItemEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.like(StrUtil.isNotBlank(dictItemQueryVo.getItemName()), DictItemEntity::getItemName, dictItemQueryVo.getItemName());
|
||||
wrapper.eq(DictItemEntity::getDelFlag, 0);
|
||||
wrapper.eq(DictItemEntity::getTypeId, dictItemQueryVo.getDicId());
|
||||
wrapper.orderByAsc(DictItemEntity::getItemOrder);
|
||||
|
||||
IPage<DictItemEntity> page = new Page<>(dictItemQueryVo.getPageNo(), dictItemQueryVo.getPageSize());
|
||||
page(page, wrapper);
|
||||
|
||||
Page returnPage = BeanCopyUtils.copyBean(page, Page.class);
|
||||
List<DictItemVo> dictItemVos = BeanCopyUtils.copyBeanList(page.getRecords(), DictItemVo.class);
|
||||
|
||||
returnPage.setRecords(dictItemVos);
|
||||
return Result.success(returnPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseMessage edit(DictItemVo dictItemVo) {
|
||||
try {
|
||||
DictItemEntity dictItemEntity = new DictItemEntity();
|
||||
BeanUtil.copyProperties(dictItemVo, dictItemEntity);
|
||||
dictItemDao.updateById(dictItemEntity);
|
||||
log.info("编辑id为{}数据字典值成功", dictItemEntity.getId());
|
||||
return Result.success("编辑成功");
|
||||
} catch (Exception e) {
|
||||
log.info("编辑数据字典值失败", e);
|
||||
}
|
||||
return Result.error("编辑失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseMessage delete(List<String> ids) {
|
||||
List<DictItemEntity> dictEntities = new ArrayList<>();
|
||||
ids.forEach(id -> {
|
||||
DictItemEntity dictEntity = new DictItemEntity();
|
||||
dictEntity.setId(id);
|
||||
dictEntity.setUpdateTime(new Date());
|
||||
dictEntity.setDelFlag(1);
|
||||
dictEntities.add(dictEntity);
|
||||
});
|
||||
updateBatchById(dictEntities);
|
||||
return Result.success("删除成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseMessage add(DictItemVo dictItemVo) {
|
||||
//判断上级字典id是否存在
|
||||
if (StrUtil.isBlank(dictItemVo.getDicId())) {
|
||||
return Result.error("上级字典id无效");
|
||||
}
|
||||
//判断上级字典id是否有效
|
||||
DictEntity dictEntity = dictDao.selectById(dictItemVo.getDicId());
|
||||
if (dictEntity == null) {
|
||||
return Result.error("上级字典id无效");
|
||||
}
|
||||
|
||||
try {
|
||||
DictItemEntity dictItemEntity = BeanCopyUtils.copyBean(dictItemVo, DictItemEntity.class);
|
||||
dictItemEntity.setId(UUID.randomUUID10())
|
||||
.setTypeId(dictItemVo.getDicId())
|
||||
.setCreateTime(new Date())
|
||||
.setUpdateTime(new Date())
|
||||
.setDelFlag(0);
|
||||
|
||||
//求已存在选项排序的最大值
|
||||
LambdaQueryWrapper<DictItemEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(DictItemEntity::getDelFlag, 0);
|
||||
wrapper.eq(DictItemEntity::getTypeId, dictItemVo.getDicId());
|
||||
List<DictItemEntity> dictItemEntities = dictItemDao.selectList(wrapper);
|
||||
Double maxOrder = dictItemEntities.stream().map(DictItemEntity::getItemOrder)
|
||||
.sorted(Comparator.reverseOrder())
|
||||
.collect(Collectors.toList())
|
||||
.stream().findFirst().orElse(null);
|
||||
|
||||
//设置排序值
|
||||
if (dictItemVo.getItemOrder() == null) {
|
||||
//如果目前没有最大值(没有选项)
|
||||
if (maxOrder == null) {
|
||||
dictItemEntity.setItemOrder(1.0);
|
||||
} else {
|
||||
//设置为最后一个
|
||||
dictItemEntity.setItemOrder(1.0 + Math.ceil(maxOrder));
|
||||
}
|
||||
}
|
||||
save(dictItemEntity);
|
||||
return Result.success("新增成功");
|
||||
} catch (Exception e) {
|
||||
log.info("新增选项失败", e);
|
||||
}
|
||||
return Result.error("新增失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseMessage listByPageCode(String dicCode) {
|
||||
LambdaQueryWrapper<DictEntity> dicWrapper = new LambdaQueryWrapper<>();
|
||||
dicWrapper.eq(DictEntity::getDicCode, dicCode);
|
||||
dicWrapper.eq(DictEntity::getDelFlag, 0);
|
||||
DictEntity dictEntity = dictDao.selectOne(dicWrapper);
|
||||
if (dictEntity == null) {
|
||||
return Result.error("此字典编码不存在或已被删除");
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<DictItemEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(DictItemEntity::getDelFlag, 0);
|
||||
wrapper.eq(DictItemEntity::getTypeId, dictEntity.getId());
|
||||
wrapper.orderByAsc(DictItemEntity::getItemOrder);
|
||||
List<DictItemEntity> list = list(wrapper);
|
||||
List<DictItemVo> dictItemVos = BeanCopyUtils.copyBeanList(list, DictItemVo.class);
|
||||
return Result.success(dictItemVos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.adc.da.sys.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.adc.da.eo.DictEntity;
|
||||
import com.adc.da.sys.util.BeanCopyUtils;
|
||||
import com.adc.da.sys.vo.DictQueryVo;
|
||||
import com.adc.da.sys.vo.DictVo;
|
||||
import com.adc.da.util.http.ResponseMessage;
|
||||
import com.adc.da.util.http.Result;
|
||||
import com.adc.da.util.utils.UUID;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.adc.da.sys.service.iservice.IDictService;
|
||||
import com.adc.da.sys.dao.mysql.DictDao;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author ThinkBook
|
||||
* @description 针对表【ts_dict】的数据库操作Service实现
|
||||
* @createDate 2023-05-05 10:28:12
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class DictServiceImpl extends ServiceImpl<DictDao, DictEntity>
|
||||
implements IDictService {
|
||||
|
||||
@Resource
|
||||
private DictDao dictDao;
|
||||
|
||||
@Override
|
||||
public ResponseMessage pageByCondition(DictQueryVo dictQueryVo) {
|
||||
LambdaQueryWrapper<DictEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.like(StrUtil.isNotBlank(dictQueryVo.getDicName()), DictEntity::getDicName, dictQueryVo.getDicName());
|
||||
wrapper.eq(StrUtil.isNotBlank(dictQueryVo.getDicCode()), DictEntity::getDicCode, dictQueryVo.getDicCode());
|
||||
wrapper.eq(DictEntity::getDelFlag, 0);
|
||||
wrapper.orderByAsc(DictEntity::getCreateTime);
|
||||
IPage<DictEntity> page = new Page<>(dictQueryVo.getPageNo(), dictQueryVo.getPageSize());
|
||||
page(page, wrapper);
|
||||
|
||||
Page returnPage = BeanCopyUtils.copyBean(page, Page.class);
|
||||
List<DictVo> dictVos = BeanCopyUtils.copyBeanList(page.getRecords(), DictVo.class);
|
||||
|
||||
returnPage.setRecords(dictVos);
|
||||
return Result.success(returnPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseMessage edit(DictVo dictVo) {
|
||||
try {
|
||||
DictEntity dictEntity = new DictEntity();
|
||||
//字典编码不可变
|
||||
BeanUtil.copyProperties(dictVo, dictEntity);
|
||||
dictEntity.setDicCode(null);
|
||||
dictEntity.setUpdateTime(new Date());
|
||||
dictDao.updateById(dictEntity);
|
||||
log.info("编辑数据字典{}成功", dictEntity.getDicName());
|
||||
return Result.success("编辑成功");
|
||||
} catch (Exception e) {
|
||||
log.info("编辑数据字典失败", e);
|
||||
}
|
||||
return Result.error("编辑失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ResponseMessage delete(List<String> ids) {
|
||||
List<DictEntity> dictEntities = new ArrayList<>();
|
||||
ids.forEach(id -> {
|
||||
DictEntity dictEntity = new DictEntity();
|
||||
dictEntity.setId(id);
|
||||
dictEntity.setUpdateTime(new Date());
|
||||
dictEntity.setDelFlag(1);
|
||||
dictEntities.add(dictEntity);
|
||||
});
|
||||
updateBatchById(dictEntities);
|
||||
return Result.success("删除成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseMessage add(DictVo dictVo) {
|
||||
//判断字典名是否重复
|
||||
Integer dicNameCount = query().eq("dic_name", dictVo.getDicName())
|
||||
.eq("del_flag", 0).count();
|
||||
if (dicNameCount > 0) {
|
||||
return Result.error("字典名重复");
|
||||
}
|
||||
//判断字典编码是否重复
|
||||
Integer dicCodeCount = query().eq("dic_code", dictVo.getDicCode())
|
||||
.eq("del_flag", 0).count();
|
||||
if (dicCodeCount > 0) {
|
||||
return Result.error("字典编码重复");
|
||||
}
|
||||
try {
|
||||
DictEntity dictEntity = BeanCopyUtils.copyBean(dictVo, DictEntity.class);
|
||||
dictEntity.setId(UUID.randomUUID10())
|
||||
.setCreateTime(new Date())
|
||||
.setUpdateTime(new Date())
|
||||
.setDelFlag(0);
|
||||
save(dictEntity);
|
||||
return Result.success("新增成功");
|
||||
} catch (Exception e) {
|
||||
log.info("新增字典失败", e);
|
||||
}
|
||||
return Result.error("新增失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.adc.da.sys.service.iservice;
|
||||
|
||||
import com.adc.da.eo.ConfigEntity;
|
||||
import com.adc.da.sys.vo.ConfigVo;
|
||||
import com.adc.da.util.http.ResponseMessage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author ThinkBook
|
||||
* @description 针对表【ts_config】的数据库操作Service
|
||||
* @createDate 2023-05-04 09:45:30
|
||||
*/
|
||||
public interface IConfigService extends IService<ConfigEntity> {
|
||||
|
||||
/**
|
||||
* 新增或更新配置项
|
||||
*
|
||||
* @param configVo
|
||||
* @return
|
||||
*/
|
||||
ResponseMessage saveOrUpdateConfig(ConfigVo configVo);
|
||||
|
||||
/**
|
||||
* 获取所有配置项
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<ConfigVo> findAllConfig();
|
||||
|
||||
/**
|
||||
* 返回一个配置项
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
ResponseMessage findConfig(String key);
|
||||
|
||||
/**
|
||||
* 返回一个配置项
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
String findConfigValueByKey(String key);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.adc.da.sys.service.iservice;
|
||||
|
||||
import com.adc.da.eo.DictItemEntity;
|
||||
import com.adc.da.sys.vo.DictItemQueryVo;
|
||||
import com.adc.da.sys.vo.DictItemVo;
|
||||
import com.adc.da.util.http.ResponseMessage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author ThinkBook
|
||||
* @description 针对表【ts_dict_item】的数据库操作Service
|
||||
* @createDate 2023-05-05 10:28:25
|
||||
*/
|
||||
public interface IDictItemService extends IService<DictItemEntity> {
|
||||
|
||||
/**
|
||||
* 获取所有字典值
|
||||
* @param dictItemQueryVo
|
||||
* @return
|
||||
*/
|
||||
ResponseMessage pageById(DictItemQueryVo dictItemQueryVo);
|
||||
|
||||
/**
|
||||
* 修改一个字典值
|
||||
* @param dictItemVo
|
||||
* @return
|
||||
*/
|
||||
ResponseMessage edit(DictItemVo dictItemVo);
|
||||
|
||||
/**
|
||||
* 删除一个字典值
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
ResponseMessage delete(List<String> ids);
|
||||
|
||||
/**
|
||||
* 添加一个字典值
|
||||
* @param dictItemVo 字典值视图对象
|
||||
* @return
|
||||
*/
|
||||
ResponseMessage add(DictItemVo dictItemVo);
|
||||
|
||||
/**
|
||||
* 根据字典编码获取所有选项
|
||||
* @param dicCode
|
||||
* @return
|
||||
*/
|
||||
ResponseMessage listByPageCode(String dicCode);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.adc.da.sys.service.iservice;
|
||||
|
||||
|
||||
import com.adc.da.eo.DictEntity;
|
||||
import com.adc.da.sys.vo.DictQueryVo;
|
||||
import com.adc.da.sys.vo.DictVo;
|
||||
import com.adc.da.util.http.ResponseMessage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author ThinkBook
|
||||
* @description 针对表【ts_dict】的数据库操作Service
|
||||
* @createDate 2023-05-05 10:28:12
|
||||
*/
|
||||
public interface IDictService extends IService<DictEntity> {
|
||||
|
||||
/**
|
||||
* 获取字典列表
|
||||
*
|
||||
* @param dictQueryVo
|
||||
* @return
|
||||
*/
|
||||
ResponseMessage pageByCondition(DictQueryVo dictQueryVo);
|
||||
|
||||
/**
|
||||
* 编辑字典
|
||||
*
|
||||
* @param dictVo
|
||||
* @return
|
||||
*/
|
||||
ResponseMessage edit(DictVo dictVo);
|
||||
|
||||
/**
|
||||
* 删除字典
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
ResponseMessage delete(List<String> id);
|
||||
|
||||
/**
|
||||
* 新增字典
|
||||
* @param dictVo
|
||||
* @return
|
||||
*/
|
||||
ResponseMessage add(DictVo dictVo);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.adc.da.sys.util;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Mzaxd
|
||||
* @since 2022-11-22 15:36
|
||||
*/
|
||||
public class BeanCopyUtils {
|
||||
|
||||
private BeanCopyUtils() {
|
||||
}
|
||||
|
||||
public static <V> V copyBean(Object source, Class<V> clazz){
|
||||
V result = null;
|
||||
//创建目标对象
|
||||
try {
|
||||
result = clazz.newInstance();
|
||||
//实现属性copy
|
||||
BeanUtils.copyProperties(source, result);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//返回结果
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <O,V> List<V> copyBeanList(List<O> list, Class<V> clazz) {
|
||||
return list.stream()
|
||||
.map(o -> copyBean(o, clazz))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.adc.da.sys.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author CaiHaohan
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ConfigVo {
|
||||
|
||||
/**
|
||||
* 配置项key
|
||||
*/
|
||||
private String configKey;
|
||||
|
||||
/**
|
||||
* 配置项value
|
||||
*/
|
||||
private String configValue;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.adc.da.sys.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
|
||||
/**
|
||||
* @author CaiHaohan
|
||||
*/
|
||||
@Data
|
||||
public class DictItemQueryVo {
|
||||
|
||||
/**
|
||||
* 上级主键id
|
||||
*/
|
||||
private String dicId;
|
||||
|
||||
/**
|
||||
* 页数
|
||||
*/
|
||||
@Min(1)
|
||||
private Integer pageNo;
|
||||
|
||||
/**
|
||||
* 每页数量
|
||||
*/
|
||||
@NotNull
|
||||
private Integer pageSize;
|
||||
|
||||
/**
|
||||
* 数据名称
|
||||
*/
|
||||
private String itemName;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer itemStatus;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Double itemOrder;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.adc.da.sys.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author CaiHaohan
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DictItemVo {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 上级字典主键id
|
||||
*/
|
||||
private String dicId;
|
||||
|
||||
/**
|
||||
* 数据名称
|
||||
*/
|
||||
private String itemName;
|
||||
|
||||
/**
|
||||
* 数据值
|
||||
*/
|
||||
private String itemValue;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String itemDescription;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Double itemOrder;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.adc.da.sys.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author CaiHaohan
|
||||
*/
|
||||
@Data
|
||||
public class DictQueryVo {
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
private String dicName;
|
||||
|
||||
/**
|
||||
* 字典编码
|
||||
*/
|
||||
private String dicCode;
|
||||
|
||||
/**
|
||||
* 页数
|
||||
*/
|
||||
@Min(1)
|
||||
private int pageNo;
|
||||
|
||||
/**
|
||||
* 每页数量
|
||||
*/
|
||||
@NotNull
|
||||
private int pageSize;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.adc.da.sys.vo;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author CaiHaohan
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DictVo {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
private String dicName;
|
||||
|
||||
/**
|
||||
* 字典编码
|
||||
*/
|
||||
private String dicCode;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user