mirror of
https://github.com/1024-lab/smart-admin.git
synced 2025-09-06 12:47:37 +00:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
2f332863e2 | ||
![]() |
e91e4f0b64 | ||
![]() |
b0addda9e9 | ||
![]() |
87354b38d4 | ||
![]() |
51069fc130 | ||
![]() |
a2785fbee7 |
@@ -12,8 +12,8 @@
|
||||
- 前端:JavaScript/TypeScript + Vue3 + Vite5 + Pinia + Ant Design Vue 4.X
|
||||
- 移动端:uniapp (vue3版本) + uni-ui + (同时支持APP、小程序、H5)
|
||||
- 后端:Java8/17 + SpringBoot2/3 + Sa Token + Mybatis-plus + 多种数据库
|
||||
- 电脑在线预览:[https://preview.smartadmin.vip](https://preview.smartadmin.vip)
|
||||
- 官方文档:[https://smartadmin.vip](https://smartadmin.vip)
|
||||
- 电脑在线预览:[https://preview.smartadmin.vip](https://preview.smartadmin.vip)
|
||||
- 移动端在线预览:[https://app.smartadmin.vip](https://app.smartadmin.vip/#/pages/login/login)
|
||||
### **理念与思想**
|
||||
|
||||
|
@@ -2,7 +2,7 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>net.1024lab</groupId>
|
||||
<groupId>net.lab1024</groupId>
|
||||
<artifactId>sa-parent</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<packaging>pom</packaging>
|
||||
@@ -48,7 +48,7 @@
|
||||
<jjwt.version>0.9.1</jjwt.version>
|
||||
<jwks-rsa.version>0.9.0</jwks-rsa.version>
|
||||
<velocity-tools.version>3.1</velocity-tools.version>
|
||||
<sa-token.version>1.37.0</sa-token.version>
|
||||
<sa-token.version>1.41.0</sa-token.version>
|
||||
<ip2region.version>2.7.0</ip2region.version>
|
||||
<bcprov.version>1.80</bcprov.version>
|
||||
<jackson-datatype-jsr310.version>2.13.4</jackson-datatype-jsr310.version>
|
||||
|
@@ -2,7 +2,7 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>net.1024lab</groupId>
|
||||
<groupId>net.lab1024</groupId>
|
||||
<artifactId>sa-parent</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
@@ -18,7 +18,7 @@
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.1024lab</groupId>
|
||||
<groupId>net.lab1024</groupId>
|
||||
<artifactId>sa-base</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
|
@@ -51,6 +51,8 @@ public class AdminSwaggerTagConst extends SwaggerTagConst {
|
||||
|
||||
public static final String SYSTEM_POSITION = "系统-职务管理";
|
||||
|
||||
public static final String SYSTEM_MESSAGE = "系统-消息";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -2,9 +2,8 @@ package net.lab1024.sa.admin.interceptor;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.dev33.satoken.exception.SaTokenException;
|
||||
import cn.dev33.satoken.strategy.SaStrategy;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.dev33.satoken.strategy.SaAnnotationStrategy;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
@@ -84,7 +83,7 @@ public class AdminInterceptor implements HandlerInterceptor {
|
||||
// --------------- 第三步: 校验 权限 ---------------
|
||||
|
||||
SmartRequestUtil.setRequestUser(requestEmployee);
|
||||
if (SaStrategy.instance.isAnnotationPresent.apply(method, SaIgnore.class)) {
|
||||
if (SaAnnotationStrategy.instance.isAnnotationPresent.apply(method, SaIgnore.class)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -93,7 +92,7 @@ public class AdminInterceptor implements HandlerInterceptor {
|
||||
return true;
|
||||
}
|
||||
|
||||
SaStrategy.instance.checkMethodAnnotation.accept(method);
|
||||
SaAnnotationStrategy.instance.checkMethodAnnotation.accept(method);
|
||||
|
||||
} catch (SaTokenException e) {
|
||||
/*
|
||||
@@ -126,7 +125,6 @@ public class AdminInterceptor implements HandlerInterceptor {
|
||||
* 检测:token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结
|
||||
*/
|
||||
private void checkActiveTimeout(RequestEmployee requestEmployee) {
|
||||
|
||||
// 用户不在线,也不用检测
|
||||
if (requestEmployee == null) {
|
||||
return;
|
||||
@@ -137,12 +135,9 @@ public class AdminInterceptor implements HandlerInterceptor {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||
// 清除上下文
|
||||
SmartRequestUtil.remove();
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,24 +0,0 @@
|
||||
package net.lab1024.sa.admin.listener;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* admin 应用启动加载
|
||||
*
|
||||
* @Author 1024创新实验室-主任:卓大
|
||||
* @Date 2021-08-26 18:46:32
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AdminStartupRunner implements CommandLineRunner {
|
||||
|
||||
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
}
|
||||
}
|
@@ -18,7 +18,6 @@ import java.util.List;
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Component
|
||||
@Mapper
|
||||
public interface CategoryDao extends BaseMapper<CategoryEntity> {
|
||||
|
||||
|
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import net.lab1024.sa.admin.module.business.category.constant.CategoryTypeEnum;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
@@ -15,11 +16,13 @@ import java.time.LocalDateTime;
|
||||
* @Date 2021/08/05 21:26:58
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
@TableName("t_category")
|
||||
public class CategoryEntity {
|
||||
public class CategoryEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long categoryId;
|
||||
|
@@ -3,6 +3,7 @@ package net.lab1024.sa.admin.module.business.category.domain.vo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -12,10 +13,12 @@ import java.util.List;
|
||||
* @Date 2021/08/05 21:26:58
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
public class CategoryTreeVO {
|
||||
public class CategoryTreeVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "类目id")
|
||||
private Long categoryId;
|
||||
|
@@ -21,7 +21,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface GoodsDao extends BaseMapper<GoodsEntity> {
|
||||
|
||||
/**
|
||||
|
@@ -7,7 +7,7 @@ import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import net.lab1024.sa.admin.module.business.goods.constant.GoodsStatusEnum;
|
||||
import net.lab1024.sa.base.common.json.deserializer.DictValueVoDeserializer;
|
||||
import net.lab1024.sa.base.common.json.deserializer.DictDataDeserializer;
|
||||
import net.lab1024.sa.base.common.swagger.SchemaEnum;
|
||||
import net.lab1024.sa.base.common.validator.enumeration.CheckEnum;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class GoodsAddForm {
|
||||
|
||||
@Schema(description = "产地")
|
||||
@NotBlank(message = "产地 不能为空 ")
|
||||
@JsonDeserialize(using = DictValueVoDeserializer.class)
|
||||
@JsonDeserialize(using = DictDataDeserializer.class)
|
||||
private String place;
|
||||
|
||||
@Schema(description = "商品价格")
|
||||
|
@@ -5,7 +5,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import net.lab1024.sa.admin.module.business.goods.constant.GoodsStatusEnum;
|
||||
import net.lab1024.sa.base.common.domain.PageParam;
|
||||
import net.lab1024.sa.base.common.json.deserializer.DictValueVoDeserializer;
|
||||
import net.lab1024.sa.base.common.json.deserializer.DictDataDeserializer;
|
||||
import net.lab1024.sa.base.common.swagger.SchemaEnum;
|
||||
import net.lab1024.sa.base.common.validator.enumeration.CheckEnum;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
@@ -17,7 +17,7 @@ import org.hibernate.validator.constraints.Length;
|
||||
* @Date 2021-10-25 20:26:54
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
public class GoodsQueryForm extends PageParam {
|
||||
@@ -34,7 +34,7 @@ public class GoodsQueryForm extends PageParam {
|
||||
private Integer goodsStatus;
|
||||
|
||||
@Schema(description = "产地")
|
||||
@JsonDeserialize(using = DictValueVoDeserializer.class)
|
||||
@JsonDeserialize(using = DictDataDeserializer.class)
|
||||
private String place;
|
||||
|
||||
@Schema(description = "上架状态")
|
||||
|
@@ -26,7 +26,6 @@ import net.lab1024.sa.base.common.util.SmartEnumUtil;
|
||||
import net.lab1024.sa.base.common.util.SmartPageUtil;
|
||||
import net.lab1024.sa.base.module.support.datatracer.constant.DataTracerTypeEnum;
|
||||
import net.lab1024.sa.base.module.support.datatracer.service.DataTracerService;
|
||||
import net.lab1024.sa.base.module.support.dict.service.DictCacheService;
|
||||
import net.lab1024.sa.base.module.support.dict.service.DictService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -60,7 +59,7 @@ public class GoodsService {
|
||||
private DataTracerService dataTracerService;
|
||||
|
||||
@Resource
|
||||
private DictCacheService dictCacheService;
|
||||
private DictService dictService;
|
||||
|
||||
/**
|
||||
* 添加商品
|
||||
@@ -194,13 +193,13 @@ public class GoodsService {
|
||||
*/
|
||||
public List<GoodsExcelVO> getAllGoods() {
|
||||
List<GoodsEntity> goodsEntityList = goodsDao.selectList(null);
|
||||
String keyCode="GODOS_PLACE";
|
||||
String dictCode = "GOODS_PLACE";
|
||||
return goodsEntityList.stream()
|
||||
.map(e ->
|
||||
GoodsExcelVO.builder()
|
||||
.goodsStatus(SmartEnumUtil.getEnumDescByValue(e.getGoodsStatus(), GoodsStatusEnum.class))
|
||||
.categoryName(categoryQueryService.queryCategoryName(e.getCategoryId()))
|
||||
.place(Arrays.stream(e.getPlace().split(",")).map(code -> dictCacheService.selectValueNameByValueCode(keyCode,code)).collect(Collectors.joining(",")))
|
||||
.place(Arrays.stream(e.getPlace().split(",")).map(code -> dictService.getDictDataLabel(dictCode, code)).collect(Collectors.joining(",")))
|
||||
.price(e.getPrice())
|
||||
.goodsName(e.getGoodsName())
|
||||
.remark(e.getRemark())
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package net.lab1024.sa.admin.module.business.oa.bank;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -35,24 +36,28 @@ public class BankController {
|
||||
|
||||
@Operation(summary = "分页查询银行信息 @author 善逸")
|
||||
@PostMapping("/oa/bank/page/query")
|
||||
@SaCheckPermission("oa:bank:query")
|
||||
public ResponseDTO<PageResult<BankVO>> queryByPage(@RequestBody @Valid BankQueryForm queryForm) {
|
||||
return bankService.queryByPage(queryForm);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据企业ID查询银行信息列表 @author 善逸")
|
||||
@GetMapping("/oa/bank/query/list/{enterpriseId}")
|
||||
@SaCheckPermission("oa:bank:query")
|
||||
public ResponseDTO<List<BankVO>> queryList(@PathVariable Long enterpriseId) {
|
||||
return bankService.queryList(enterpriseId);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询银行信息详情 @author 善逸")
|
||||
@GetMapping("/oa/bank/get/{bankId}")
|
||||
@SaCheckPermission("oa:bank:query")
|
||||
public ResponseDTO<BankVO> getDetail(@PathVariable Long bankId) {
|
||||
return bankService.getDetail(bankId);
|
||||
}
|
||||
|
||||
@Operation(summary = "新建银行信息 @author 善逸")
|
||||
@PostMapping("/oa/bank/create")
|
||||
@SaCheckPermission("oa:bank:add")
|
||||
public ResponseDTO<String> createBank(@RequestBody @Valid BankCreateForm createVO) {
|
||||
RequestUser requestUser = SmartRequestUtil.getRequestUser();
|
||||
createVO.setCreateUserId(requestUser.getUserId());
|
||||
@@ -62,12 +67,14 @@ public class BankController {
|
||||
|
||||
@Operation(summary = "编辑银行信息 @author 善逸")
|
||||
@PostMapping("/oa/bank/update")
|
||||
@SaCheckPermission("oa:bank:update")
|
||||
public ResponseDTO<String> updateBank(@RequestBody @Valid BankUpdateForm updateVO) {
|
||||
return bankService.updateBank(updateVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除银行信息 @author 善逸")
|
||||
@GetMapping("/oa/bank/delete/{bankId}")
|
||||
@SaCheckPermission("oa:bank:delete")
|
||||
public ResponseDTO<String> deleteBank(@PathVariable Long bankId) {
|
||||
return bankService.deleteBank(bankId);
|
||||
}
|
||||
|
@@ -21,7 +21,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface BankDao extends BaseMapper<BankEntity> {
|
||||
|
||||
/**
|
||||
|
@@ -100,6 +100,7 @@ public class EnterpriseController {
|
||||
|
||||
@Operation(summary = "按照类型查询企业 @author 开云")
|
||||
@GetMapping("/oa/enterprise/query/list")
|
||||
@SaCheckPermission("oa:enterprise:query")
|
||||
public ResponseDTO<List<EnterpriseListVO>> queryList(@RequestParam(value = "type", required = false) Integer type) {
|
||||
return enterpriseService.queryList(type);
|
||||
}
|
||||
@@ -114,12 +115,14 @@ public class EnterpriseController {
|
||||
|
||||
@Operation(summary = "查询企业全部员工 @author 罗伊")
|
||||
@PostMapping("/oa/enterprise/employee/list")
|
||||
@SaCheckPermission("oa:enterprise:queryEmployee")
|
||||
public ResponseDTO<List<EnterpriseEmployeeVO>> employeeList(@RequestBody @Valid List<Long> enterpriseIdList) {
|
||||
return ResponseDTO.ok(enterpriseService.employeeList(enterpriseIdList));
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询企业员工 @author 卓大")
|
||||
@PostMapping("/oa/enterprise/employee/queryPage")
|
||||
@SaCheckPermission("oa:enterprise:queryEmployee")
|
||||
public ResponseDTO<PageResult<EnterpriseEmployeeVO>> queryPageEmployeeList(@RequestBody @Valid EnterpriseEmployeeQueryForm queryForm) {
|
||||
return ResponseDTO.ok(enterpriseService.queryPageEmployeeList(queryForm));
|
||||
}
|
||||
|
@@ -23,7 +23,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface EnterpriseDao extends BaseMapper<EnterpriseEntity> {
|
||||
|
||||
/**
|
||||
|
@@ -22,7 +22,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface EnterpriseEmployeeDao extends BaseMapper<EnterpriseEmployeeEntity> {
|
||||
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package net.lab1024.sa.admin.module.business.oa.invoice;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -38,18 +39,21 @@ public class InvoiceController {
|
||||
|
||||
@Operation(summary = "分页查询发票信息 @author 善逸")
|
||||
@PostMapping("/oa/invoice/page/query")
|
||||
@SaCheckPermission("oa:invoice:query")
|
||||
public ResponseDTO<PageResult<InvoiceVO>> queryByPage(@RequestBody @Valid InvoiceQueryForm queryForm) {
|
||||
return invoiceService.queryByPage(queryForm);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询发票信息详情 @author 善逸")
|
||||
@GetMapping("/oa/invoice/get/{invoiceId}")
|
||||
@SaCheckPermission("oa:invoice:query")
|
||||
public ResponseDTO<InvoiceVO> getDetail(@PathVariable Long invoiceId) {
|
||||
return invoiceService.getDetail(invoiceId);
|
||||
}
|
||||
|
||||
@Operation(summary = "新建发票信息 @author 善逸")
|
||||
@PostMapping("/oa/invoice/create")
|
||||
@SaCheckPermission("oa:invoice:add")
|
||||
public ResponseDTO<String> createInvoice(@RequestBody @Valid InvoiceAddForm createVO) {
|
||||
RequestUser requestUser = SmartRequestUtil.getRequestUser();
|
||||
createVO.setCreateUserId(requestUser.getUserId());
|
||||
@@ -57,21 +61,24 @@ public class InvoiceController {
|
||||
return invoiceService.createInvoice(createVO);
|
||||
}
|
||||
|
||||
@OperateLog
|
||||
@Operation(summary = "编辑发票信息 @author 善逸")
|
||||
@PostMapping("/oa/invoice/update")
|
||||
@OperateLog
|
||||
@SaCheckPermission("oa:invoice:update")
|
||||
public ResponseDTO<String> updateInvoice(@RequestBody @Valid InvoiceUpdateForm updateVO) {
|
||||
return invoiceService.updateInvoice(updateVO);
|
||||
}
|
||||
|
||||
@Operation(summary = "删除发票信息 @author 善逸")
|
||||
@GetMapping("/invoice/delete/{invoiceId}")
|
||||
@SaCheckPermission("oa:invoice:delete")
|
||||
public ResponseDTO<String> deleteInvoice(@PathVariable Long invoiceId) {
|
||||
return invoiceService.deleteInvoice(invoiceId);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询列表 @author lidoudou")
|
||||
@GetMapping("/oa/invoice/query/list/{enterpriseId}")
|
||||
@SaCheckPermission("oa:invoice:query")
|
||||
public ResponseDTO<List<InvoiceVO>> queryList(@PathVariable Long enterpriseId) {
|
||||
return invoiceService.queryList(enterpriseId);
|
||||
}
|
||||
|
@@ -21,7 +21,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface InvoiceDao extends BaseMapper<InvoiceEntity> {
|
||||
|
||||
/**
|
||||
|
@@ -27,7 +27,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface NoticeDao extends BaseMapper<NoticeEntity> {
|
||||
|
||||
// ================================= 数据范围相关 【子表】 =================================
|
||||
|
@@ -15,7 +15,6 @@ import org.springframework.stereotype.Component;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface NoticeTypeDao extends BaseMapper<NoticeTypeEntity> {
|
||||
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* @Date 2020/11/28 20:59:17
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@@ -89,7 +89,6 @@ public class DataScopeSqlConfigService {
|
||||
|
||||
/**
|
||||
* 根据调用的方法获取,此方法的配置信息
|
||||
*
|
||||
*/
|
||||
public DataScopeSqlConfig getSqlConfig(String method) {
|
||||
return this.dataScopeMethodMap.get(method);
|
||||
@@ -125,7 +124,7 @@ public class DataScopeSqlConfigService {
|
||||
log.warn("data scope custom strategy class:{} ,bean is null", sqlConfigDTO.getJoinSqlImplClazz());
|
||||
return "";
|
||||
}
|
||||
return powerStrategy.getCondition(viewTypeEnum,paramMap, sqlConfigDTO);
|
||||
return powerStrategy.getCondition(viewTypeEnum, paramMap, sqlConfigDTO);
|
||||
}
|
||||
if (DataScopeWhereInTypeEnum.EMPLOYEE == sqlConfigDTO.getDataScopeWhereInType()) {
|
||||
List<Long> canViewEmployeeIds = dataScopeViewService.getCanViewEmployeeId(viewTypeEnum, employeeId);
|
||||
|
@@ -56,6 +56,7 @@ public class DataScopeViewService {
|
||||
if (DataScopeViewTypeEnum.DEPARTMENT_AND_SUB == viewType) {
|
||||
return this.getDepartmentAndSubEmployeeIdList(employeeId);
|
||||
}
|
||||
// 可以查看所有员工数据
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,6 @@ import java.util.List;
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Component
|
||||
@Mapper
|
||||
public interface DepartmentDao extends BaseMapper<DepartmentEntity> {
|
||||
|
||||
|
@@ -36,7 +36,7 @@ public class DepartmentEntity {
|
||||
/**
|
||||
* 负责人员工 id
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
private Long managerId;
|
||||
|
||||
/**
|
||||
|
@@ -3,6 +3,7 @@ package net.lab1024.sa.admin.module.system.department.domain.vo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
@@ -12,10 +13,12 @@ import java.time.LocalDateTime;
|
||||
* @Date 2022-01-12 20:37:48
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
public class DepartmentVO {
|
||||
public class DepartmentVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "部门id")
|
||||
private Long departmentId;
|
||||
|
@@ -117,7 +117,7 @@ public class EmployeeController {
|
||||
@Operation(summary = "查询员工-根据部门id @author 卓大")
|
||||
@GetMapping("/employee/getAllEmployeeByDepartmentId/{departmentId}")
|
||||
public ResponseDTO<List<EmployeeVO>> getAllEmployeeByDepartmentId(@PathVariable Long departmentId) {
|
||||
return employeeService.getAllEmployeeByDepartmentId(departmentId, Boolean.FALSE);
|
||||
return employeeService.getAllEmployeeByDepartmentId(departmentId);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询所有员工 @author 卓大")
|
||||
|
@@ -22,7 +22,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
||||
/**
|
||||
* 查询员工列表
|
||||
@@ -35,7 +34,7 @@ public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
||||
List<EmployeeVO> selectEmployeeByDisabledAndDeleted(@Param("disabledFlag") Boolean disabledFlag, @Param("deletedFlag") Boolean deletedFlag);
|
||||
|
||||
/**
|
||||
* 更新禁用状态
|
||||
* 更新单个
|
||||
*/
|
||||
void updateDisableFlag(@Param("employeeId") Long employeeId, @Param("disabledFlag") Boolean disabledFlag);
|
||||
|
||||
|
@@ -53,4 +53,4 @@ public class EmployeeUpdateCenterForm {
|
||||
@Schema(description = "备注")
|
||||
@Length(max = 200, message = "备注最多200字符")
|
||||
private String remark;
|
||||
}
|
||||
}
|
@@ -239,7 +239,6 @@ public class EmployeeService {
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新登录人头像
|
||||
*
|
||||
@@ -384,11 +383,8 @@ public class EmployeeService {
|
||||
/**
|
||||
* 获取某个部门的员工信息
|
||||
*/
|
||||
public ResponseDTO<List<EmployeeVO>> getAllEmployeeByDepartmentId(Long departmentId, Boolean disabledFlag) {
|
||||
List<EmployeeEntity> employeeEntityList = employeeDao.selectByDepartmentId(departmentId, disabledFlag);
|
||||
if (disabledFlag != null) {
|
||||
employeeEntityList = employeeEntityList.stream().filter(e -> e.getDisabledFlag().equals(disabledFlag)).collect(Collectors.toList());
|
||||
}
|
||||
public ResponseDTO<List<EmployeeVO>> getAllEmployeeByDepartmentId(Long departmentId) {
|
||||
List<EmployeeEntity> employeeEntityList = employeeDao.selectByDepartmentId(departmentId, Boolean.FALSE);
|
||||
|
||||
if (CollectionUtils.isEmpty(employeeEntityList)) {
|
||||
return ResponseDTO.ok(Collections.emptyList());
|
||||
@@ -429,7 +425,7 @@ public class EmployeeService {
|
||||
* 根据登录名获取员工
|
||||
*/
|
||||
public EmployeeEntity getByLoginName(String loginName) {
|
||||
return employeeDao.getByLoginName(loginName, null);
|
||||
return employeeDao.getByLoginName(loginName, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
* @Date 2021-12-15 21:05:46
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@RestController
|
||||
@Tag(name = AdminSwaggerTagConst.System.SYSTEM_LOGIN)
|
||||
|
@@ -167,12 +167,12 @@ public class LoginService implements StpInterface {
|
||||
|
||||
// 验证账号状态
|
||||
if (employeeEntity.getDeletedFlag()) {
|
||||
saveLoginLog(employeeEntity, ip, userAgent, "账号已删除", LoginLogResultEnum.LOGIN_FAIL);
|
||||
saveLoginLog(employeeEntity, ip, userAgent, "账号已删除", LoginLogResultEnum.LOGIN_FAIL, loginDeviceEnum);
|
||||
return ResponseDTO.userErrorParam("您的账号已被删除,请联系工作人员!");
|
||||
}
|
||||
|
||||
if (employeeEntity.getDisabledFlag()) {
|
||||
saveLoginLog(employeeEntity, ip, userAgent, "账号已禁用", LoginLogResultEnum.LOGIN_FAIL);
|
||||
saveLoginLog(employeeEntity, ip, userAgent, "账号已禁用", LoginLogResultEnum.LOGIN_FAIL, loginDeviceEnum);
|
||||
return ResponseDTO.userErrorParam("您的账号已被禁用,请联系工作人员!");
|
||||
}
|
||||
|
||||
@@ -206,9 +206,9 @@ public class LoginService implements StpInterface {
|
||||
}
|
||||
|
||||
// 密码错误
|
||||
if ( !SecurityPasswordService.matchesPwd(requestPassword,employeeEntity.getLoginPwd()) ) {
|
||||
if (!SecurityPasswordService.matchesPwd(requestPassword, employeeEntity.getLoginPwd())) {
|
||||
// 记录登录失败
|
||||
saveLoginLog(employeeEntity, ip, userAgent, "密码错误", LoginLogResultEnum.LOGIN_FAIL);
|
||||
saveLoginLog(employeeEntity, ip, userAgent, "密码错误", LoginLogResultEnum.LOGIN_FAIL, loginDeviceEnum);
|
||||
// 记录等级保护次数
|
||||
String msg = securityLoginService.recordLoginFail(employeeEntity.getEmployeeId(), UserTypeEnum.ADMIN_EMPLOYEE, employeeEntity.getLoginName(), loginFailEntityResponseDTO.getData());
|
||||
return msg == null ? ResponseDTO.userErrorParam("登录名或密码错误!") : ResponseDTO.error(UserErrorCode.LOGIN_FAIL_WILL_LOCK, msg);
|
||||
@@ -237,7 +237,7 @@ public class LoginService implements StpInterface {
|
||||
LoginResultVO loginResultVO = getLoginResult(requestEmployee, token);
|
||||
|
||||
//保存登录记录
|
||||
saveLoginLog(employeeEntity, ip, userAgent, superPasswordFlag ? "万能密码登录" : loginDeviceEnum.getDesc(), LoginLogResultEnum.LOGIN_SUCCESS);
|
||||
saveLoginLog(employeeEntity, ip, userAgent, superPasswordFlag ? "万能密码登录" : StringConst.EMPTY, LoginLogResultEnum.LOGIN_SUCCESS, loginDeviceEnum);
|
||||
|
||||
// 设置 token
|
||||
loginResultVO.setToken(token);
|
||||
@@ -411,7 +411,7 @@ public class LoginService implements StpInterface {
|
||||
/**
|
||||
* 保存登录日志
|
||||
*/
|
||||
private void saveLoginLog(EmployeeEntity employeeEntity, String ip, String userAgent, String remark, LoginLogResultEnum result) {
|
||||
private void saveLoginLog(EmployeeEntity employeeEntity, String ip, String userAgent, String remark, LoginLogResultEnum result, LoginDeviceEnum loginDeviceEnum) {
|
||||
LoginLogEntity loginEntity = LoginLogEntity.builder()
|
||||
.userId(employeeEntity.getEmployeeId())
|
||||
.userType(UserTypeEnum.ADMIN_EMPLOYEE.getValue())
|
||||
@@ -420,6 +420,7 @@ public class LoginService implements StpInterface {
|
||||
.loginIp(ip)
|
||||
.loginIpRegion(SmartIpUtil.getRegion(ip))
|
||||
.remark(remark)
|
||||
.loginDevice(loginDeviceEnum.getDesc())
|
||||
.loginResult(result.getValue())
|
||||
.createTime(LocalDateTime.now())
|
||||
.build();
|
||||
|
@@ -19,7 +19,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface MenuDao extends BaseMapper<MenuEntity> {
|
||||
|
||||
/**
|
||||
|
@@ -0,0 +1,54 @@
|
||||
package net.lab1024.sa.admin.module.system.message;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import net.lab1024.sa.admin.constant.AdminSwaggerTagConst;
|
||||
import net.lab1024.sa.base.common.domain.PageResult;
|
||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||
import net.lab1024.sa.base.common.domain.ValidateList;
|
||||
import net.lab1024.sa.base.module.support.message.domain.MessageQueryForm;
|
||||
import net.lab1024.sa.base.module.support.message.domain.MessageSendForm;
|
||||
import net.lab1024.sa.base.module.support.message.domain.MessageVO;
|
||||
import net.lab1024.sa.base.module.support.message.service.MessageService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
/**
|
||||
* 后管 消息路由
|
||||
*
|
||||
* @author: 卓大
|
||||
* @date: 2025/04/09 20:55
|
||||
*/
|
||||
@Tag(name = AdminSwaggerTagConst.System.SYSTEM_MESSAGE)
|
||||
@RestController
|
||||
public class AdminMessageController {
|
||||
|
||||
@Autowired
|
||||
private MessageService messageService;
|
||||
|
||||
@Operation(summary = "通知消息-新建 @author 卓大")
|
||||
@PostMapping("/message/sendMessages")
|
||||
@SaCheckPermission("system:message:send")
|
||||
public ResponseDTO<String> sendMessages(@RequestBody @Valid ValidateList<MessageSendForm> messageList) {
|
||||
messageService.sendMessage(messageList);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
@Operation(summary = "通知消息-分页查询 @author 卓大")
|
||||
@PostMapping("/message/query")
|
||||
@SaCheckPermission("system:message:query")
|
||||
public ResponseDTO<PageResult<MessageVO>> query(@RequestBody @Valid MessageQueryForm queryForm) {
|
||||
return ResponseDTO.ok(messageService.query(queryForm));
|
||||
}
|
||||
|
||||
@Operation(summary = "通知消息-删除 @author 卓大")
|
||||
@GetMapping("/message/delete/{messageId}")
|
||||
@SaCheckPermission("system:message:delete")
|
||||
public ResponseDTO<String> delete(@PathVariable Long messageId) {
|
||||
return messageService.delete(messageId);
|
||||
}
|
||||
|
||||
}
|
@@ -19,7 +19,6 @@ import org.springframework.stereotype.Component;
|
||||
*/
|
||||
|
||||
@Mapper
|
||||
@Component
|
||||
public interface PositionDao extends BaseMapper<PositionEntity> {
|
||||
|
||||
/**
|
||||
|
@@ -16,7 +16,6 @@ import net.lab1024.sa.admin.module.system.role.domain.entity.RoleEntity;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface RoleDao extends BaseMapper<RoleEntity> {
|
||||
|
||||
/**
|
||||
|
@@ -19,7 +19,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface RoleDataScopeDao extends BaseMapper<RoleDataScopeEntity> {
|
||||
|
||||
/**
|
||||
|
@@ -25,7 +25,6 @@ import java.util.Set;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface RoleEmployeeDao extends BaseMapper<RoleEmployeeEntity> {
|
||||
|
||||
/**
|
||||
|
@@ -19,7 +19,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface RoleMenuDao extends BaseMapper<RoleMenuEntity> {
|
||||
|
||||
/**
|
||||
|
@@ -8,26 +8,24 @@ import jakarta.validation.Valid;
|
||||
import net.lab1024.sa.base.common.controller.SupportBaseController;
|
||||
import net.lab1024.sa.base.common.domain.PageResult;
|
||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||
import net.lab1024.sa.base.common.domain.ValidateList;
|
||||
import net.lab1024.sa.base.constant.SwaggerTagConst;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.form.*;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictKeyVO;
|
||||
import net.lab1024.sa.base.module.support.dict.service.DictCacheService;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictDataVO;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictVO;
|
||||
import net.lab1024.sa.base.module.support.dict.service.DictService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
* 数据字典 Controller
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 22:25:04
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Tag(name = SwaggerTagConst.Support.DICT)
|
||||
@RestController
|
||||
@@ -36,60 +34,106 @@ public class AdminDictController extends SupportBaseController {
|
||||
@Resource
|
||||
private DictService dictService;
|
||||
|
||||
@Resource
|
||||
private DictCacheService dictCacheService;
|
||||
// ------------------- 获取全部数据 -------------------
|
||||
|
||||
@Operation(summary = "分页查询数据字典KEY - @author 罗伊")
|
||||
@PostMapping("/dict/key/query")
|
||||
public ResponseDTO<PageResult<DictKeyVO>> keyQuery(@Valid @RequestBody DictKeyQueryForm queryForm) {
|
||||
return dictService.keyQuery(queryForm);
|
||||
@Operation(summary = "获取全部数据(供前端缓存使用) @author 1024创新实验室-主任-卓大")
|
||||
@GetMapping("/dict/getAllDictData")
|
||||
public ResponseDTO<List<DictDataVO>> getAll() {
|
||||
return ResponseDTO.ok(dictService.getAll());
|
||||
}
|
||||
|
||||
@Operation(summary = "获取所有字典code @author 1024创新实验室-主任-卓大")
|
||||
@GetMapping("/dict/getAllDict")
|
||||
public ResponseDTO<List<DictVO>> getAllDict() {
|
||||
return ResponseDTO.ok(dictService.getAllDict());
|
||||
}
|
||||
|
||||
@Operation(summary = "数据字典KEY-添加- @author 罗伊")
|
||||
@PostMapping("/dict/key/add")
|
||||
// ------------------- 字典 -------------------
|
||||
|
||||
@Operation(summary = "分页查询 @author 1024创新实验室-主任-卓大")
|
||||
@PostMapping("/dict/queryPage")
|
||||
@SaCheckPermission("support:dict:query")
|
||||
public ResponseDTO<PageResult<DictVO>> queryPage(@RequestBody @Valid DictQueryForm queryForm) {
|
||||
return ResponseDTO.ok(dictService.queryPage(queryForm));
|
||||
}
|
||||
|
||||
@Operation(summary = "添加 @author 1024创新实验室-主任-卓大")
|
||||
@PostMapping("/dict/add")
|
||||
@SaCheckPermission("support:dict:add")
|
||||
public ResponseDTO<String> keyAdd(@Valid @RequestBody DictKeyAddForm keyAddForm) {
|
||||
return dictService.keyAdd(keyAddForm);
|
||||
public ResponseDTO<String> add(@RequestBody @Valid DictAddForm addForm) {
|
||||
return dictService.add(addForm);
|
||||
}
|
||||
|
||||
@Operation(summary = "数据字典缓存-刷新- @author 罗伊")
|
||||
@GetMapping("/dict/cache/refresh")
|
||||
@SaCheckPermission("support:dict:refresh")
|
||||
public ResponseDTO<String> cacheRefresh() {
|
||||
return dictCacheService.cacheRefresh();
|
||||
@Operation(summary = "更新 @author 1024创新实验室-主任-卓大")
|
||||
@PostMapping("/dict/update")
|
||||
@SaCheckPermission("support:dict:update")
|
||||
public ResponseDTO<String> update(@RequestBody @Valid DictUpdateForm updateForm) {
|
||||
return dictService.update(updateForm);
|
||||
}
|
||||
|
||||
@Operation(summary = "数据字典Value-添加- @author 罗伊")
|
||||
@PostMapping("/dict/value/add")
|
||||
public ResponseDTO<String> valueAdd(@Valid @RequestBody DictValueAddForm valueAddForm) {
|
||||
return dictService.valueAdd(valueAddForm);
|
||||
@Operation(summary = "启用/禁用 @author 1024创新实验室-主任-卓大")
|
||||
@GetMapping("/dict/updateDisabled/{dictId}")
|
||||
@SaCheckPermission("support:dict:updateDisabled")
|
||||
public ResponseDTO<String> updateDisabled(@PathVariable Long dictId) {
|
||||
return dictService.updateDisabled(dictId);
|
||||
}
|
||||
|
||||
@Operation(summary = "数据字典KEY-更新- @author 罗伊")
|
||||
@PostMapping("/dict/key/edit")
|
||||
@SaCheckPermission("support:dict:edit")
|
||||
public ResponseDTO<String> keyEdit(@Valid @RequestBody DictKeyUpdateForm keyUpdateForm) {
|
||||
return dictService.keyEdit(keyUpdateForm);
|
||||
}
|
||||
|
||||
@Operation(summary = "数据字典Value-更新- @author 罗伊")
|
||||
@PostMapping("/dict/value/edit")
|
||||
public ResponseDTO<String> valueEdit(@Valid @RequestBody DictValueUpdateForm valueUpdateForm) {
|
||||
return dictService.valueEdit(valueUpdateForm);
|
||||
}
|
||||
|
||||
@Operation(summary = "数据字典KEY-删除- @author 罗伊")
|
||||
@PostMapping("/dict/key/delete")
|
||||
@Operation(summary = "批量删除 @author 1024创新实验室-主任-卓大")
|
||||
@PostMapping("/dict/batchDelete")
|
||||
@SaCheckPermission("support:dict:delete")
|
||||
public ResponseDTO<String> keyDelete(@RequestBody List<Long> keyIdList) {
|
||||
return dictService.keyDelete(keyIdList);
|
||||
public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
|
||||
return dictService.batchDelete(idList);
|
||||
}
|
||||
|
||||
@Operation(summary = "数据字典Value-删除- @author 罗伊")
|
||||
@PostMapping("/dict/value/delete")
|
||||
public ResponseDTO<String> valueDelete(@RequestBody List<Long> valueIdList) {
|
||||
return dictService.valueDelete(valueIdList);
|
||||
@Operation(summary = "单个删除 @author 1024创新实验室-主任-卓大")
|
||||
@GetMapping("/dict/delete/{dictId}")
|
||||
@SaCheckPermission("support:dict:delete")
|
||||
public ResponseDTO<String> delete(@PathVariable Long dictId) {
|
||||
return dictService.delete(dictId);
|
||||
}
|
||||
|
||||
// ------------------- 字典数据 -------------------
|
||||
|
||||
@Operation(summary = "字典数据 分页查询 @author 1024创新实验室-主任-卓大")
|
||||
@GetMapping("/dict/dictData/queryDictData/{dictId}")
|
||||
@SaCheckPermission("support:dictData:query")
|
||||
public ResponseDTO<List<DictDataVO>> queryDictData(@PathVariable Long dictId) {
|
||||
return ResponseDTO.ok(dictService.queryDictData(dictId));
|
||||
}
|
||||
|
||||
@Operation(summary = "字典数据 启用/禁用 @author 1024创新实验室-主任-卓大")
|
||||
@GetMapping("/dict/dictData/updateDisabled/{dictDataId}")
|
||||
@SaCheckPermission("support:dictData:updateDisabled")
|
||||
public ResponseDTO<String> updateDictDataDisabled(@PathVariable Long dictDataId) {
|
||||
return dictService.updateDictDataDisabled(dictDataId);
|
||||
}
|
||||
|
||||
@Operation(summary = "字典数据 添加 @author 1024创新实验室-主任-卓大")
|
||||
@PostMapping("/dict/dictData/add")
|
||||
@SaCheckPermission("support:dictData:add")
|
||||
public ResponseDTO<String> addDictData(@RequestBody @Valid DictDataAddForm addForm) {
|
||||
return dictService.addDictData(addForm);
|
||||
}
|
||||
|
||||
@Operation(summary = "字典数据 更新 @author 1024创新实验室-主任-卓大")
|
||||
@PostMapping("/dict/dictData/update")
|
||||
@SaCheckPermission("support:dictData:update")
|
||||
public ResponseDTO<String> updateDictData(@RequestBody @Valid DictDataUpdateForm updateForm) {
|
||||
return dictService.updateDictData(updateForm);
|
||||
}
|
||||
|
||||
@Operation(summary = "字典数据 批量删除 @author 1024创新实验室-主任-卓大")
|
||||
@PostMapping("/dict/dictData/batchDelete")
|
||||
@SaCheckPermission("support:dictData:delete")
|
||||
public ResponseDTO<String> batchDeleteDictData(@RequestBody ValidateList<Long> idList) {
|
||||
return dictService.batchDeleteDictData(idList);
|
||||
}
|
||||
|
||||
@Operation(summary = "字典数据 单个删除 @author 1024创新实验室-主任-卓大")
|
||||
@GetMapping("/dict/dictData/delete/{dictDataId}")
|
||||
@SaCheckPermission("support:dictData:delete")
|
||||
public ResponseDTO<String> deleteDictData(@PathVariable Long dictDataId) {
|
||||
return dictService.deleteDictData(dictDataId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>net.1024lab</groupId>
|
||||
<groupId>net.lab1024</groupId>
|
||||
<artifactId>sa-parent</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
|
@@ -1,18 +1,15 @@
|
||||
package net.lab1024.sa.base.common.json.deserializer;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.ObjectCodec;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictValueVO;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 字典反序列化
|
||||
@@ -21,13 +18,13 @@ import java.util.stream.Collectors;
|
||||
* @Date 2022-08-12 22:17:53
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Slf4j
|
||||
public class DictValueVoDeserializer extends JsonDeserializer<String> {
|
||||
public class DictDataDeserializer extends JsonDeserializer<String> {
|
||||
|
||||
@Override
|
||||
public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
|
||||
public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
|
||||
List<String> list = new ArrayList<>();
|
||||
ObjectCodec objectCodec = jsonParser.getCodec();
|
||||
JsonNode listOrObjectNode = objectCodec.readTree(jsonParser);
|
@@ -0,0 +1,35 @@
|
||||
package net.lab1024.sa.base.config;
|
||||
|
||||
import net.lab1024.sa.base.module.support.cache.CacheService;
|
||||
import net.lab1024.sa.base.module.support.cache.CaffeineCacheServiceImpl;
|
||||
import net.lab1024.sa.base.module.support.cache.RedisCacheServiceImpl;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 缓存配置
|
||||
*
|
||||
* @author zhoumingfa
|
||||
* @date 2025/03/28
|
||||
*/
|
||||
@Configuration
|
||||
public class CacheConfig {
|
||||
|
||||
private static final String REDIS_CACHE = "redis";
|
||||
private static final String CAFFEINE_CACHE = "caffeine";
|
||||
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "spring.cache", name = {"type"}, havingValue = REDIS_CACHE)
|
||||
public CacheService redisCacheService() {
|
||||
return new RedisCacheServiceImpl();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "spring.cache", name = {"type"}, havingValue = CAFFEINE_CACHE)
|
||||
public CacheService caffeineCacheService() {
|
||||
return new CaffeineCacheServiceImpl();
|
||||
}
|
||||
|
||||
}
|
@@ -145,7 +145,7 @@ public class DataSourceConfig {
|
||||
if (dataScopePlugin != null) {
|
||||
pluginsList.add(dataScopePlugin);
|
||||
}
|
||||
factoryBean.setPlugins(pluginsList.toArray(new Interceptor[pluginsList.size()]));
|
||||
factoryBean.setPlugins(pluginsList.toArray(new Interceptor[0]));
|
||||
// 添加字段自动填充处理
|
||||
factoryBean.setGlobalConfig(new GlobalConfig().setBanner(false).setMetaObjectHandler(new MybatisPlusFillHandler()));
|
||||
|
||||
|
@@ -25,7 +25,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
* @Date 2019-09-02 23:21:10
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
@Configuration
|
||||
@@ -68,7 +68,7 @@ public class FileConfig implements WebMvcConfigurer {
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "file.storage", name = {"mode"}, havingValue = "cloud")
|
||||
@ConditionalOnProperty(prefix = "file.storage", name = {"mode"}, havingValue = MODE_CLOUD)
|
||||
public AmazonS3 initAmazonS3() {
|
||||
ClientConfiguration clientConfig = new ClientConfiguration();
|
||||
clientConfig.setProtocol(Protocol.HTTPS);
|
||||
|
@@ -1,11 +1,13 @@
|
||||
package net.lab1024.sa.base.config;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import net.lab1024.sa.base.common.constant.StringConst;
|
||||
import net.lab1024.sa.base.common.util.SmartRequestUtil;
|
||||
import net.lab1024.sa.base.module.support.repeatsubmit.RepeatSubmitAspect;
|
||||
import net.lab1024.sa.base.module.support.repeatsubmit.ticket.RepeatSubmitCaffeineTicket;
|
||||
import net.lab1024.sa.base.module.support.repeatsubmit.ticket.RepeatSubmitRedisTicket;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.core.ValueOperations;
|
||||
|
||||
/**
|
||||
* 重复提交配置
|
||||
@@ -14,14 +16,17 @@ import org.springframework.context.annotation.Configuration;
|
||||
* @Date 2021/10/9 18:47
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Configuration
|
||||
public class RepeatSubmitConfig {
|
||||
|
||||
@Resource
|
||||
private ValueOperations<String, String> valueOperations;
|
||||
|
||||
@Bean
|
||||
public RepeatSubmitAspect repeatSubmitAspect() {
|
||||
RepeatSubmitCaffeineTicket caffeineTicket = new RepeatSubmitCaffeineTicket(this::ticket);
|
||||
RepeatSubmitRedisTicket caffeineTicket = new RepeatSubmitRedisTicket(valueOperations, this::ticket);
|
||||
return new RepeatSubmitAspect(caffeineTicket);
|
||||
}
|
||||
|
||||
|
@@ -7,8 +7,14 @@ package net.lab1024.sa.base.constant;
|
||||
* @Date 2022-05-30 21:22:12
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
public class CacheKeyConst {
|
||||
|
||||
public static class Dict {
|
||||
|
||||
public static final String DICT_DATA = "dict_data_cache";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package net.lab1024.sa.base.module.support.apiencrypt.advice;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.sa.base.common.util.SmartStringUtil;
|
||||
@@ -25,7 +25,7 @@ import java.lang.reflect.Type;
|
||||
* @Date 2023/10/21 11:41:46
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>,Since 2012
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>,Since 2012
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@@ -37,16 +37,19 @@ public class DecryptRequestAdvice extends RequestBodyAdviceAdapter {
|
||||
@Resource
|
||||
private ApiEncryptService apiEncryptService;
|
||||
|
||||
@Resource
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@Override
|
||||
public boolean supports(MethodParameter methodParameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) {
|
||||
return methodParameter.hasMethodAnnotation(ApiDecrypt.class) || methodParameter.hasParameterAnnotation(ApiDecrypt.class) || methodParameter.getContainingClass().isAnnotationPresent(ApiDecrypt.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) {
|
||||
public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) {
|
||||
try {
|
||||
String bodyStr = IOUtils.toString(inputMessage.getBody(), ENCODING);
|
||||
ApiEncryptForm apiEncryptForm = JSONObject.parseObject(bodyStr, ApiEncryptForm.class);
|
||||
ApiEncryptForm apiEncryptForm = objectMapper.readValue(bodyStr, ApiEncryptForm.class);
|
||||
if (SmartStringUtil.isEmpty(apiEncryptForm.getEncryptData())) {
|
||||
return inputMessage;
|
||||
}
|
||||
|
@@ -24,13 +24,13 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
|
||||
* @Date 2023/10/24 09:52:58
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>,Since 2012
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>,Since 2012
|
||||
*/
|
||||
|
||||
|
||||
@Slf4j
|
||||
@ControllerAdvice
|
||||
public class EncryptResponseAdvice implements ResponseBodyAdvice<ResponseDTO> {
|
||||
public class EncryptResponseAdvice implements ResponseBodyAdvice<ResponseDTO<Object>> {
|
||||
|
||||
@Resource
|
||||
private ApiEncryptService apiEncryptService;
|
||||
@@ -44,19 +44,18 @@ public class EncryptResponseAdvice implements ResponseBodyAdvice<ResponseDTO> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseDTO beforeBodyWrite(ResponseDTO body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
|
||||
if (body.getData() == null) {
|
||||
public ResponseDTO<Object> beforeBodyWrite(ResponseDTO<Object> body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
|
||||
if (body == null || body.getData() == null) {
|
||||
return body;
|
||||
}
|
||||
|
||||
String encrypt = null;
|
||||
try {
|
||||
encrypt = apiEncryptService.encrypt(objectMapper.writeValueAsString(body.getData()));
|
||||
String encrypt = apiEncryptService.encrypt(objectMapper.writeValueAsString(body.getData()));
|
||||
body.setData(encrypt);
|
||||
body.setDataType(DataTypeEnum.ENCRYPT.getValue());
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
body.setData(encrypt);
|
||||
body.setDataType(DataTypeEnum.ENCRYPT.getValue());
|
||||
return body;
|
||||
}
|
||||
}
|
||||
|
@@ -14,61 +14,30 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 缓存操作
|
||||
* 缓存服务
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2021/10/11 20:07
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Service
|
||||
public class CacheService {
|
||||
|
||||
@Resource
|
||||
private CaffeineCacheManager caffeineCacheManager;
|
||||
public interface CacheService {
|
||||
|
||||
/**
|
||||
* 获取所有缓存名称
|
||||
*
|
||||
*/
|
||||
public List<String> cacheNames() {
|
||||
return Lists.newArrayList(caffeineCacheManager.getCacheNames());
|
||||
}
|
||||
List<String> cacheNames();
|
||||
|
||||
/**
|
||||
* 某个缓存下的所有key
|
||||
*
|
||||
* 某个缓存下的所有 key
|
||||
*/
|
||||
public List<String> cacheKey(String cacheName) {
|
||||
CaffeineCache cache = (CaffeineCache) caffeineCacheManager.getCache(cacheName);
|
||||
if (cache == null) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
Set<Object> cacheKey = cache.getNativeCache().asMap().keySet();
|
||||
return cacheKey.stream().map(e -> e.toString()).collect(Collectors.toList());
|
||||
}
|
||||
List<String> cacheKey(String cacheName);
|
||||
|
||||
/**
|
||||
* 移除某个key
|
||||
*
|
||||
* 移除某个 key
|
||||
*/
|
||||
void removeCache(String cacheName);
|
||||
|
||||
public void removeCache(String cacheName) {
|
||||
CaffeineCache cache = (CaffeineCache) caffeineCacheManager.getCache(cacheName);
|
||||
if (cache != null) {
|
||||
cache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@SmartReload(ReloadConst.CACHE_SERVICE)
|
||||
public void clearAllCache() {
|
||||
Collection<String> cacheNames = caffeineCacheManager.getCacheNames();
|
||||
for (String name : cacheNames) {
|
||||
CaffeineCache cache = (CaffeineCache) caffeineCacheManager.getCache(name);
|
||||
if (cache != null) {
|
||||
cache.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
package net.lab1024.sa.base.module.support.cache;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import jakarta.annotation.Resource;
|
||||
import net.lab1024.sa.base.constant.ReloadConst;
|
||||
import net.lab1024.sa.base.module.support.reload.core.annoation.SmartReload;
|
||||
import org.springframework.cache.caffeine.CaffeineCache;
|
||||
import org.springframework.cache.caffeine.CaffeineCacheManager;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* caffeine 缓存实现
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2021/10/11 20:07
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
public class CaffeineCacheServiceImpl implements CacheService {
|
||||
|
||||
@Resource
|
||||
private CaffeineCacheManager caffeineCacheManager;
|
||||
|
||||
/**
|
||||
* 获取所有缓存名称
|
||||
*/
|
||||
@Override
|
||||
public List<String> cacheNames() {
|
||||
return Lists.newArrayList(caffeineCacheManager.getCacheNames());
|
||||
}
|
||||
|
||||
/**
|
||||
* 某个缓存下的所有 key
|
||||
*/
|
||||
@Override
|
||||
public List<String> cacheKey(String cacheName) {
|
||||
CaffeineCache cache = (CaffeineCache) caffeineCacheManager.getCache(cacheName);
|
||||
if (cache == null) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
Set<Object> cacheKey = cache.getNativeCache().asMap().keySet();
|
||||
return cacheKey.stream().map(e -> e.toString()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除某个 key
|
||||
*/
|
||||
@Override
|
||||
public void removeCache(String cacheName) {
|
||||
CaffeineCache cache = (CaffeineCache) caffeineCacheManager.getCache(cacheName);
|
||||
if (cache != null) {
|
||||
cache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@SmartReload(ReloadConst.CACHE_SERVICE)
|
||||
public void clearAllCache() {
|
||||
Collection<String> cacheNames = caffeineCacheManager.getCacheNames();
|
||||
for (String name : cacheNames) {
|
||||
CaffeineCache cache = (CaffeineCache) caffeineCacheManager.getCache(name);
|
||||
if (cache != null) {
|
||||
cache.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,86 @@
|
||||
package net.lab1024.sa.base.module.support.cache;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import jakarta.annotation.Resource;
|
||||
import net.lab1024.sa.base.constant.ReloadConst;
|
||||
import net.lab1024.sa.base.module.support.reload.core.annoation.SmartReload;
|
||||
import org.springframework.data.redis.cache.RedisCache;
|
||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
import org.springframework.data.redis.connection.RedisConnection;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* redis 缓存实现
|
||||
*
|
||||
* @author zhoumingfa
|
||||
* @date 2025/3/28
|
||||
*/
|
||||
public class RedisCacheServiceImpl implements CacheService {
|
||||
|
||||
@Resource
|
||||
private RedisCacheManager redisCacheManager;
|
||||
|
||||
@Resource
|
||||
private RedisConnectionFactory redisConnectionFactory;
|
||||
|
||||
/**
|
||||
* 获取所有缓存名称
|
||||
*/
|
||||
@Override
|
||||
public List<String> cacheNames() {
|
||||
return Lists.newArrayList(redisCacheManager.getCacheNames());
|
||||
}
|
||||
|
||||
/**
|
||||
* 某个缓存下的所有 key
|
||||
*/
|
||||
@Override
|
||||
public List<String> cacheKey(String cacheName) {
|
||||
RedisCache cache = (RedisCache) redisCacheManager.getCache(cacheName);
|
||||
if (cache == null) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
// 获取 Redis 连接
|
||||
RedisConnection connection = redisConnectionFactory.getConnection();
|
||||
// 根据指定的 key 模式获取所有匹配的键
|
||||
Set<byte[]> keys = connection.keyCommands().keys((cacheName + ":*").getBytes());
|
||||
|
||||
if (keys != null) {
|
||||
return keys.stream().map(key -> {
|
||||
String redisKey = StrUtil.str(key, "utf-8");
|
||||
// 从 Redis 键中提取出最后一个冒号后面的字符串作为真正的键
|
||||
return redisKey.substring(redisKey.lastIndexOf(":") + 1);
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
connection.close();
|
||||
return Lists.newArrayList(cacheName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除某个 key
|
||||
*/
|
||||
@Override
|
||||
public void removeCache(String cacheName) {
|
||||
RedisCache cache = (RedisCache) redisCacheManager.getCache(cacheName);
|
||||
if (cache != null) {
|
||||
cache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@SmartReload(ReloadConst.CACHE_SERVICE)
|
||||
public void clearAllCache() {
|
||||
Collection<String> cacheNames = redisCacheManager.getCacheNames();
|
||||
for (String name : cacheNames) {
|
||||
RedisCache cache = (RedisCache) redisCacheManager.getCache(name);
|
||||
if (cache != null) {
|
||||
cache.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -20,7 +20,6 @@ import org.springframework.stereotype.Component;
|
||||
*/
|
||||
|
||||
@Mapper
|
||||
@Component
|
||||
public interface ChangeLogDao extends BaseMapper<ChangeLogEntity> {
|
||||
|
||||
/**
|
||||
|
@@ -14,7 +14,6 @@ import org.springframework.stereotype.Component;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface CodeGeneratorConfigDao extends BaseMapper<CodeGeneratorConfigEntity> {
|
||||
|
||||
}
|
@@ -18,7 +18,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface CodeGeneratorDao {
|
||||
|
||||
/**
|
||||
|
@@ -159,7 +159,7 @@ public class CodeGeneratorTemplateService {
|
||||
CodeDelete deleteInfo = JSON.parseObject(codeGeneratorConfigEntity.getDeleteInfo(), CodeDelete.class);
|
||||
List<CodeQueryField> queryFields = JSONArray.parseArray(codeGeneratorConfigEntity.getQueryFields(), CodeQueryField.class);
|
||||
List<CodeTableField> tableFields = JSONArray.parseArray(codeGeneratorConfigEntity.getTableFields(), CodeTableField.class);
|
||||
tableFields.stream().forEach(e -> e.setWidth(e.getWidth() == null ? 0 : e.getWidth()));
|
||||
tableFields.forEach(e -> e.setWidth(e.getWidth() == null ? 0 : e.getWidth()));
|
||||
|
||||
CodeGeneratorConfigForm form = CodeGeneratorConfigForm.builder().basic(basic).fields(fields).insertAndUpdate(insertAndUpdate).deleteInfo(deleteInfo).queryFields(queryFields).tableFields(tableFields).deleteInfo(deleteInfo).build();
|
||||
form.setTableName(tableName);
|
||||
|
@@ -64,8 +64,7 @@ public abstract class CodeGenerateBaseVariableService {
|
||||
return null;
|
||||
}
|
||||
|
||||
return fields.stream().filter(e -> columnName.equals(e.getColumnName()))
|
||||
.findFirst().get();
|
||||
return fields.stream().filter(e -> SmartStringUtil.equals(columnName, e.getColumnName())).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +88,7 @@ public abstract class CodeGenerateBaseVariableService {
|
||||
}
|
||||
|
||||
CodeInsertAndUpdateField field = first.get();
|
||||
return SmartStringUtil.equals(field.getFrontComponent(), CodeFrontComponentEnum.FILE_UPLOAD.getValue());
|
||||
return CodeFrontComponentEnum.FILE_UPLOAD.equalsValue(field.getFrontComponent());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,8 +113,7 @@ public abstract class CodeGenerateBaseVariableService {
|
||||
return null;
|
||||
}
|
||||
|
||||
Optional<CodeField> first = fields.stream().filter(e -> columnName.equals(e.getColumnName())).findFirst();
|
||||
return first.orElse(null);
|
||||
return fields.stream().filter(e -> columnName.equals(e.getColumnName())).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -8,7 +8,10 @@ import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeQueryFi
|
||||
import net.lab1024.sa.base.module.support.codegenerator.service.variable.CodeGenerateBaseVariableService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author 1024创新实验室-主任:卓大
|
||||
@@ -39,7 +42,7 @@ public class MapperVariableService extends CodeGenerateBaseVariableService {
|
||||
List<String> columnNameList = queryField.getColumnNameList();
|
||||
if (columnNameList.size() == 1) {
|
||||
// AND INSTR(t_notice.title,#{query.keywords})
|
||||
stringBuilder.append(" AND INSTR(")
|
||||
stringBuilder.append("AND INSTR(")
|
||||
.append(form.getTableName()).append(".").append(queryField.getColumnNameList().get(0))
|
||||
.append(",#{queryForm.")
|
||||
.append(queryField.getFieldName())
|
||||
@@ -47,21 +50,21 @@ public class MapperVariableService extends CodeGenerateBaseVariableService {
|
||||
} else {
|
||||
for (int i = 0; i < columnNameList.size(); i++) {
|
||||
if (i == 0) {
|
||||
stringBuilder.append("AND ( INSTR(")
|
||||
stringBuilder.append("AND (\n INSTR(")
|
||||
.append(form.getTableName()).append(".").append(queryField.getColumnNameList().get(i))
|
||||
.append(",#{queryForm.")
|
||||
.append(queryField.getFieldName())
|
||||
.append("})");
|
||||
} else {
|
||||
// OR INSTR(t_notice.author,#{query.keywords})
|
||||
stringBuilder.append("\n OR INSTR(")
|
||||
stringBuilder.append("\n OR INSTR(")
|
||||
.append(form.getTableName()).append(".").append(queryField.getColumnNameList().get(i))
|
||||
.append(",#{queryForm.")
|
||||
.append(queryField.getFieldName())
|
||||
.append("})");
|
||||
}
|
||||
}
|
||||
stringBuilder.append("\n )");
|
||||
stringBuilder.append("\n )");
|
||||
}
|
||||
fieldMap.put("likeStr", stringBuilder.toString());
|
||||
} else if (CodeQueryFieldQueryTypeEnum.DICT.equalsValue(queryField.getQueryTypeEnum())) {
|
||||
|
@@ -84,14 +84,6 @@ public class VOVariableService extends CodeGenerateBaseVariableService {
|
||||
packageList.add("import io.swagger.v3.oas.annotations.media.Schema;");
|
||||
}
|
||||
|
||||
|
||||
//字典
|
||||
if (isDict(field.getColumnName(), form)) {
|
||||
finalFieldMap.put("dict", "\n @JsonSerialize(using = DictValueVoSerializer.class)");
|
||||
packageList.add("import com.fasterxml.jackson.databind.annotation.JsonSerialize;");
|
||||
packageList.add("import net.lab1024.sa.base.common.json.serializer.DictValueVoSerializer;");
|
||||
}
|
||||
|
||||
//文件上传
|
||||
if (isFile(field.getColumnName(), form)) {
|
||||
finalFieldMap.put("file", "\n @JsonSerialize(using = FileKeyVoSerializer.class)");
|
||||
|
@@ -67,6 +67,7 @@ public class FormVariableService extends CodeGenerateBaseVariableService {
|
||||
|
||||
if (CodeFrontComponentEnum.DICT_SELECT.equalsValue(field.getFrontComponent())) {
|
||||
frontImportSet.add("import DictSelect from '/@/components/support/dict-select/index.vue';");
|
||||
frontImportSet.add("import { DICT_CODE_ENUM } from '/@/constants/support/dict-const.js';");
|
||||
}
|
||||
|
||||
if (CodeFrontComponentEnum.FILE_UPLOAD.equalsValue(field.getFrontComponent())) {
|
||||
|
@@ -2,10 +2,14 @@ package net.lab1024.sa.base.module.support.codegenerator.service.variable.front;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.google.common.base.CaseFormat;
|
||||
import net.lab1024.sa.base.common.util.SmartStringUtil;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.constant.CodeFrontComponentEnum;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.constant.CodeQueryFieldQueryTypeEnum;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.form.CodeGeneratorConfigForm;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeField;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeInsertAndUpdateField;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeQueryField;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.domain.model.CodeTableField;
|
||||
import net.lab1024.sa.base.module.support.codegenerator.service.variable.CodeGenerateBaseVariableService;
|
||||
|
||||
import java.util.*;
|
||||
@@ -29,34 +33,74 @@ public class ListVariableService extends CodeGenerateBaseVariableService {
|
||||
public Map<String, Object> getInjectVariablesMap(CodeGeneratorConfigForm form) {
|
||||
Map<String, Object> variablesMap = new HashMap<>();
|
||||
|
||||
List<Map<String, Object>> variableList = new ArrayList<>();
|
||||
List<CodeQueryField> queryFields = form.getQueryFields();
|
||||
|
||||
HashSet<String> frontImportSet = new HashSet<>();
|
||||
frontImportSet.add("import " + CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_CAMEL, form.getBasic().getModuleName()) + "Form from './" + CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, form.getBasic().getModuleName()) + "-form.vue';");
|
||||
|
||||
// 查询参数
|
||||
List<Map<String, Object>> queryVariable = new ArrayList<>();
|
||||
List<CodeQueryField> queryFields = form.getQueryFields();
|
||||
|
||||
for (CodeQueryField queryField : queryFields) {
|
||||
Map<String, Object> objectMap = BeanUtil.beanToMap(queryField);
|
||||
|
||||
CodeField codeField = getCodeFieldByColumnName(queryField.getColumnNameList().get(0), form);
|
||||
objectMap.put("frontEnumName", codeField.getEnumName());
|
||||
objectMap.put("dict", codeField.getDict());
|
||||
|
||||
if(CodeQueryFieldQueryTypeEnum.ENUM.equalsValue(queryField.getQueryTypeEnum())){
|
||||
if (CodeQueryFieldQueryTypeEnum.ENUM.equalsValue(queryField.getQueryTypeEnum())) {
|
||||
objectMap.put("frontEnumName", codeField.getEnumName());
|
||||
frontImportSet.add("import SmartEnumSelect from '/@/components/framework/smart-enum-select/index.vue';");
|
||||
}
|
||||
|
||||
if(CodeQueryFieldQueryTypeEnum.DICT.equalsValue(queryField.getQueryTypeEnum())){
|
||||
if (CodeQueryFieldQueryTypeEnum.DICT.equalsValue(queryField.getQueryTypeEnum())) {
|
||||
objectMap.put("dict", codeField.getDict());
|
||||
frontImportSet.add("import DictSelect from '/@/components/support/dict-select/index.vue';");
|
||||
}
|
||||
|
||||
if(CodeQueryFieldQueryTypeEnum.DATE_RANGE.equalsValue(queryField.getQueryTypeEnum())){
|
||||
if (CodeQueryFieldQueryTypeEnum.DATE_RANGE.equalsValue(queryField.getQueryTypeEnum())) {
|
||||
frontImportSet.add("import { defaultTimeRanges } from '/@/lib/default-time-ranges';");
|
||||
}
|
||||
variableList.add(objectMap);
|
||||
|
||||
queryVariable.add(objectMap);
|
||||
}
|
||||
variablesMap.put("queryFields",variableList);
|
||||
variablesMap.put("frontImportList",new ArrayList<>(frontImportSet));
|
||||
|
||||
// 表格列表
|
||||
List<Map<String, Object>> listVariable = new ArrayList<>();
|
||||
// 过滤掉不显示的字段
|
||||
List<CodeTableField> tableFields = form.getTableFields().stream().filter(CodeTableField::getShowFlag).toList();
|
||||
|
||||
for (CodeTableField tableField : tableFields) {
|
||||
Map<String, Object> objectMap = BeanUtil.beanToMap(tableField);
|
||||
objectMap.put("fieldName", tableField.getFieldName());
|
||||
|
||||
CodeField codeField = getCodeFieldByColumnName(tableField.getColumnName(), form);
|
||||
if (codeField == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 是否存在字典
|
||||
if (SmartStringUtil.isNotBlank(codeField.getDict())) {
|
||||
objectMap.put("dict", codeField.getDict());
|
||||
frontImportSet.add("import { DICT_CODE_ENUM } from '/@/constants/support/dict-const.js';");
|
||||
frontImportSet.add("import DictLabel from '/@/components/support/dict-label/index.vue';");
|
||||
}
|
||||
|
||||
CodeInsertAndUpdateField codeInsertAndUpdateField = form.getInsertAndUpdate().getFieldList().stream().filter(e -> SmartStringUtil.equals(tableField.getColumnName(), e.getColumnName())).findFirst().orElse(null);
|
||||
if (codeInsertAndUpdateField == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 是否存在上传组件
|
||||
if (CodeFrontComponentEnum.FILE_UPLOAD.equalsValue(codeInsertAndUpdateField.getFrontComponent())) {
|
||||
objectMap.put("frontComponent", codeInsertAndUpdateField.getFrontComponent());
|
||||
frontImportSet.add("import FilePreview from '/@/components/support/file-preview/index.vue';");
|
||||
}
|
||||
|
||||
listVariable.add(objectMap);
|
||||
}
|
||||
|
||||
variablesMap.put("queryFields", queryVariable);
|
||||
variablesMap.put("listFields", listVariable);
|
||||
variablesMap.put("frontImportList", new ArrayList<>(frontImportSet));
|
||||
|
||||
return variablesMap;
|
||||
}
|
||||
}
|
||||
|
@@ -19,7 +19,6 @@ import java.util.List;
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Component
|
||||
@Mapper
|
||||
public interface ConfigDao extends BaseMapper<ConfigEntity> {
|
||||
|
||||
|
@@ -12,11 +12,11 @@ import java.lang.annotation.Target;
|
||||
* @Date 2022-07-23 19:38:52
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface DataTracerFieldDict {
|
||||
|
||||
String keyCode() default "";
|
||||
String dictCode();
|
||||
}
|
||||
|
@@ -21,7 +21,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface DataTracerDao extends BaseMapper<DataTracerEntity> {
|
||||
|
||||
/**
|
||||
|
@@ -16,7 +16,8 @@ import net.lab1024.sa.base.common.util.SmartStringUtil;
|
||||
import net.lab1024.sa.base.module.support.datatracer.annoation.*;
|
||||
import net.lab1024.sa.base.module.support.datatracer.constant.DataTracerConst;
|
||||
import net.lab1024.sa.base.module.support.datatracer.domain.bo.DataTracerContentBO;
|
||||
import net.lab1024.sa.base.module.support.dict.service.DictCacheService;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictDataVO;
|
||||
import net.lab1024.sa.base.module.support.dict.service.DictService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -39,7 +40,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* @Date 2022-07-23 19:38:52
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@@ -48,7 +49,7 @@ public class DataTracerChangeContentService {
|
||||
@Resource
|
||||
private ApplicationContext applicationContext;
|
||||
@Resource
|
||||
private DictCacheService dictCacheService;
|
||||
private DictService dictService;
|
||||
/**
|
||||
* 字段描述缓存
|
||||
*/
|
||||
@@ -64,7 +65,7 @@ public class DataTracerChangeContentService {
|
||||
*
|
||||
* @param oldObjectList 原始对象列表
|
||||
* @param newObjectList 新的对象列表
|
||||
* @param <T> Class类型
|
||||
* @param <T> Class类型
|
||||
* @return 变更内容
|
||||
*/
|
||||
public <T> String getChangeContent(List<T> oldObjectList, List<T> newObjectList) {
|
||||
@@ -143,7 +144,7 @@ public class DataTracerChangeContentService {
|
||||
/**
|
||||
* 单个对象变动内容
|
||||
*
|
||||
* @param oldObjectList 旧的对象列表
|
||||
* @param oldObjectList 旧的对象列表
|
||||
* @param newObjectList 新的对象列表
|
||||
* @return 拼接后的内容
|
||||
*/
|
||||
@@ -163,7 +164,7 @@ public class DataTracerChangeContentService {
|
||||
* 获取一个对象的内容信息
|
||||
*
|
||||
* @param objectList 对象列表
|
||||
* @param <T> 类型
|
||||
* @param <T> 类型
|
||||
* @return 内容
|
||||
*/
|
||||
private <T> String getObjectListContent(List<T> objectList) {
|
||||
@@ -275,7 +276,6 @@ public class DataTracerChangeContentService {
|
||||
|
||||
/**
|
||||
* 获取字段值
|
||||
*
|
||||
*/
|
||||
private DataTracerContentBO getFieldValue(Field field, Object object) {
|
||||
Object fieldValue = "";
|
||||
@@ -303,7 +303,8 @@ public class DataTracerChangeContentService {
|
||||
fieldContent = SmartEnumUtil.getEnumDescByValue(fieldValue, dataTracerFieldEnum.enumClass());
|
||||
}
|
||||
} else if (dataTracerFieldDict != null) {
|
||||
fieldContent = dictCacheService.selectValueNameByValueCodeSplit(dataTracerFieldDict.keyCode(), fieldValue.toString());
|
||||
DictDataVO dictData = dictService.getDictData(dataTracerFieldDict.dictCode(), fieldValue.toString());
|
||||
fieldContent = dictData == null ? fieldValue.toString() : dictData.getDataLabel();
|
||||
} else if (dataTracerFieldSql != null) {
|
||||
fieldContent = this.getRelateDisplayValue(fieldValue, dataTracerFieldSql);
|
||||
} else if (fieldValue instanceof Date) {
|
||||
@@ -330,7 +331,6 @@ public class DataTracerChangeContentService {
|
||||
|
||||
/**
|
||||
* 获取关联字段的显示值
|
||||
*
|
||||
*/
|
||||
private String getRelateDisplayValue(Object fieldValue, DataTracerFieldSql dataTracerFieldSql) {
|
||||
Class<? extends BaseMapper> relateMapper = dataTracerFieldSql.relateMapper();
|
||||
@@ -351,7 +351,6 @@ public class DataTracerChangeContentService {
|
||||
|
||||
/**
|
||||
* 获取字段描述信息 优先 OperateField 没得话swagger判断
|
||||
*
|
||||
*/
|
||||
private String getFieldDesc(Field field) {
|
||||
// 根据字段名称 从缓存中查询
|
||||
@@ -370,7 +369,6 @@ public class DataTracerChangeContentService {
|
||||
|
||||
/**
|
||||
* 获取操作类型
|
||||
*
|
||||
*/
|
||||
private String getOperateType(Object oldObject, Object newObject) {
|
||||
if (oldObject == null && newObject != null) {
|
||||
@@ -384,7 +382,6 @@ public class DataTracerChangeContentService {
|
||||
|
||||
/**
|
||||
* 校验是否进行比对
|
||||
*
|
||||
*/
|
||||
private boolean valid(Object oldObject, Object newObject) {
|
||||
if (oldObject == null && newObject == null) {
|
||||
@@ -404,7 +401,6 @@ public class DataTracerChangeContentService {
|
||||
|
||||
/**
|
||||
* 校验
|
||||
*
|
||||
*/
|
||||
private <T> boolean valid(List<T> oldObjectList, List<T> newObjectList) {
|
||||
if (CollectionUtils.isEmpty(oldObjectList) && CollectionUtils.isEmpty(newObjectList)) {
|
||||
@@ -429,7 +425,6 @@ public class DataTracerChangeContentService {
|
||||
/**
|
||||
* 查询 包含 file key 注解的字段
|
||||
* 使用缓存
|
||||
*
|
||||
*/
|
||||
private List<Field> getField(Object obj) {
|
||||
// 从缓存中查询
|
||||
|
@@ -1,57 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.dict.controller;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import net.lab1024.sa.base.common.controller.SupportBaseController;
|
||||
import net.lab1024.sa.base.common.domain.PageResult;
|
||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||
import net.lab1024.sa.base.constant.SwaggerTagConst;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.form.DictValueQueryForm;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictKeyVO;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictValueVO;
|
||||
import net.lab1024.sa.base.module.support.dict.service.DictCacheService;
|
||||
import net.lab1024.sa.base.module.support.dict.service.DictService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Tag(name = SwaggerTagConst.Support.DICT)
|
||||
@RestController
|
||||
public class DictController extends SupportBaseController {
|
||||
|
||||
@Resource
|
||||
private DictService dictService;
|
||||
@Resource
|
||||
private DictCacheService dictCacheService;
|
||||
|
||||
|
||||
@Operation(summary = "查询全部字典key - @author 卓大")
|
||||
@GetMapping("/dict/key/queryAll")
|
||||
public ResponseDTO<List<DictKeyVO>> queryAll() {
|
||||
return ResponseDTO.ok(dictService.queryAllKey());
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询数据字典value - @author 罗伊")
|
||||
@PostMapping("/dict/value/query")
|
||||
public ResponseDTO<PageResult<DictValueVO>> valueQuery(@Valid @RequestBody DictValueQueryForm queryForm) {
|
||||
return dictService.valueQuery(queryForm);
|
||||
}
|
||||
|
||||
@Operation(summary = "数据字典-值列表- @author 罗伊")
|
||||
@GetMapping("/dict/value/list/{keyCode}")
|
||||
public ResponseDTO<List<DictValueVO>> valueList(@PathVariable String keyCode) {
|
||||
List<DictValueVO> dictValueVOList = dictCacheService.selectByKeyCode(keyCode);
|
||||
return ResponseDTO.ok(dictValueVOList);
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
package net.lab1024.sa.base.module.support.dict.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictEntity;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.form.DictQueryForm;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictVO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 数据字典 Dao
|
||||
*
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 22:25:04
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Mapper
|
||||
@Component
|
||||
public interface DictDao extends BaseMapper<DictEntity> {
|
||||
|
||||
/**
|
||||
* 分页 查询
|
||||
*/
|
||||
List<DictVO> queryPage(Page page, @Param("queryForm") DictQueryForm queryForm);
|
||||
|
||||
/**
|
||||
* 根据 dictCode 去查询
|
||||
*/
|
||||
DictEntity selectByCode(@Param("code") String code);
|
||||
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
package net.lab1024.sa.base.module.support.dict.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictDataEntity;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictDataVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典数据表 Dao
|
||||
*
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 23:12:59
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Mapper
|
||||
@Component
|
||||
public interface DictDataDao extends BaseMapper<DictDataEntity> {
|
||||
|
||||
List<DictDataVO> queryByDictId(@Param("dictId") Long dictId);
|
||||
|
||||
List<DictDataVO> selectByDictDataIds(@Param("dictDataIdList") Collection<Long> dictDataIds);
|
||||
|
||||
DictDataEntity selectByDictIdAndValue(@Param("dictId") Long dictId, @Param("dataValue") String dataValue);
|
||||
|
||||
List<DictDataVO> getAll();
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.dict.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictKeyEntity;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.form.DictKeyQueryForm;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictKeyVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface DictKeyDao extends BaseMapper<DictKeyEntity> {
|
||||
|
||||
/**
|
||||
* 查找所有未删除的自带key
|
||||
*/
|
||||
List<DictKeyEntity> selectByDeletedFlag(@Param("deletedFlag") Boolean deletedFlag);
|
||||
|
||||
/**
|
||||
* 逻辑删除
|
||||
*
|
||||
*/
|
||||
void updateDeletedFlagByIdList(@Param("dictKeyIdList") List<Long> dictKeyIdList, @Param("deletedFlag") Boolean deletedFlag);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
*/
|
||||
List<DictKeyVO> query(Page page, @Param("query") DictKeyQueryForm queryForm);
|
||||
|
||||
/**
|
||||
* 跟进code查询
|
||||
*/
|
||||
DictKeyEntity selectByCode(@Param("keyCode")String keyCode, @Param("deletedFlag") Boolean deletedFlag);
|
||||
}
|
@@ -1,56 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.dict.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictValueEntity;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.form.DictValueQueryForm;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictValueVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface DictValueDao extends BaseMapper<DictValueEntity> {
|
||||
|
||||
/**
|
||||
* 查找所有未删除的自带key
|
||||
*
|
||||
*/
|
||||
List<DictValueEntity> selectByDeletedFlag(@Param("deletedFlag") Boolean deletedFlag);
|
||||
|
||||
/**
|
||||
* 查找所有未删除的自带key
|
||||
*
|
||||
*/
|
||||
List<DictValueEntity> selectByDeletedFlagAndKeyId(@Param("dictKeyId") Long dictKeyId, @Param("deletedFlag") Boolean deletedFlag);
|
||||
|
||||
/**
|
||||
* 逻辑删除
|
||||
*
|
||||
*/
|
||||
void updateDeletedFlagByIdList(@Param("dictValueIdList") List<Long> dictValueIdList, @Param("deletedFlag") Boolean deletedFlag);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
*/
|
||||
List<DictValueVO> query(Page page, @Param("query") DictValueQueryForm queryForm);
|
||||
|
||||
/**
|
||||
* 跟进code查询
|
||||
*
|
||||
*/
|
||||
DictValueEntity selectByCode(@Param("dictKeyId") Long dictKeyId,@Param("valueCode") String valueCode, @Param("deletedFlag") Boolean deletedFlag);
|
||||
}
|
@@ -8,43 +8,52 @@ import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
* 字典数据表 实体类
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 23:12:59
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Data
|
||||
@TableName("t_dict_value")
|
||||
public class DictValueEntity {
|
||||
@TableName("t_dict_data")
|
||||
public class DictDataEntity {
|
||||
|
||||
/**
|
||||
* 字典数据id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long dictValueId;
|
||||
private Long dictDataId;
|
||||
|
||||
private Long dictKeyId;
|
||||
/**
|
||||
* 编码
|
||||
* 字典id
|
||||
*/
|
||||
private String valueCode;
|
||||
private Long dictId;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
* 字典项值
|
||||
*/
|
||||
private String valueName;
|
||||
private String dataValue;
|
||||
|
||||
/**
|
||||
* 字典项显示名称
|
||||
*/
|
||||
private String dataLabel;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
* 排序(越大越靠前)
|
||||
*/
|
||||
private Integer sort;
|
||||
private Integer sortOrder;
|
||||
|
||||
/**
|
||||
* 删除标识
|
||||
* 禁用状态
|
||||
*/
|
||||
private Boolean deletedFlag;
|
||||
private Boolean disabledFlag;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
@@ -55,4 +64,5 @@ public class DictValueEntity {
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
|
||||
}
|
@@ -8,39 +8,42 @@ import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
* 数据字典 实体类
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 22:25:04
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Data
|
||||
@TableName("t_dict_key")
|
||||
public class DictKeyEntity {
|
||||
@TableName("t_dict")
|
||||
public class DictEntity {
|
||||
|
||||
/**
|
||||
* 字典id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long dictKeyId;
|
||||
private Long dictId;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
* 字典名字
|
||||
*/
|
||||
private String keyCode;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String keyName;
|
||||
private String dictName;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
* 字典编码
|
||||
*/
|
||||
private String dictCode;
|
||||
|
||||
/**
|
||||
* 字典备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 删除标识
|
||||
* 禁用状态
|
||||
*/
|
||||
private Boolean deletedFlag;
|
||||
private Boolean disabledFlag;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
@@ -51,4 +54,5 @@ public class DictKeyEntity {
|
||||
* 更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 数据字典 新建表单
|
||||
*
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 22:25:04
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class DictAddForm {
|
||||
|
||||
@Schema(description = "字典名字", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "字典名字 不能为空")
|
||||
private String dictName;
|
||||
|
||||
@Schema(description = "字典编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "字典编码 不能为空")
|
||||
private String dictCode;
|
||||
|
||||
@Schema(description = "字典备注")
|
||||
private String remark;
|
||||
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 字典数据表 新建表单
|
||||
*
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 23:12:59
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class DictDataAddForm {
|
||||
|
||||
@Schema(description = "字典id", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "字典id 不能为空")
|
||||
private Long dictId;
|
||||
|
||||
@Schema(description = "字典项值", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "字典项值 不能为空")
|
||||
private String dataValue;
|
||||
|
||||
@Schema(description = "字典项显示名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "字典项显示名称 不能为空")
|
||||
private String dataLabel;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "排序(越大越靠前)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "排序(越大越靠前) 不能为空")
|
||||
private Integer sortOrder;
|
||||
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* 字典数据表 更新表单
|
||||
*
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 23:12:59
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class DictDataUpdateForm extends DictDataAddForm {
|
||||
|
||||
@Schema(description = "字典数据id", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "字典数据id 不能为空")
|
||||
private Long dictDataId;
|
||||
|
||||
@Schema(description = "字典数据编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "字典数据编码 不能为空")
|
||||
private String dictCode;
|
||||
|
||||
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
public class DictKeyAddForm {
|
||||
|
||||
@Schema(description = "编码")
|
||||
@NotBlank(message = "编码不能为空")
|
||||
@Length(max = 50,message = "编码太长了,不能超过50字符")
|
||||
private String keyCode;
|
||||
|
||||
@Schema(description = "名称")
|
||||
@NotBlank(message = "名称不能为空")
|
||||
@Length(max = 50,message = "名称太长了,不能超过50字符")
|
||||
private String keyName;
|
||||
|
||||
@Schema(description = "备注")
|
||||
@Length(max = 500,message = "备注太长了")
|
||||
private String remark;
|
||||
}
|
@@ -1,24 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import net.lab1024.sa.base.common.domain.PageParam;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
public class DictKeyQueryForm extends PageParam {
|
||||
|
||||
@Schema(description = "搜索词")
|
||||
private String searchWord;
|
||||
|
||||
@Schema(description = "删除标识",hidden = true)
|
||||
private Boolean deletedFlag;
|
||||
}
|
@@ -1,22 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
public class DictKeyUpdateForm extends DictKeyAddForm {
|
||||
|
||||
@Schema(description = "keyId")
|
||||
@NotNull(message = "keyId不能为空")
|
||||
private Long dictKeyId;
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.form;
|
||||
|
||||
import net.lab1024.sa.base.common.domain.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 数据字典 分页查询表单
|
||||
*
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 22:25:04
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class DictQueryForm extends PageParam {
|
||||
|
||||
@Schema(description = "关键字")
|
||||
private String keywords;
|
||||
|
||||
@Schema(description = "禁用状态")
|
||||
private Boolean disabledFlag;
|
||||
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 数据字典 更新表单
|
||||
*
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 22:25:04
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class DictUpdateForm {
|
||||
|
||||
@Schema(description = "字典id", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotNull(message = "字典id 不能为空")
|
||||
private Long dictId;
|
||||
|
||||
@Schema(description = "字典名字", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "字典名字 不能为空")
|
||||
private String dictName;
|
||||
|
||||
@Schema(description = "字典编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "字典编码 不能为空")
|
||||
private String dictCode;
|
||||
|
||||
@Schema(description = "字典备注")
|
||||
private String remark;
|
||||
|
||||
}
|
@@ -1,43 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
public class DictValueAddForm {
|
||||
|
||||
@Schema(description = "dictKeyId")
|
||||
@NotNull(message = "dictKeyId不能为空")
|
||||
private Long dictKeyId;
|
||||
|
||||
@Schema(description = "编码")
|
||||
@NotBlank(message = "编码不能为空")
|
||||
@Length(max = 50,message = "编码太长了,不能超过50字符")
|
||||
private String valueCode;
|
||||
|
||||
@Schema(description = "名称")
|
||||
@NotBlank(message = "名称不能为空")
|
||||
@Length(max = 50,message = "名称太长了,不能超过50字符")
|
||||
private String valueName;
|
||||
|
||||
@Schema(description = "排序")
|
||||
@NotNull(message = "排序不能为空")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "备注")
|
||||
@Length(max = 500,message = "备注太长了")
|
||||
private String remark;
|
||||
|
||||
}
|
@@ -1,29 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import net.lab1024.sa.base.common.domain.PageParam;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
public class DictValueQueryForm extends PageParam {
|
||||
|
||||
@Schema(description = "dictKeyId")
|
||||
@NotNull(message = "dictKeyId不能为空")
|
||||
private Long dictKeyId;
|
||||
|
||||
@Schema(description = "搜索词")
|
||||
private String searchWord;
|
||||
|
||||
@Schema(description = "删除标识",hidden = true)
|
||||
private Boolean deletedFlag;
|
||||
}
|
@@ -1,22 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.form;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
public class DictValueUpdateForm extends DictValueAddForm {
|
||||
|
||||
@Schema(description = "valueId")
|
||||
@NotNull(message = "valueId不能为空")
|
||||
private Long dictValueId;
|
||||
}
|
@@ -0,0 +1,49 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 字典数据表 列表VO
|
||||
*
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 23:12:59
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class DictDataVO {
|
||||
|
||||
@Schema(description = "字典数据id")
|
||||
private Long dictDataId;
|
||||
|
||||
@Schema(description = "字典id")
|
||||
private Long dictId;
|
||||
|
||||
@Schema(description = "字典编码")
|
||||
private String dictCode;
|
||||
|
||||
@Schema(description = "字典项值")
|
||||
private String dataValue;
|
||||
|
||||
@Schema(description = "字典项显示名称")
|
||||
private String dataLabel;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "排序(越大越靠前)")
|
||||
private Integer sortOrder;
|
||||
|
||||
@Schema(description = "禁用状态")
|
||||
private Boolean disabledFlag;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
@@ -1,29 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
public class DictKeyVO {
|
||||
|
||||
@Schema(description = "dictKeyId")
|
||||
private Long dictKeyId;
|
||||
|
||||
@Schema(description = "编码")
|
||||
private String keyCode;
|
||||
|
||||
@Schema(description = "名称")
|
||||
private String keyName;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 数据字典 列表VO
|
||||
*
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 22:25:04
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class DictVO {
|
||||
|
||||
@Schema(description = "字典id")
|
||||
private Long dictId;
|
||||
|
||||
@Schema(description = "字典名字")
|
||||
private String dictName;
|
||||
|
||||
@Schema(description = "字典编码")
|
||||
private String dictCode;
|
||||
|
||||
@Schema(description = "字典备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "禁用状态")
|
||||
private Integer disabledFlag;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.dict.domain.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 字典
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Data
|
||||
public class DictValueVO {
|
||||
|
||||
@Schema(description = "valueId")
|
||||
private Long dictValueId;
|
||||
|
||||
@Schema(description = "dictKeyId")
|
||||
private Long dictKeyId;
|
||||
|
||||
@Schema(description = "编码")
|
||||
private String valueCode;
|
||||
|
||||
@Schema(description = "名称")
|
||||
private String valueName;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
package net.lab1024.sa.base.module.support.dict.manager;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
||||
import net.lab1024.sa.base.constant.CacheKeyConst;
|
||||
import net.lab1024.sa.base.module.support.dict.dao.DictDao;
|
||||
import net.lab1024.sa.base.module.support.dict.dao.DictDataDao;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictDataEntity;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictEntity;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictDataVO;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* 数据字典 缓存
|
||||
*
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 22:25:04
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class DictManager {
|
||||
|
||||
@Resource
|
||||
private DictDao dictDao;
|
||||
|
||||
@Resource
|
||||
private DictDataDao dictDataDao;
|
||||
|
||||
|
||||
/**
|
||||
* 获取字典
|
||||
*/
|
||||
@Cacheable(value = CacheKeyConst.Dict.DICT_DATA, key = "#dictCode + '_' + #dataValue")
|
||||
public DictDataVO getDictData(String dictCode, String dataValue) {
|
||||
DictEntity dictEntity = dictDao.selectByCode(dictCode);
|
||||
if (dictEntity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
DictDataEntity dictDataEntity = dictDataDao.selectByDictIdAndValue(dictEntity.getDictId(), dataValue);
|
||||
return SmartBeanUtil.copy(dictDataEntity, DictDataVO.class);
|
||||
}
|
||||
|
||||
}
|
@@ -1,135 +0,0 @@
|
||||
package net.lab1024.sa.base.module.support.dict.service;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
||||
import net.lab1024.sa.base.module.support.dict.dao.DictKeyDao;
|
||||
import net.lab1024.sa.base.module.support.dict.dao.DictValueDao;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictKeyEntity;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictValueEntity;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictValueVO;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 字典缓存 服务
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DictCacheService {
|
||||
|
||||
@Resource
|
||||
private DictKeyDao dictKeyDao;
|
||||
@Resource
|
||||
private DictValueDao dictValueDao;
|
||||
|
||||
private ConcurrentHashMap<String, List<DictValueVO>> DICT_CACHE = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void dictCache() {
|
||||
this.cacheInit();
|
||||
}
|
||||
|
||||
public void cacheInit() {
|
||||
List<DictKeyEntity> dictKeyEntityList = dictKeyDao.selectByDeletedFlag(false);
|
||||
if (CollectionUtils.isEmpty(dictKeyEntityList)) {
|
||||
return;
|
||||
}
|
||||
List<DictValueEntity> dictKeyValueList = dictValueDao.selectByDeletedFlag(false);
|
||||
List<DictValueVO> dictValueVOList = SmartBeanUtil.copyList(dictKeyValueList, DictValueVO.class);
|
||||
Map<Long, List<DictValueVO>> valueListMap = dictValueVOList.stream().collect(Collectors.groupingBy(DictValueVO::getDictKeyId));
|
||||
//字典键值对缓存
|
||||
for (DictKeyEntity dictKeyEntity : dictKeyEntityList) {
|
||||
String keyCode = dictKeyEntity.getKeyCode();
|
||||
Long dictKeyId = dictKeyEntity.getDictKeyId();
|
||||
DICT_CACHE.put(keyCode, valueListMap.getOrDefault(dictKeyId, Lists.newArrayList()));
|
||||
}
|
||||
log.info("################# 数据字典缓存初始化完毕 ###################");
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新缓存
|
||||
*/
|
||||
public ResponseDTO<String> cacheRefresh() {
|
||||
DICT_CACHE.clear();
|
||||
this.cacheInit();
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询某个key对应的字典值列表
|
||||
*
|
||||
* @param keyCode
|
||||
* @return
|
||||
*/
|
||||
public List<DictValueVO> selectByKeyCode(String keyCode) {
|
||||
return DICT_CACHE.getOrDefault(keyCode, Lists.newArrayList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询值code名称
|
||||
* @param keyCode
|
||||
* @param valueCode
|
||||
* @return
|
||||
*/
|
||||
public String selectValueNameByValueCode(String keyCode, String valueCode) {
|
||||
DictValueVO dictValueVO = this.selectValueByValueCode(keyCode, valueCode);
|
||||
if (dictValueVO == null){
|
||||
return "";
|
||||
}
|
||||
return dictValueVO.getValueName()
|
||||
;
|
||||
}
|
||||
|
||||
public DictValueVO selectValueByValueCode(String keyCode, String valueCode) {
|
||||
if (StrUtil.isEmpty(valueCode)) {
|
||||
return null;
|
||||
}
|
||||
if (StrUtil.isEmpty(keyCode)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<DictValueVO> dictValueVOList = DICT_CACHE.get(valueCode);
|
||||
if (CollectionUtils.isEmpty(dictValueVOList)) {
|
||||
return null;
|
||||
}
|
||||
Optional<DictValueVO> option = dictValueVOList.stream().filter(e->e.getValueCode().equals(valueCode)).findFirst();
|
||||
if(option.isPresent()){
|
||||
return option.get();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public String selectValueNameByValueCodeSplit(String keyCode, String valueCodes) {
|
||||
if (StrUtil.isEmpty(valueCodes)) {
|
||||
return "";
|
||||
}
|
||||
List<String> valueNameList = Lists.newArrayList();
|
||||
String[] valueCodeArray = valueCodes.split(",");
|
||||
for (String valueCode : valueCodeArray) {
|
||||
DictValueVO dictValueVO = this.selectValueByValueCode(keyCode, valueCode);
|
||||
if (dictValueVO != null) {
|
||||
valueNameList.add(dictValueVO.getValueName());
|
||||
}
|
||||
}
|
||||
return StringUtils.join(valueNameList, ",");
|
||||
}
|
||||
|
||||
}
|
@@ -1,196 +1,275 @@
|
||||
package net.lab1024.sa.base.module.support.dict.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.Interner;
|
||||
import com.google.common.collect.Interners;
|
||||
import jakarta.annotation.Resource;
|
||||
import net.lab1024.sa.base.common.code.UserErrorCode;
|
||||
import net.lab1024.sa.base.common.domain.PageResult;
|
||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
||||
import net.lab1024.sa.base.common.util.SmartPageUtil;
|
||||
import net.lab1024.sa.base.module.support.dict.dao.DictKeyDao;
|
||||
import net.lab1024.sa.base.module.support.dict.dao.DictValueDao;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictKeyEntity;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictValueEntity;
|
||||
import net.lab1024.sa.base.common.util.SmartStringUtil;
|
||||
import net.lab1024.sa.base.constant.CacheKeyConst;
|
||||
import net.lab1024.sa.base.module.support.dict.dao.DictDao;
|
||||
import net.lab1024.sa.base.module.support.dict.dao.DictDataDao;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictDataEntity;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictEntity;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.form.*;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictKeyVO;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictValueVO;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictDataVO;
|
||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictVO;
|
||||
import net.lab1024.sa.base.module.support.dict.manager.DictManager;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 字典 服务
|
||||
* 数据字典 Service
|
||||
*
|
||||
* @Author 1024创新实验室: 罗伊
|
||||
* @Date 2022/5/26 19:40:55
|
||||
* @Wechat zhuoda1024
|
||||
* @Email lab1024@163.com
|
||||
* @Author 1024创新实验室-主任-卓大
|
||||
* @Date 2025-03-25 22:25:04
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
|
||||
@Service
|
||||
public class DictService {
|
||||
|
||||
@Resource
|
||||
private DictKeyDao dictKeyDao;
|
||||
private DictDao dictDao;
|
||||
|
||||
@Resource
|
||||
private DictValueDao dictValueDao;
|
||||
private DictDataDao dictDataDao;
|
||||
|
||||
@Resource
|
||||
private DictCacheService dictCacheService;
|
||||
private CacheManager cacheManager;
|
||||
|
||||
@Resource
|
||||
private DictManager dictManager;
|
||||
|
||||
/**
|
||||
* key添加
|
||||
*
|
||||
* @param keyAddForm
|
||||
* @return
|
||||
* 获取全部数据
|
||||
*/
|
||||
public synchronized ResponseDTO<String> keyAdd(DictKeyAddForm keyAddForm) {
|
||||
DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyAddForm.getKeyCode(), false);
|
||||
if (dictKeyEntity != null) {
|
||||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
||||
public List<DictDataVO> getAll() {
|
||||
return dictDataDao.getAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有字典
|
||||
*/
|
||||
public List<DictVO> getAllDict() {
|
||||
List<DictEntity> dictEntityList = dictDao.selectList(null).stream().filter(e -> !e.getDisabledFlag()).collect(Collectors.toList());
|
||||
return SmartBeanUtil.copyList(dictEntityList, DictVO.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
public PageResult<DictVO> queryPage(DictQueryForm queryForm) {
|
||||
Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
|
||||
List<DictVO> list = dictDao.queryPage(page, queryForm);
|
||||
return SmartPageUtil.convert2PageResult(page, list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public synchronized ResponseDTO<String> add(DictAddForm addForm) {
|
||||
DictEntity existDictCode = dictDao.selectByCode(addForm.getDictCode());
|
||||
if (null != existDictCode) {
|
||||
return ResponseDTO.userErrorParam("数据字典编码已经存在!");
|
||||
}
|
||||
dictKeyEntity = SmartBeanUtil.copy(keyAddForm, DictKeyEntity.class);
|
||||
dictKeyDao.insert(dictKeyEntity);
|
||||
//刷新缓存
|
||||
dictCacheService.cacheRefresh();
|
||||
|
||||
DictEntity dictEntity = SmartBeanUtil.copy(addForm, DictEntity.class);
|
||||
dictDao.insert(dictEntity);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 值添加
|
||||
*
|
||||
* @param valueAddForm
|
||||
* @return
|
||||
* 禁用 启用
|
||||
*/
|
||||
public synchronized ResponseDTO<String> valueAdd(DictValueAddForm valueAddForm) {
|
||||
DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueAddForm.getDictKeyId(),valueAddForm.getValueCode(), false);
|
||||
if (dictValueEntity != null) {
|
||||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
||||
public ResponseDTO<String> updateDisabled(Long dictId) {
|
||||
DictEntity dictEntity = dictDao.selectById(dictId);
|
||||
if (dictEntity == null) {
|
||||
return ResponseDTO.userErrorParam("数据不存在");
|
||||
}
|
||||
dictValueEntity = SmartBeanUtil.copy(valueAddForm, DictValueEntity.class);
|
||||
dictValueDao.insert(dictValueEntity);
|
||||
//刷新缓存
|
||||
dictCacheService.cacheRefresh();
|
||||
|
||||
dictEntity.setDisabledFlag(!dictEntity.getDisabledFlag());
|
||||
dictDao.updateById(dictEntity);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* key 编辑
|
||||
*
|
||||
* @param keyUpdateForm
|
||||
* @return
|
||||
* 更新
|
||||
*/
|
||||
public synchronized ResponseDTO<String> keyEdit(DictKeyUpdateForm keyUpdateForm) {
|
||||
DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyUpdateForm.getKeyCode(), false);
|
||||
if (dictKeyEntity != null && !dictKeyEntity.getDictKeyId().equals(keyUpdateForm.getDictKeyId())) {
|
||||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
||||
@CacheEvict(CacheKeyConst.Dict.DICT_DATA)
|
||||
public synchronized ResponseDTO<String> update(DictUpdateForm updateForm) {
|
||||
DictEntity existDictCode = dictDao.selectByCode(updateForm.getDictCode());
|
||||
if (null != existDictCode && !existDictCode.getDictId().equals(updateForm.getDictId())) {
|
||||
return ResponseDTO.userErrorParam("数据字典编码已经存在!");
|
||||
}
|
||||
DictKeyEntity dictKeyUpdateEntity = SmartBeanUtil.copy(keyUpdateForm, DictKeyEntity.class);
|
||||
dictKeyDao.updateById(dictKeyUpdateEntity);
|
||||
//刷新缓存
|
||||
dictCacheService.cacheRefresh();
|
||||
|
||||
DictEntity dictEntity = SmartBeanUtil.copy(updateForm, DictEntity.class);
|
||||
dictDao.updateById(dictEntity);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 值编辑
|
||||
*
|
||||
* @param valueUpdateForm
|
||||
* @return
|
||||
* 批量删除
|
||||
*/
|
||||
public synchronized ResponseDTO<String> valueEdit(DictValueUpdateForm valueUpdateForm) {
|
||||
DictKeyEntity dictKeyEntity = dictKeyDao.selectById(valueUpdateForm.getDictKeyId());
|
||||
if (dictKeyEntity == null || dictKeyEntity.getDeletedFlag()) {
|
||||
return ResponseDTO.userErrorParam("key不能存在");
|
||||
}
|
||||
DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueUpdateForm.getDictKeyId(),valueUpdateForm.getValueCode(), false);
|
||||
if (dictValueEntity != null && !dictValueEntity.getDictValueId().equals(valueUpdateForm.getDictValueId())) {
|
||||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
||||
}
|
||||
DictValueEntity dictValueUpdateEntity = SmartBeanUtil.copy(valueUpdateForm, DictValueEntity.class);
|
||||
dictValueDao.updateById(dictValueUpdateEntity);
|
||||
//刷新缓存
|
||||
dictCacheService.cacheRefresh();
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* key删除
|
||||
*
|
||||
* @param keyIdList
|
||||
* @return
|
||||
*/
|
||||
public synchronized ResponseDTO<String> keyDelete(List<Long> keyIdList) {
|
||||
if (CollectionUtils.isEmpty(keyIdList)) {
|
||||
@CacheEvict(CacheKeyConst.Dict.DICT_DATA)
|
||||
public synchronized ResponseDTO<String> batchDelete(List<Long> idList) {
|
||||
if (CollectionUtils.isEmpty(idList)) {
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
dictKeyDao.updateDeletedFlagByIdList(keyIdList, true);
|
||||
//刷新缓存
|
||||
dictCacheService.cacheRefresh();
|
||||
|
||||
dictDao.deleteBatchIds(idList);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 值删除
|
||||
*
|
||||
* @param valueIdList
|
||||
* @return
|
||||
* 单个删除
|
||||
*/
|
||||
public synchronized ResponseDTO<String> valueDelete(List<Long> valueIdList) {
|
||||
if (CollectionUtils.isEmpty(valueIdList)) {
|
||||
@CacheEvict(CacheKeyConst.Dict.DICT_DATA)
|
||||
public synchronized ResponseDTO<String> delete(Long dictId) {
|
||||
if (null == dictId) {
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
dictValueDao.updateDeletedFlagByIdList(valueIdList, true);
|
||||
//刷新缓存
|
||||
dictCacheService.cacheRefresh();
|
||||
|
||||
dictDao.deleteById(dictId);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
|
||||
// -------------- 字典数据 --------------------
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*/
|
||||
public List<DictDataVO> queryDictData(Long dictId) {
|
||||
return dictDataDao.queryByDictId(dictId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典
|
||||
*/
|
||||
|
||||
public DictDataVO getDictData(String dictCode, String dataValue) {
|
||||
return dictManager.getDictData(dictCode, dataValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典Label
|
||||
*/
|
||||
public String getDictDataLabel(String dictCode, String dataValue) {
|
||||
DictDataVO dictData = getDictData(dictCode, dataValue);
|
||||
return dictData == null ? "" : dictData.getDataLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
public synchronized ResponseDTO<String> addDictData(DictDataAddForm addForm) {
|
||||
|
||||
addForm.setDataValue(SmartStringUtil.trim(addForm.getDataValue()));
|
||||
|
||||
DictEntity dictEntity = dictDao.selectById(addForm.getDictId());
|
||||
if (null == dictEntity) {
|
||||
return ResponseDTO.userErrorParam("数据字典不存在");
|
||||
}
|
||||
|
||||
DictDataEntity existData = dictDataDao.selectByDictIdAndValue(addForm.getDictId(), addForm.getDataValue());
|
||||
if (null != existData) {
|
||||
return ResponseDTO.userErrorParam("已存在相同value的数据");
|
||||
}
|
||||
|
||||
DictDataEntity dictDataEntity = SmartBeanUtil.copy(addForm, DictDataEntity.class);
|
||||
dictDataDao.insert(dictDataEntity);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询key
|
||||
*
|
||||
* @param queryForm
|
||||
* @return
|
||||
* 更新
|
||||
*/
|
||||
public ResponseDTO<PageResult<DictKeyVO>> keyQuery(DictKeyQueryForm queryForm) {
|
||||
queryForm.setDeletedFlag(false);
|
||||
Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
|
||||
List<DictKeyVO> list = dictKeyDao.query(page, queryForm);
|
||||
PageResult<DictKeyVO> pageResult = SmartPageUtil.convert2PageResult(page, list);
|
||||
if (pageResult.getEmptyFlag()) {
|
||||
return ResponseDTO.ok(pageResult);
|
||||
@CacheEvict(value = CacheKeyConst.Dict.DICT_DATA, key = "#updateForm.dictCode + '_' + #updateForm.dataValue")
|
||||
public synchronized ResponseDTO<String> updateDictData(DictDataUpdateForm updateForm) {
|
||||
|
||||
updateForm.setDataValue(SmartStringUtil.trim(updateForm.getDataValue()));
|
||||
|
||||
DictEntity dictEntity = dictDao.selectById(updateForm.getDictId());
|
||||
if (null == dictEntity) {
|
||||
return ResponseDTO.userErrorParam("数据字典不存在");
|
||||
}
|
||||
return ResponseDTO.ok(pageResult);
|
||||
|
||||
DictDataEntity existData = dictDataDao.selectByDictIdAndValue(updateForm.getDictId(), updateForm.getDataValue());
|
||||
if (null != existData && !existData.getDictDataId().equals(updateForm.getDictDataId())) {
|
||||
return ResponseDTO.userErrorParam("已存在相同value的数据");
|
||||
}
|
||||
|
||||
DictDataEntity dictDataEntity = SmartBeanUtil.copy(updateForm, DictDataEntity.class);
|
||||
dictDataDao.updateById(dictDataEntity);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 所有key
|
||||
*
|
||||
* @return
|
||||
* 批量删除
|
||||
*/
|
||||
public List<DictKeyVO> queryAllKey() {
|
||||
return SmartBeanUtil.copyList(dictKeyDao.selectByDeletedFlag(false), DictKeyVO.class);
|
||||
public synchronized ResponseDTO<String> batchDeleteDictData(List<Long> idList) {
|
||||
if (CollectionUtils.isEmpty(idList)) {
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
// 清除缓存
|
||||
clearDictDataCache(idList);
|
||||
// 删除
|
||||
dictDataDao.deleteBatchIds(idList);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询值
|
||||
*
|
||||
* @param queryForm
|
||||
* @return
|
||||
* 单个删除
|
||||
*/
|
||||
public ResponseDTO<PageResult<DictValueVO>> valueQuery(DictValueQueryForm queryForm) {
|
||||
queryForm.setDeletedFlag(false);
|
||||
Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
|
||||
List<DictValueVO> list = dictValueDao.query(page, queryForm);
|
||||
PageResult<DictValueVO> pageResult = SmartPageUtil.convert2PageResult(page, list);
|
||||
if (pageResult.getEmptyFlag()) {
|
||||
return ResponseDTO.ok(pageResult);
|
||||
public synchronized ResponseDTO<String> deleteDictData(Long dictDataId) {
|
||||
if (null == dictDataId) {
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
return ResponseDTO.ok(pageResult);
|
||||
// 清除缓存
|
||||
clearDictDataCache(Collections.singletonList(dictDataId));
|
||||
// 删除
|
||||
dictDataDao.deleteById(dictDataId);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* 清空字典数据缓存
|
||||
*/
|
||||
private void clearDictDataCache(List<Long> idList) {
|
||||
List<DictDataVO> dictDataList = dictDataDao.selectByDictDataIds(idList);
|
||||
Cache cache = cacheManager.getCache(CacheKeyConst.Dict.DICT_DATA);
|
||||
if (cache == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (DictDataVO dictDataVO : dictDataList) {
|
||||
cache.evict(dictDataVO.getDictCode() + "_" + dictDataVO.getDataValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新启用/禁用
|
||||
*/
|
||||
public synchronized ResponseDTO<String> updateDictDataDisabled(Long dictDataId) {
|
||||
DictDataEntity dictDataEntity = dictDataDao.selectById(dictDataId);
|
||||
if (dictDataEntity == null) {
|
||||
return ResponseDTO.userErrorParam("数据不存在");
|
||||
}
|
||||
|
||||
dictDataEntity.setDisabledFlag(!dictDataEntity.getDisabledFlag());
|
||||
dictDataDao.updateById(dictDataEntity);
|
||||
return ResponseDTO.ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -21,7 +21,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface FeedbackDao extends BaseMapper<FeedbackEntity> {
|
||||
|
||||
/**
|
||||
|
@@ -22,7 +22,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface FileDao extends BaseMapper<FileEntity> {
|
||||
|
||||
/**
|
||||
|
@@ -21,7 +21,6 @@ import java.util.List;
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Component
|
||||
@Mapper
|
||||
public interface HeartBeatRecordDao extends BaseMapper<HeartBeatRecordEntity> {
|
||||
|
||||
|
@@ -15,7 +15,6 @@ import org.springframework.stereotype.Component;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface HelpDocCatalogDao extends BaseMapper<HelpDocCatalogEntity> {
|
||||
|
||||
}
|
||||
|
@@ -25,7 +25,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface HelpDocDao extends BaseMapper<HelpDocEntity> {
|
||||
|
||||
// ================================= 帮助文档【主表 t_help_doc 】 =================================
|
||||
|
@@ -18,7 +18,6 @@ import java.util.List;
|
||||
* @date 2024/6/17 21:30
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface SmartJobDao extends BaseMapper<SmartJobEntity> {
|
||||
|
||||
/**
|
||||
|
@@ -18,7 +18,6 @@ import java.util.List;
|
||||
* @date 2024/6/17 21:30
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface SmartJobLogDao extends BaseMapper<SmartJobLogEntity> {
|
||||
|
||||
/**
|
||||
|
@@ -21,7 +21,6 @@ import java.util.List;
|
||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||
*/
|
||||
@Mapper
|
||||
@Component
|
||||
public interface LoginLogDao extends BaseMapper<LoginLogEntity> {
|
||||
|
||||
/**
|
||||
|
@@ -60,6 +60,11 @@ public class LoginLogEntity {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 登录设备
|
||||
*/
|
||||
private String loginDevice;
|
||||
|
||||
/**
|
||||
* 登录类型
|
||||
*/
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user