添加迭代任务;添加字典管理
This commit is contained in:
parent
cbb4a1f62d
commit
eae10871e0
@ -203,4 +203,5 @@ public interface Constants {
|
||||
* 登陆查询用户字段
|
||||
*/
|
||||
String USERNAME = "UserName";
|
||||
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ import java.util.Arrays;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* @author: DB
|
||||
* @author DB
|
||||
* @Date: 2023/08/04/13:48
|
||||
* @Description: 代码生成
|
||||
*/
|
||||
@ -40,17 +40,17 @@ public class CpopGenerator {
|
||||
/**
|
||||
* 输出路径
|
||||
*/
|
||||
private static final String EXPORT_URL = "/Cpop-Mall";
|
||||
private static final String EXPORT_URL = "/Cpop-System";
|
||||
|
||||
/**
|
||||
* 模块
|
||||
*/
|
||||
private static final String EXPORT_ITEM = "mall";
|
||||
private static final String EXPORT_ITEM = "system";
|
||||
|
||||
/**
|
||||
* 表前缀
|
||||
*/
|
||||
private static final String TABLE_PREFIX = "cp_mall_";
|
||||
private static final String TABLE_PREFIX = "cp_sys_";
|
||||
|
||||
/**
|
||||
* 主入口
|
||||
|
||||
@ -6,13 +6,11 @@ import com.cpop.core.base.entity.BaseUpdateListener;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 商城-商品-规格 实体类。
|
||||
*
|
||||
|
||||
@ -83,11 +83,17 @@ knife4j:
|
||||
terms-of-service-url: https://api.jamboxsys.com
|
||||
group:
|
||||
#系统
|
||||
system:
|
||||
Oam:
|
||||
group-name: Oam
|
||||
api-rule: package
|
||||
api-rule-resources:
|
||||
- com.cpop.oam
|
||||
#系统
|
||||
System:
|
||||
group-name: System
|
||||
api-rule: package
|
||||
api-rule-resources:
|
||||
- com.cpop.system
|
||||
|
||||
#微信
|
||||
wx:
|
||||
|
||||
@ -0,0 +1,45 @@
|
||||
package com.cpop.oam.business.bo;
|
||||
|
||||
import com.cpop.core.annontation.StringArrayConvert;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* Task迭代对象
|
||||
* @author DB
|
||||
* @since 2023-12-01 09:43:08
|
||||
* @version 1.0.0
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "Task迭代对象")
|
||||
public class TaskIterationBo {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@ApiModelProperty("主键")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 任务主体
|
||||
*/
|
||||
@NotBlank(message = "任务主体不能为空")
|
||||
@ApiModelProperty(value = "任务主体", required = true)
|
||||
private String subject;
|
||||
|
||||
/**任务内容 */
|
||||
@NotBlank(message = "任务内容不能为空")
|
||||
@ApiModelProperty(value = "任务内容", required = true)
|
||||
private String taskContent;
|
||||
|
||||
/**
|
||||
* 附件地址
|
||||
*/
|
||||
@StringArrayConvert
|
||||
@ApiModelProperty("附件地址")
|
||||
private String attachmentUrl;
|
||||
}
|
||||
@ -0,0 +1,103 @@
|
||||
package com.cpop.oam.business.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 任务归档分页
|
||||
* @author DB
|
||||
* @param
|
||||
* @since 2023-11-30 22:24:49
|
||||
* @version 1.0.0
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "任务归档分页", description = "任务归档分页")
|
||||
public class TaskArchivingPagVo {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@ApiModelProperty("主键")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 主要负责员工id
|
||||
*/
|
||||
@ApiModelProperty("主要负责员工id")
|
||||
private String responsibleStaffId;
|
||||
|
||||
/**
|
||||
* 主键主要负责员工
|
||||
*/
|
||||
@ApiModelProperty("主要负责员工")
|
||||
private String responsibleStaffName;
|
||||
|
||||
/**
|
||||
* 任务类型(0:迭代;1:需求;2:投诉)
|
||||
*/
|
||||
@ApiModelProperty("任务类型(0:迭代;1:需求;2:投诉)")
|
||||
private Integer taskType;
|
||||
|
||||
/**
|
||||
* 任务内容
|
||||
*/
|
||||
@ApiModelProperty("任务内容")
|
||||
private String taskContent;
|
||||
|
||||
/**
|
||||
* 任务评级(0:A;1:B;2:C;3:D;4:E)
|
||||
*/
|
||||
@ApiModelProperty("任务评级(0:A;1:B;2:C;3:D;4:E)")
|
||||
private Integer taskRating;
|
||||
|
||||
/**
|
||||
* 任务绩点
|
||||
*/
|
||||
@ApiModelProperty("任务绩点")
|
||||
private Integer gradePoint;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@ApiModelProperty("开始时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime taskReceiptTime;
|
||||
|
||||
/**
|
||||
* 转测试时间
|
||||
*/
|
||||
@ApiModelProperty("转测试时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime toTestTime;
|
||||
|
||||
/**
|
||||
* 转部署时间
|
||||
*/
|
||||
@ApiModelProperty("转部署时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime toFinishTime;
|
||||
|
||||
/**
|
||||
* 主体
|
||||
*/
|
||||
@ApiModelProperty("主体")
|
||||
private String subject;
|
||||
|
||||
/**
|
||||
* 小组成员
|
||||
*/
|
||||
@ApiModelProperty("小组成员")
|
||||
private String taskGroupStaffs;
|
||||
|
||||
/**
|
||||
* 操作流程
|
||||
*/
|
||||
@ApiModelProperty("操作流程")
|
||||
private String testToFinishUrl;
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
package com.cpop.oam.business.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 任务待评估与待领取分页
|
||||
* @author DB
|
||||
* @since 2023-11-30 22:44:03
|
||||
* @version 1.0.0
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "任务待评估与待领取分页")
|
||||
public class TaskToBeClaimedPageVo {
|
||||
|
||||
/**任务id */
|
||||
@ApiModelProperty(value = "任务id")
|
||||
private String id;
|
||||
|
||||
/**主体 */
|
||||
@ApiModelProperty(value = "主体")
|
||||
private String subject;
|
||||
|
||||
/**任务内容 */
|
||||
@ApiModelProperty(value = "任务内容")
|
||||
private String taskContent;
|
||||
|
||||
/**附件地址 */
|
||||
@ApiModelProperty(value = "附件地址")
|
||||
private String attachmentUrl;
|
||||
|
||||
/**任务评级(0:A;1:B;2:C;3:D;4:E) */
|
||||
@ApiModelProperty(value = "任务评级(0:A;1:B;2:C;3:D;4:E)")
|
||||
private Integer taskRating;
|
||||
|
||||
/**任务类型(0:迭代;1:需求;2:投诉/工单) */
|
||||
@ApiModelProperty(value = "任务类型(0:迭代;1:需求;2:投诉/工单)")
|
||||
private Integer taskType;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@ApiModelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**对接员工 */
|
||||
@ApiModelProperty(value = "对接员工")
|
||||
private String dockingStaff;
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
package com.cpop.oam.business.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "个人工单返回对象", description = "个人工单返回对象对象")
|
||||
public class TaskWorkOrderPersonVo {
|
||||
|
||||
/**
|
||||
* 工单id
|
||||
*/
|
||||
@ApiModelProperty(value = "工单id")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 机构/品牌
|
||||
*/
|
||||
@ApiModelProperty(value = "机构/品牌")
|
||||
private String brandName;
|
||||
|
||||
/**
|
||||
* 校区/店铺
|
||||
*/
|
||||
@ApiModelProperty(value = "校区/店铺")
|
||||
private String storeName;
|
||||
|
||||
/**
|
||||
* 问题描述
|
||||
*/
|
||||
@ApiModelProperty(value = "问题描述")
|
||||
private String taskContent;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String phoneNumber;
|
||||
|
||||
/**
|
||||
* 提交人ID
|
||||
*/
|
||||
@ApiModelProperty(value = "提交人ID")
|
||||
private String recordStaffId;
|
||||
|
||||
/**
|
||||
* 提交人
|
||||
*/
|
||||
@ApiModelProperty(value = "提交人")
|
||||
private String recordStaffName;
|
||||
|
||||
/**
|
||||
* 提交时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@ApiModelProperty(value = "提交时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 接收用时
|
||||
*/
|
||||
@ApiModelProperty(value = "接收用时")
|
||||
private Integer receivingTime;
|
||||
|
||||
/**
|
||||
* 工单状态
|
||||
*/
|
||||
@ApiModelProperty(value = "工单状态")
|
||||
private Integer workOrderStatus;
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
package com.cpop.system.business.bo;
|
||||
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @author DB
|
||||
* @version 1.0.0
|
||||
* @since 2023-12-01 17:04
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "字典数据参数")
|
||||
public class DictDataBo {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@ApiModelProperty("id")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@NotNull(message = "排序不能为空")
|
||||
@ApiModelProperty(value = "排序",required = true)
|
||||
private Integer dictSort;
|
||||
|
||||
/**
|
||||
* 字典标签
|
||||
*/
|
||||
@NotBlank(message = "字典标签不能为空")
|
||||
@ApiModelProperty(value = "字典标签",required = true)
|
||||
private String dictLabel;
|
||||
|
||||
/**
|
||||
* 字典键值
|
||||
*/
|
||||
@NotBlank(message = "字典键值不能为空")
|
||||
@ApiModelProperty(value = "字典键值",required = true)
|
||||
private String dictValue;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
@NotBlank(message = "字典类型不能为空")
|
||||
@ApiModelProperty(value = "字典类型",required = true)
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 样式属性(其他样式扩展)
|
||||
*/
|
||||
@ApiModelProperty("样式属性(其他样式扩展)")
|
||||
private String cssClass;
|
||||
|
||||
/**
|
||||
* 表格回显样式
|
||||
*/
|
||||
@ApiModelProperty("表格回显样式")
|
||||
private String listClass;
|
||||
|
||||
/**
|
||||
* 是否默认(1是 0否)
|
||||
*/
|
||||
@ApiModelProperty("是否默认(1是 0否)")
|
||||
private Boolean isDefault;
|
||||
|
||||
/**
|
||||
* 状态(1正常 0停用)
|
||||
*/
|
||||
@NotNull(message = "状态不能为空")
|
||||
@ApiModelProperty(value = "状态(1正常 0停用)",required = true)
|
||||
private Boolean status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ApiModelProperty("备注")
|
||||
private String remark;
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package com.cpop.system.business.bo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 字典数据分页参数
|
||||
* @author DB
|
||||
* @version 1.0.0
|
||||
* @since 2023-12-01 16:28
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "字典数据分页参数")
|
||||
public class DictDataPageBo {
|
||||
|
||||
/**
|
||||
* 字典标签
|
||||
*/
|
||||
@ApiModelProperty("字典标签")
|
||||
private String dictLabel;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
@ApiModelProperty("字典类型")
|
||||
private String dictType;
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
package com.cpop.system.business.bo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 字典类型参数
|
||||
* @version 1.0.0
|
||||
* @author DB
|
||||
* @since 2023-12-01 15:15
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "字典类型参数")
|
||||
public class DictTypeBo {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@ApiModelProperty(value = "主键")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 字典名
|
||||
*/
|
||||
@NotBlank(message = "字典名不能为空")
|
||||
@ApiModelProperty(value = "字典名",required = true)
|
||||
private String dictName;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
@NotBlank(message = "字典类型不能为空")
|
||||
@ApiModelProperty(value = "字典类型",required = true)
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 状态(0正常 1停用)
|
||||
*/
|
||||
@NotNull(message = "状态不能为空")
|
||||
@ApiModelProperty(value = "状态(0正常 1停用)",required = true)
|
||||
private Boolean status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
}
|
||||
@ -0,0 +1,131 @@
|
||||
package com.cpop.system.business.controller;
|
||||
|
||||
import com.cpop.common.utils.bean.BeanUtils;
|
||||
import com.cpop.core.base.R;
|
||||
import com.cpop.core.utils.SpringUtils;
|
||||
import com.cpop.system.business.bo.DictDataBo;
|
||||
import com.cpop.system.business.bo.DictDataPageBo;
|
||||
import com.cpop.system.business.entity.DictType;
|
||||
import com.cpop.system.business.service.DictTypeService;
|
||||
import com.cpop.system.business.vo.DictDataListVo;
|
||||
import com.cpop.system.business.vo.DictDataPageVo;
|
||||
import com.cpop.system.business.vo.DictDataVo;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.cpop.system.business.entity.DictData;
|
||||
import com.cpop.system.business.service.DictDataService;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统-字典数据表 控制层。
|
||||
*
|
||||
* @author DB
|
||||
* @since 2023-12-01
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "系统-字典数据表接口")
|
||||
@RequestMapping("/dictData")
|
||||
public class DictDataController {
|
||||
|
||||
@Autowired
|
||||
private DictDataService dictDataService;
|
||||
|
||||
/**
|
||||
* 获取字典数据分页
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
* @param bo 请求参数
|
||||
* @return R<Page<DictData>>
|
||||
*/
|
||||
@GetMapping("/getDictDataPage")
|
||||
@ApiOperation("获取字典数据分页")
|
||||
public R<Page<DictDataPageVo>> getDictDataPage(@ApiParam("查询参数") DictDataPageBo bo) {
|
||||
Page<DictDataPageVo> page = dictDataService.getDictDataPage(bo);
|
||||
return R.ok(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据主键获取字典数据详情
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
* @param id 字典数据主键
|
||||
* @return DictData
|
||||
*/
|
||||
@GetMapping("/getDictDataInfo/{id}")
|
||||
@ApiOperation("根据主键获取字典数据详情")
|
||||
public R<DictDataVo> getDictDataInfo(@PathVariable @ApiParam("字典数据code") String id) {
|
||||
DictDataVo vo = dictDataService.getDictDataInfo(id);
|
||||
return R.ok(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型获取字典数据
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
* @param dictType 字典类型
|
||||
* @return R<DictDataVo>
|
||||
*/
|
||||
@GetMapping("/getDictDataByDictType/{dictType}")
|
||||
@ApiOperation("根据字典类型获取字典数据")
|
||||
public R<List<DictDataListVo>> getDictDataByDictType(@PathVariable @ApiParam("字典数据code") String dictType) {
|
||||
List<DictData> dataList = dictDataService.getDictDataByDictType(dictType);
|
||||
return R.ok(BeanUtils.mapToList(dataList, DictDataListVo.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增字典数据
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
* @param bo 请求参数
|
||||
* @return R<Void>
|
||||
*/
|
||||
@PostMapping("/insertDictData")
|
||||
@ApiOperation("新增字典数据")
|
||||
public R<Void> insertDictData(@RequestBody @ApiParam("字典数据") @Validated DictDataBo bo) {
|
||||
dictDataService.insertDictData(bo);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典数据
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
* @param bo 请求
|
||||
* @return R<Void>
|
||||
*/
|
||||
@PutMapping("/updateDictData")
|
||||
@ApiOperation("修改字典数据")
|
||||
public R<Void> updateDictData(@RequestBody @ApiParam("字典数据") @Validated DictDataBo bo) {
|
||||
dictDataService.updateDictData(bo);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典数据
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
* @param id 主键
|
||||
* @return R<Void>
|
||||
*/
|
||||
@DeleteMapping("/removeDictData/{id}")
|
||||
@ApiOperation("删除字典数据")
|
||||
public R<Void> removeDictData(@PathVariable String id) {
|
||||
dictDataService.removeDictData(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,161 @@
|
||||
package com.cpop.system.business.controller;
|
||||
|
||||
import com.cpop.common.utils.bean.BeanUtils;
|
||||
import com.cpop.core.base.R;
|
||||
import com.cpop.core.base.entity.LoginUser;
|
||||
import com.cpop.core.base.exception.ServiceException;
|
||||
import com.cpop.core.utils.SecurityUtils;
|
||||
import com.cpop.system.business.bo.DictTypeBo;
|
||||
import com.cpop.system.business.vo.DictTypePageVo;
|
||||
import com.cpop.system.business.vo.DictTypeVo;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import lombok.extern.java.Log;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.cpop.system.business.entity.DictType;
|
||||
import com.cpop.system.business.service.DictTypeService;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import static com.cpop.system.business.entity.table.DictTypeTableDef.DICT_TYPE;
|
||||
|
||||
/**
|
||||
* 系统-字典类型表 控制层。
|
||||
*
|
||||
* @author DB
|
||||
* @since 2023-12-01
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "系统管理模块-字典类型接口")
|
||||
@RequestMapping("/dictType")
|
||||
public class DictTypeController {
|
||||
|
||||
@Autowired
|
||||
private DictTypeService dictTypeService;
|
||||
|
||||
/**
|
||||
* 获取系统字典类型分页
|
||||
*
|
||||
* @param dictName 字典名
|
||||
* @return R<Page < DictTypePageVo>>
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
*/
|
||||
@GetMapping("/getDictTypePage")
|
||||
@ApiOperation("获取系统字典类型分页")
|
||||
public R<Page<DictTypePageVo>> getDictTypePage(@ApiParam(value = "字典名") String dictName) {
|
||||
Page<DictTypePageVo> page = dictTypeService.getDictTypePage(dictName);
|
||||
return R.ok(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据主键获取字典类型详情
|
||||
*
|
||||
* @param id 字典类型主键
|
||||
* @return R<DictTypeVo>
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
*/
|
||||
@GetMapping("/getDictTypeInfo/{id}")
|
||||
@ApiOperation("根据主键获取字典类型详情")
|
||||
public R<DictTypeVo> getDictTypeInfo(@PathVariable @ApiParam("字典类型主键") String id) {
|
||||
DictTypeVo dictType = dictTypeService.getOneAs(QueryWrapper.create().where(DICT_TYPE.ID.eq(id)), DictTypeVo.class);
|
||||
return R.ok(dictType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增字典类型
|
||||
*
|
||||
* @param bo 请求参数
|
||||
* @return R<Void>
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
*/
|
||||
@PostMapping("/insertDictType")
|
||||
@ApiOperation("新增字典类型")
|
||||
public R<Void> insertDictType(@Validated @RequestBody DictTypeBo bo) {
|
||||
if (!dictTypeService.checkDictTypeUnique(bo)) {
|
||||
throw new ServiceException("新增字典'" + bo.getDictName() + "'失败,字典类型已存在");
|
||||
}
|
||||
dictTypeService.save(BeanUtils.mapToClass(bo, DictType.class));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典类型
|
||||
*
|
||||
* @param bo 请求
|
||||
* @return R<Void>
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
*/
|
||||
@PutMapping("/updateDictType")
|
||||
@ApiOperation("修改字典类型")
|
||||
public R<Void> updateDictType(@Validated @RequestBody DictTypeBo bo) {
|
||||
if (!dictTypeService.checkDictTypeUnique(bo)) {
|
||||
throw new ServiceException("修改字典'" + bo.getDictName() + "'失败,字典类型已存在");
|
||||
}
|
||||
dictTypeService.updateById(BeanUtils.mapToClass(bo, DictType.class));
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据主键删除字典类型
|
||||
*
|
||||
* @param id 主键
|
||||
* @return R<Void>
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
*/
|
||||
@DeleteMapping("/removeById/{id}")
|
||||
@ApiOperation("根据主键删除字典类型")
|
||||
public R<Void> removeById(@PathVariable @ApiParam("字典类型主键") String id) {
|
||||
dictTypeService.removeDataAndCache(id);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新字典缓存
|
||||
*
|
||||
* @return R<Void>
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
*/
|
||||
@ApiOperation("刷新字典缓存")
|
||||
@PutMapping("/refreshCache")
|
||||
public R<Void> refreshCache() {
|
||||
dictTypeService.resetDictCache();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典选择框列表
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
* @return R<List<DictTypeVo>>
|
||||
*/
|
||||
@ApiOperation("获取字典选择框列表")
|
||||
@GetMapping("/optionSelect")
|
||||
public R<List<DictTypeVo>> optionSelect() {
|
||||
LoginUser loginUser = SecurityUtils.getInstance().getLoginUser();
|
||||
List<DictTypeVo> dictTypes = dictTypeService.queryChain()
|
||||
.where(DICT_TYPE.USER_TYPE.eq(loginUser.getUserType().toString()))
|
||||
.listAs(DictTypeVo.class);
|
||||
return R.ok(dictTypes);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
package com.cpop.system.business.entity;
|
||||
|
||||
import com.cpop.core.base.entity.BaseEntity;
|
||||
import com.cpop.core.base.entity.BaseInsertListener;
|
||||
import com.cpop.core.base.entity.BaseUpdateListener;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 系统-字典数据表 实体类。
|
||||
*
|
||||
* @author DB
|
||||
* @since 2023-12-01
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@Table(value = "cp_sys_dict_data", onInsert = BaseInsertListener.class, onUpdate = BaseUpdateListener.class, mapperGenerateEnable = false)
|
||||
public class DictData extends BaseEntity implements Serializable {
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer dictSort;
|
||||
|
||||
/**
|
||||
* 字典标签
|
||||
*/
|
||||
private String dictLabel;
|
||||
|
||||
/**
|
||||
* 字典键值
|
||||
*/
|
||||
private String dictValue;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 样式属性(其他样式扩展)
|
||||
*/
|
||||
private String cssClass;
|
||||
|
||||
/**
|
||||
* 表格回显样式
|
||||
*/
|
||||
private String listClass;
|
||||
|
||||
/**
|
||||
* 是否默认(1是 0否)
|
||||
*/
|
||||
private Boolean isDefault;
|
||||
|
||||
/**
|
||||
* 状态(1正常 0停用)
|
||||
*/
|
||||
private Boolean status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 用户类型
|
||||
*/
|
||||
private String userType;
|
||||
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
package com.cpop.system.business.entity;
|
||||
|
||||
import com.cpop.core.base.entity.BaseEntity;
|
||||
import com.cpop.core.base.entity.BaseInsertListener;
|
||||
import com.cpop.core.base.entity.BaseUpdateListener;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 系统-字典表 实体类。
|
||||
*
|
||||
* @author DB
|
||||
* @since 2023-12-01
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@Table(value = "cp_sys_dict_type", onInsert = BaseInsertListener.class, onUpdate = BaseUpdateListener.class, mapperGenerateEnable = false)
|
||||
public class DictType extends BaseEntity implements Serializable {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 字典名
|
||||
*/
|
||||
private String dictName;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 状态(0正常 1停用)
|
||||
*/
|
||||
private Boolean status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 用户类型
|
||||
*/
|
||||
private String userType;
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.cpop.system.business.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.cpop.system.business.entity.DictData;
|
||||
|
||||
/**
|
||||
* 系统-字典数据表 映射层。
|
||||
*
|
||||
* @author DB
|
||||
* @since 2023-12-01
|
||||
*/
|
||||
public interface DictDataMapper extends BaseMapper<DictData> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.cpop.system.business.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.cpop.system.business.entity.DictType;
|
||||
|
||||
/**
|
||||
* 系统-字典表 映射层。
|
||||
*
|
||||
* @author DB
|
||||
* @since 2023-12-01
|
||||
*/
|
||||
public interface DictTypeMapper extends BaseMapper<DictType> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,72 @@
|
||||
package com.cpop.system.business.service;
|
||||
|
||||
import com.cpop.system.business.bo.DictDataBo;
|
||||
import com.cpop.system.business.bo.DictDataPageBo;
|
||||
import com.cpop.system.business.vo.DictDataListVo;
|
||||
import com.cpop.system.business.vo.DictDataPageVo;
|
||||
import com.cpop.system.business.vo.DictDataVo;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.cpop.system.business.entity.DictData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统-字典数据表 服务层。
|
||||
*
|
||||
* @author DB
|
||||
* @since 2023-12-01
|
||||
*/
|
||||
public interface DictDataService extends IService<DictData> {
|
||||
|
||||
/**
|
||||
* 获取字典数据分页
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
* @param bo 请求参数
|
||||
* @return Page<DictDataPageVo>
|
||||
*/
|
||||
Page<DictDataPageVo> getDictDataPage(DictDataPageBo bo);
|
||||
|
||||
/**
|
||||
* 根据主键获取字典数据详情
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
* @param id 主键
|
||||
* @return DictDataVo
|
||||
*/
|
||||
DictDataVo getDictDataInfo(String id);
|
||||
|
||||
/**
|
||||
* 根据字典类型获取字典数据
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
* @param dictType 字典类型
|
||||
* @return List<DictDataVo>
|
||||
*/
|
||||
List<DictData> getDictDataByDictType(String dictType);
|
||||
|
||||
/**
|
||||
* 新增字典数据
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
* @param bo 请求参数
|
||||
*/
|
||||
void insertDictData(DictDataBo bo);
|
||||
|
||||
/**
|
||||
* 修改字典数据
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
* @param bo 请求
|
||||
*/
|
||||
void updateDictData(DictDataBo bo);
|
||||
|
||||
/**
|
||||
* 删除字典数据
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
* @param id 主键
|
||||
*/
|
||||
void removeDictData(String id);
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
package com.cpop.system.business.service;
|
||||
|
||||
import com.cpop.core.base.R;
|
||||
import com.cpop.system.business.bo.DictTypeBo;
|
||||
import com.cpop.system.business.vo.DictTypePageVo;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.cpop.system.business.entity.DictType;
|
||||
|
||||
/**
|
||||
* 系统-字典表 服务层。
|
||||
*
|
||||
* @author DB
|
||||
* @since 2023-12-01
|
||||
*/
|
||||
public interface DictTypeService extends IService<DictType> {
|
||||
|
||||
/**
|
||||
* 获取系统字典类型分页
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
* @param dictName 字典名
|
||||
* @return R<Page<DictTypePageVo>>
|
||||
*/
|
||||
Page<DictTypePageVo> getDictTypePage(String dictName);
|
||||
|
||||
/**
|
||||
* 查询系统类型是否存在
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
* @param bo 请求参数
|
||||
* @return boolean
|
||||
*/
|
||||
Boolean checkDictTypeUnique(DictTypeBo bo);
|
||||
|
||||
/**
|
||||
* 根据主键删除字典类型
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
* @param id 主键
|
||||
*/
|
||||
void removeDataAndCache(String id);
|
||||
|
||||
/**
|
||||
* 重设字典
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
*/
|
||||
void resetDictCache();
|
||||
|
||||
/**
|
||||
* 清除字典缓存
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
*/
|
||||
void clearDictCache();
|
||||
|
||||
/**
|
||||
* 加载字典缓存
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
*/
|
||||
void loadingDictCache();
|
||||
}
|
||||
@ -0,0 +1,148 @@
|
||||
package com.cpop.system.business.service.impl;
|
||||
|
||||
import com.cpop.common.utils.StringUtils;
|
||||
import com.cpop.common.utils.bean.BeanUtils;
|
||||
import com.cpop.core.base.entity.LoginUser;
|
||||
import com.cpop.core.base.entity.PageDomain;
|
||||
import com.cpop.core.utils.SecurityUtils;
|
||||
import com.cpop.core.utils.SpringUtils;
|
||||
import com.cpop.core.utils.sql.SqlUtils;
|
||||
import com.cpop.system.business.bo.DictDataBo;
|
||||
import com.cpop.system.business.bo.DictDataPageBo;
|
||||
import com.cpop.system.business.vo.DictDataListVo;
|
||||
import com.cpop.system.business.vo.DictDataPageVo;
|
||||
import com.cpop.system.business.vo.DictDataVo;
|
||||
import com.cpop.system.framework.utils.DictUtils;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.cpop.system.business.entity.DictData;
|
||||
import com.cpop.system.business.mapper.DictDataMapper;
|
||||
import com.cpop.system.business.service.DictDataService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.cpop.system.business.entity.table.DictDataTableDef.DICT_DATA;
|
||||
|
||||
/**
|
||||
* 系统-字典数据表 服务层实现。
|
||||
*
|
||||
* @author DB
|
||||
* @since 2023-12-01
|
||||
*/
|
||||
@Service("dictDataService")
|
||||
public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> implements DictDataService {
|
||||
|
||||
/**
|
||||
* 获取字典数据分页
|
||||
*
|
||||
* @param bo 请求参数
|
||||
* @return Page<DictDataPageVo>
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
*/
|
||||
@Override
|
||||
public Page<DictDataPageVo> getDictDataPage(DictDataPageBo bo) {
|
||||
LoginUser loginUser = SecurityUtils.getInstance().getLoginUser();
|
||||
PageDomain pageDomain = SqlUtils.getInstance().getPageDomain();
|
||||
return this.pageAs(Page.of(pageDomain.getPageNum(), pageDomain.getPageSize()),
|
||||
QueryWrapper.create()
|
||||
.select(DICT_DATA.ID, DICT_DATA.DICT_LABEL, DICT_DATA.DICT_VALUE, DICT_DATA.DICT_TYPE, DICT_DATA.UPDATE_TIME)
|
||||
.where(DICT_DATA.USER_TYPE.eq(loginUser.getUserType().toString()))
|
||||
.and(DICT_DATA.DICT_TYPE.eq(bo.getDictType()))
|
||||
.and(DICT_DATA.DICT_LABEL.like(bo.getDictLabel()))
|
||||
.orderBy(DICT_DATA.DICT_SORT.asc()),
|
||||
DictDataPageVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据主键获取字典数据详情
|
||||
*
|
||||
* @param id 主键
|
||||
* @return DictDataVo
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
*/
|
||||
@Override
|
||||
public DictDataVo getDictDataInfo(String id) {
|
||||
return BeanUtils.mapToClass(this.getById(id), DictDataVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型获取字典数据
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return List<DictDataVo>
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
*/
|
||||
@Override
|
||||
public List<DictData> getDictDataByDictType(String dictType) {
|
||||
List<DictData> dictCache = DictUtils.getDictCache(dictType);
|
||||
if (dictCache != null && !dictCache.isEmpty()) {
|
||||
return dictCache;
|
||||
}
|
||||
//获取当前用户信息
|
||||
LoginUser loginUser = SecurityUtils.getInstance().getLoginUser();
|
||||
dictCache = this.list(QueryWrapper.create().select(DICT_DATA.ALL_COLUMNS)
|
||||
.where(DICT_DATA.STATUS.eq(1))
|
||||
.and(DICT_DATA.DICT_TYPE.eq(dictType))
|
||||
.and(DICT_DATA.USER_TYPE.eq(loginUser.getUserType().toString()))
|
||||
.orderBy(DICT_DATA.DICT_SORT.asc()));
|
||||
if (StringUtils.isNotEmpty(dictCache)) {
|
||||
DictUtils.setDictCache(dictType, dictCache);
|
||||
return dictCache;
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增字典数据
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
* @param bo 请求参数
|
||||
*/
|
||||
@Override
|
||||
public void insertDictData(DictDataBo bo) {
|
||||
DictData dictData = BeanUtils.mapToClass(bo, DictData.class);
|
||||
LoginUser loginUser = SecurityUtils.getInstance().getLoginUser();
|
||||
dictData.setUserType(loginUser.getUserType().toString());
|
||||
boolean save = this.save(dictData);
|
||||
if (save) {
|
||||
List<DictData> dictDatas = getDictDataByDictType(dictData.getDictType());
|
||||
DictUtils.setDictCache(dictData.getDictType(), dictDatas);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改字典数据
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
* @param bo 请求
|
||||
*/
|
||||
@Override
|
||||
public void updateDictData(DictDataBo bo) {
|
||||
DictData dictData = BeanUtils.mapToClass(bo, DictData.class);
|
||||
boolean save = this.updateById(dictData);
|
||||
if (save) {
|
||||
List<DictData> dictDatas = getDictDataByDictType(dictData.getDictType());
|
||||
DictUtils.setDictCache(dictData.getDictType(), dictDatas);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除字典数据
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
* @param id 主键
|
||||
*/
|
||||
@Override
|
||||
public void removeDictData(String id) {
|
||||
DictDataVo data = getDictDataInfo(id);
|
||||
this.removeById(id);
|
||||
List<DictData> dictDatas = getDictDataByDictType(data.getDictType());
|
||||
DictUtils.setDictCache(data.getDictType(), dictDatas);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,133 @@
|
||||
package com.cpop.system.business.service.impl;
|
||||
|
||||
import com.cpop.common.utils.StringUtils;
|
||||
import com.cpop.core.base.entity.LoginUser;
|
||||
import com.cpop.core.base.entity.PageDomain;
|
||||
import com.cpop.core.base.exception.ServiceException;
|
||||
import com.cpop.core.utils.SecurityUtils;
|
||||
import com.cpop.core.utils.SpringUtils;
|
||||
import com.cpop.core.utils.sql.SqlUtils;
|
||||
import com.cpop.system.business.bo.DictTypeBo;
|
||||
import com.cpop.system.business.entity.DictData;
|
||||
import com.cpop.system.business.service.DictDataService;
|
||||
import com.cpop.system.business.vo.DictTypePageVo;
|
||||
import com.cpop.system.framework.utils.DictUtils;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.cpop.system.business.entity.DictType;
|
||||
import com.cpop.system.business.mapper.DictTypeMapper;
|
||||
import com.cpop.system.business.service.DictTypeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.cpop.system.business.entity.table.DictDataTableDef.DICT_DATA;
|
||||
import static com.cpop.system.business.entity.table.DictTypeTableDef.DICT_TYPE;
|
||||
|
||||
/**
|
||||
* 系统-字典表 服务层实现。
|
||||
*
|
||||
* @author DB
|
||||
* @since 2023-12-01
|
||||
*/
|
||||
@Service("dictTypeService")
|
||||
public class DictTypeServiceImpl extends ServiceImpl<DictTypeMapper, DictType> implements DictTypeService {
|
||||
|
||||
/**
|
||||
* 获取系统字典类型分页
|
||||
*
|
||||
* @param dictName 字典名
|
||||
* @return R<Page < DictTypePageVo>>
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
*/
|
||||
@Override
|
||||
public Page<DictTypePageVo> getDictTypePage(String dictName) {
|
||||
//获取分页参数
|
||||
PageDomain pageDomain = SqlUtils.getInstance().getPageDomain();
|
||||
//获取当前登陆用户类型
|
||||
LoginUser loginUser = SecurityUtils.getInstance().getLoginUser();
|
||||
return this.pageAs(Page.of(pageDomain.getPageNum(), pageDomain.getPageSize()),
|
||||
QueryWrapper.create().select(DICT_TYPE.ID, DICT_TYPE.DICT_NAME, DICT_TYPE.DICT_TYPE_, DICT_TYPE.UPDATE_TIME)
|
||||
.where(DICT_TYPE.USER_TYPE.eq(loginUser.getUserType().toString()))
|
||||
.and(DICT_TYPE.DICT_NAME.like(dictName)),
|
||||
DictTypePageVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询系统类型是否存在
|
||||
*
|
||||
* @param bo 请求参数
|
||||
* @return boolean
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
*/
|
||||
@Override
|
||||
public Boolean checkDictTypeUnique(DictTypeBo bo) {
|
||||
String dictId = StringUtils.isNotBlank(bo.getId()) ? bo.getId() : "-1";
|
||||
LoginUser loginUser = SecurityUtils.getInstance().getLoginUser();
|
||||
DictType dictType = this.getOne(QueryWrapper.create()
|
||||
.where(DICT_TYPE.DICT_TYPE_.eq(bo.getDictType()))
|
||||
.and(DICT_TYPE.USER_TYPE.eq(loginUser.getUserType().toString())));
|
||||
return dictType == null || StringUtils.equals(dictId, dictType.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据主键删除字典类型
|
||||
*
|
||||
* @param id 主键
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
*/
|
||||
@Override
|
||||
public void removeDataAndCache(String id) {
|
||||
//查询数据
|
||||
DictType dictType = this.getById(id);
|
||||
//查询字典数据
|
||||
if (SpringUtils.getBean(DictDataService.class).count(QueryWrapper.create().where(DICT_DATA.DICT_TYPE.eq(dictType.getDictType()))) > 0) {
|
||||
throw new ServiceException(String.format("%1$s已分配,不能删除", dictType.getDictName()));
|
||||
}
|
||||
this.removeById(id);
|
||||
//删除缓存
|
||||
DictUtils.removeDictCache(dictType.getDictType());
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置字典缓存数据
|
||||
*/
|
||||
@Override
|
||||
public void resetDictCache() {
|
||||
clearDictCache();
|
||||
loadingDictCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空字典缓存数据
|
||||
*/
|
||||
@Override
|
||||
public void clearDictCache() {
|
||||
DictUtils.clearDictCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载字典缓存
|
||||
*
|
||||
* @author DB
|
||||
* @since 2023/12/01
|
||||
*/
|
||||
@Override
|
||||
public void loadingDictCache() {
|
||||
DictData dictData = new DictData();
|
||||
dictData.setStatus(false);
|
||||
Map<String, List<DictData>> dictDataMap = SpringUtils.getBean(DictDataService.class)
|
||||
.list(QueryWrapper.create().orderBy(DICT_DATA.DICT_SORT.asc()))
|
||||
.stream().collect(Collectors.groupingBy(DictData::getDictType));
|
||||
for (Map.Entry<String, List<DictData>> entry : dictDataMap.entrySet()) {
|
||||
DictUtils.setDictCache(entry.getKey(), entry.getValue().stream().sorted(Comparator.comparing(DictData::getDictSort)).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
package com.cpop.system.business.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author DB
|
||||
* @version 1.0.0
|
||||
* @since 2023-12-01 16:58
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "字典数据返回对象")
|
||||
public class DictDataListVo {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@ApiModelProperty(value = "id")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 字典标签
|
||||
*/
|
||||
@ApiModelProperty(value = "字典标签")
|
||||
private String dictLabel;
|
||||
|
||||
/**
|
||||
* 字典值
|
||||
*/
|
||||
@ApiModelProperty(value = "字典值")
|
||||
private String dictValue;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
@ApiModelProperty(value = "字典类型")
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@ApiModelProperty(value = "排序")
|
||||
private String dictSort;
|
||||
|
||||
/**
|
||||
* 样式属性(其他样式扩展)
|
||||
*/
|
||||
@ApiModelProperty(value = "样式属性(其他样式扩展)")
|
||||
private String cssClass;
|
||||
|
||||
/**
|
||||
* 表格回显样式
|
||||
*/
|
||||
@ApiModelProperty(value = "表格回显样式")
|
||||
private String listClass;
|
||||
|
||||
/**
|
||||
* 是否默认(1是 0否)
|
||||
*/
|
||||
@ApiModelProperty(value = "是否默认(1是 0否)")
|
||||
private Boolean isDefault;
|
||||
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package com.cpop.system.business.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 字典数据分页
|
||||
* @author DB
|
||||
* @version 1.0.0
|
||||
* @since 2023-12-01 16:30
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "字典数据分页")
|
||||
public class DictDataPageVo {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@ApiModelProperty(value = "id")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 字典标签
|
||||
*/
|
||||
@ApiModelProperty(value = "字典标签")
|
||||
private String dictLabel;
|
||||
|
||||
/**
|
||||
* 字典值
|
||||
*/
|
||||
@ApiModelProperty(value = "字典值")
|
||||
private String dictValue;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
@ApiModelProperty(value = "字典类型")
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
@ -0,0 +1,77 @@
|
||||
package com.cpop.system.business.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author DB
|
||||
* @version 1.0.0
|
||||
* @since 2023-12-01 16:42
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "品牌分页返回参数")
|
||||
public class DictDataVo {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@ApiModelProperty(value = "id")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 字典标签
|
||||
*/
|
||||
@ApiModelProperty(value = "字典标签")
|
||||
private String dictLabel;
|
||||
|
||||
/**
|
||||
* 字典值
|
||||
*/
|
||||
@ApiModelProperty(value = "字典值")
|
||||
private String dictValue;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
@ApiModelProperty(value = "字典类型")
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@ApiModelProperty(value = "排序")
|
||||
private String dictSort;
|
||||
|
||||
/**
|
||||
* 样式属性(其他样式扩展)
|
||||
*/
|
||||
@ApiModelProperty(value = "样式属性(其他样式扩展)")
|
||||
private String cssClass;
|
||||
|
||||
/**
|
||||
* 表格回显样式
|
||||
*/
|
||||
@ApiModelProperty(value = "表格回显样式")
|
||||
private String listClass;
|
||||
|
||||
/**
|
||||
* 是否默认(1是 0否)
|
||||
*/
|
||||
@ApiModelProperty(value = "是否默认(1是 0否)")
|
||||
private Boolean isDefault;
|
||||
|
||||
/**
|
||||
* 状态(1正常 0停用)
|
||||
*/
|
||||
@ApiModelProperty(value = "状态(1正常 0停用)")
|
||||
private Boolean status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
package com.cpop.system.business.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.joda.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 字典类型分页
|
||||
* @version 1.0.0
|
||||
* @author DB
|
||||
* @since 2023-12-01 15:15
|
||||
*/
|
||||
@Data
|
||||
@ApiModel(value = "品牌参数")
|
||||
public class DictTypePageVo {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@ApiModelProperty(value = "主键")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 字典名
|
||||
*/
|
||||
@ApiModelProperty(value = "字典名")
|
||||
private String dictName;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
@ApiModelProperty(value = "字典类型")
|
||||
private String dictType;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
package com.cpop.system.business.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.joda.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 字典类型参数
|
||||
* @version 1.0.0
|
||||
* @author DB
|
||||
* @since 2023-12-01 15:15
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "字典类型参数")
|
||||
public class DictTypeVo {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@ApiModelProperty(value = "主键")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 字典名
|
||||
*/
|
||||
@ApiModelProperty(value = "字典名")
|
||||
private String dickName;
|
||||
|
||||
/**
|
||||
* 字典类型
|
||||
*/
|
||||
@ApiModelProperty(value = "字典类型")
|
||||
private String dickType;
|
||||
|
||||
/**
|
||||
* 状态(0正常 1停用)
|
||||
*/
|
||||
@ApiModelProperty(value = "状态(0正常 1停用)")
|
||||
private Boolean status;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remark;
|
||||
}
|
||||
@ -0,0 +1,159 @@
|
||||
package com.cpop.system.framework.utils;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.cpop.common.constant.Constants;
|
||||
import com.cpop.common.utils.StringUtils;
|
||||
import com.cpop.core.service.RedisService;
|
||||
import com.cpop.core.utils.SpringUtils;
|
||||
import com.cpop.system.business.entity.DictData;
|
||||
import org.springframework.data.redis.cache.RedisCache;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典工具类
|
||||
*/
|
||||
public class DictUtils {
|
||||
/**
|
||||
* 分隔符
|
||||
*/
|
||||
public static final String SEPARATOR = ",";
|
||||
|
||||
/**
|
||||
* 设置字典缓存
|
||||
*
|
||||
* @param key 参数键
|
||||
* @param dictDatas 字典数据列表
|
||||
*/
|
||||
public static void setDictCache(String key, List<DictData> dictDatas) {
|
||||
SpringUtils.getBean(RedisService.class).setCacheObject(getCacheKey(key), dictDatas);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典缓存
|
||||
*
|
||||
* @param key 参数键
|
||||
* @return dictDatas 字典数据列表
|
||||
*/
|
||||
public static List<DictData> getDictCache(String key) {
|
||||
JSONArray arrayCache = SpringUtils.getBean(RedisService.class).getCacheObject(getCacheKey(key));
|
||||
if (StringUtils.isNotNull(arrayCache)) {
|
||||
return arrayCache.toList(DictData.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型和字典值获取字典标签
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param dictValue 字典值
|
||||
* @return 字典标签
|
||||
*/
|
||||
public static String getDictLabel(String dictType, String dictValue) {
|
||||
return getDictLabel(dictType, dictValue, SEPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型和字典标签获取字典值
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param dictLabel 字典标签
|
||||
* @return 字典值
|
||||
*/
|
||||
public static String getDictValue(String dictType, String dictLabel) {
|
||||
return getDictValue(dictType, dictLabel, SEPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型和字典值获取字典标签
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param dictValue 字典值
|
||||
* @param separator 分隔符
|
||||
* @return 字典标签
|
||||
*/
|
||||
public static String getDictLabel(String dictType, String dictValue, String separator) {
|
||||
StringBuilder propertyString = new StringBuilder();
|
||||
List<DictData> datas = getDictCache(dictType);
|
||||
|
||||
if (StringUtils.isNotNull(datas)) {
|
||||
if (StringUtils.containsAny(separator, dictValue)) {
|
||||
for (DictData dict : datas) {
|
||||
for (String value : dictValue.split(separator)) {
|
||||
if (value.equals(dict.getDictValue())) {
|
||||
propertyString.append(dict.getDictLabel()).append(separator);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (DictData dict : datas) {
|
||||
if (dictValue.equals(dict.getDictValue())) {
|
||||
return dict.getDictLabel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return StringUtils.stripEnd(propertyString.toString(), separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型和字典标签获取字典值
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param dictLabel 字典标签
|
||||
* @param separator 分隔符
|
||||
* @return 字典值
|
||||
*/
|
||||
public static String getDictValue(String dictType, String dictLabel, String separator) {
|
||||
StringBuilder propertyString = new StringBuilder();
|
||||
List<DictData> datas = getDictCache(dictType);
|
||||
|
||||
if (StringUtils.containsAny(separator, dictLabel) && StringUtils.isNotEmpty(datas)) {
|
||||
for (DictData dict : datas) {
|
||||
for (String label : dictLabel.split(separator)) {
|
||||
if (label.equals(dict.getDictLabel())) {
|
||||
propertyString.append(dict.getDictValue()).append(separator);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (DictData dict : datas) {
|
||||
if (dictLabel.equals(dict.getDictLabel())) {
|
||||
return dict.getDictValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
return StringUtils.stripEnd(propertyString.toString(), separator);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定字典缓存
|
||||
*
|
||||
* @param key 字典键
|
||||
*/
|
||||
public static void removeDictCache(String key) {
|
||||
SpringUtils.getBean(RedisService.class).deleteObject(getCacheKey(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空字典缓存
|
||||
*/
|
||||
public static void clearDictCache() {
|
||||
Collection<String> keys = SpringUtils.getBean(RedisService.class).keys(Constants.SYS_DICT_KEY + "*");
|
||||
SpringUtils.getBean(RedisService.class).deleteObject(keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置cache key
|
||||
*
|
||||
* @param configKey 参数键
|
||||
* @return 缓存键key
|
||||
*/
|
||||
public static String getCacheKey(String configKey) {
|
||||
return Constants.SYS_DICT_KEY + configKey;
|
||||
}
|
||||
}
|
||||
7
Cpop-System/src/main/resources/mapper/DictDataMapper.xml
Normal file
7
Cpop-System/src/main/resources/mapper/DictDataMapper.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cpop.system.business.mapper.DictDataMapper">
|
||||
|
||||
</mapper>
|
||||
7
Cpop-System/src/main/resources/mapper/DictTypeMapper.xml
Normal file
7
Cpop-System/src/main/resources/mapper/DictTypeMapper.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.cpop.system.business.mapper.DictTypeMapper">
|
||||
|
||||
</mapper>
|
||||
Loading…
x
Reference in New Issue
Block a user