mirror of
https://gitee.com/lab1024/smart-admin.git
synced 2025-09-22 05:16:39 +08:00
Merge remote-tracking branch 'origin/master'
# Conflicts: # smart-admin-web-javascript/src/views/business/erp/goods/goods-list.vue # smart-admin-web-typescript/src/views/business/erp/goods/goods-list.vue
This commit is contained in:
commit
23c4889723
@ -48,7 +48,7 @@
|
|||||||
<jjwt.version>0.9.1</jjwt.version>
|
<jjwt.version>0.9.1</jjwt.version>
|
||||||
<jwks-rsa.version>0.9.0</jwks-rsa.version>
|
<jwks-rsa.version>0.9.0</jwks-rsa.version>
|
||||||
<velocity-tools.version>3.1</velocity-tools.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>
|
<ip2region.version>2.7.0</ip2region.version>
|
||||||
<bcprov.version>1.80</bcprov.version>
|
<bcprov.version>1.80</bcprov.version>
|
||||||
<jackson-datatype-jsr310.version>2.13.4</jackson-datatype-jsr310.version>
|
<jackson-datatype-jsr310.version>2.13.4</jackson-datatype-jsr310.version>
|
||||||
|
@ -2,9 +2,8 @@ package net.lab1024.sa.admin.interceptor;
|
|||||||
|
|
||||||
import cn.dev33.satoken.annotation.SaIgnore;
|
import cn.dev33.satoken.annotation.SaIgnore;
|
||||||
import cn.dev33.satoken.exception.SaTokenException;
|
import cn.dev33.satoken.exception.SaTokenException;
|
||||||
import cn.dev33.satoken.strategy.SaStrategy;
|
|
||||||
import cn.dev33.satoken.stp.StpUtil;
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.dev33.satoken.strategy.SaAnnotationStrategy;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
@ -84,7 +83,7 @@ public class AdminInterceptor implements HandlerInterceptor {
|
|||||||
// --------------- 第三步: 校验 权限 ---------------
|
// --------------- 第三步: 校验 权限 ---------------
|
||||||
|
|
||||||
SmartRequestUtil.setRequestUser(requestEmployee);
|
SmartRequestUtil.setRequestUser(requestEmployee);
|
||||||
if (SaStrategy.instance.isAnnotationPresent.apply(method, SaIgnore.class)) {
|
if (SaAnnotationStrategy.instance.isAnnotationPresent.apply(method, SaIgnore.class)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +92,7 @@ public class AdminInterceptor implements HandlerInterceptor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SaStrategy.instance.checkMethodAnnotation.accept(method);
|
SaAnnotationStrategy.instance.checkMethodAnnotation.accept(method);
|
||||||
|
|
||||||
} catch (SaTokenException e) {
|
} catch (SaTokenException e) {
|
||||||
/*
|
/*
|
||||||
@ -126,7 +125,6 @@ public class AdminInterceptor implements HandlerInterceptor {
|
|||||||
* 检测:token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结
|
* 检测:token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结
|
||||||
*/
|
*/
|
||||||
private void checkActiveTimeout(RequestEmployee requestEmployee) {
|
private void checkActiveTimeout(RequestEmployee requestEmployee) {
|
||||||
|
|
||||||
// 用户不在线,也不用检测
|
// 用户不在线,也不用检测
|
||||||
if (requestEmployee == null) {
|
if (requestEmployee == null) {
|
||||||
return;
|
return;
|
||||||
@ -137,12 +135,9 @@ public class AdminInterceptor implements HandlerInterceptor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||||
// 清除上下文
|
// 清除上下文
|
||||||
SmartRequestUtil.remove();
|
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
|
* @Email lab1024@163.com
|
||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Component
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface CategoryDao extends BaseMapper<CategoryEntity> {
|
public interface CategoryDao extends BaseMapper<CategoryEntity> {
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.lab1024.sa.admin.module.business.category.constant.CategoryTypeEnum;
|
import net.lab1024.sa.admin.module.business.category.constant.CategoryTypeEnum;
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@ -23,7 +22,6 @@ import java.time.LocalDateTime;
|
|||||||
@TableName("t_category")
|
@TableName("t_category")
|
||||||
public class CategoryEntity implements Serializable {
|
public class CategoryEntity implements Serializable {
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@TableId(type = IdType.AUTO)
|
@TableId(type = IdType.AUTO)
|
||||||
|
@ -3,7 +3,6 @@ package net.lab1024.sa.admin.module.business.category.domain.vo;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -19,7 +18,6 @@ import java.util.List;
|
|||||||
@Data
|
@Data
|
||||||
public class CategoryTreeVO implements Serializable {
|
public class CategoryTreeVO implements Serializable {
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Schema(description = "类目id")
|
@Schema(description = "类目id")
|
||||||
|
@ -21,7 +21,6 @@ import java.util.List;
|
|||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface GoodsDao extends BaseMapper<GoodsEntity> {
|
public interface GoodsDao extends BaseMapper<GoodsEntity> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7,7 +7,7 @@ import jakarta.validation.constraints.NotBlank;
|
|||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.lab1024.sa.admin.module.business.goods.constant.GoodsStatusEnum;
|
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.swagger.SchemaEnum;
|
||||||
import net.lab1024.sa.base.common.validator.enumeration.CheckEnum;
|
import net.lab1024.sa.base.common.validator.enumeration.CheckEnum;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ public class GoodsAddForm {
|
|||||||
|
|
||||||
@Schema(description = "产地")
|
@Schema(description = "产地")
|
||||||
@NotBlank(message = "产地 不能为空 ")
|
@NotBlank(message = "产地 不能为空 ")
|
||||||
@JsonDeserialize(using = DictValueVoDeserializer.class)
|
@JsonDeserialize(using = DictDataDeserializer.class)
|
||||||
private String place;
|
private String place;
|
||||||
|
|
||||||
@Schema(description = "商品价格")
|
@Schema(description = "商品价格")
|
||||||
|
@ -5,7 +5,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.lab1024.sa.admin.module.business.goods.constant.GoodsStatusEnum;
|
import net.lab1024.sa.admin.module.business.goods.constant.GoodsStatusEnum;
|
||||||
import net.lab1024.sa.base.common.domain.PageParam;
|
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.swagger.SchemaEnum;
|
||||||
import net.lab1024.sa.base.common.validator.enumeration.CheckEnum;
|
import net.lab1024.sa.base.common.validator.enumeration.CheckEnum;
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
@ -34,7 +34,7 @@ public class GoodsQueryForm extends PageParam {
|
|||||||
private Integer goodsStatus;
|
private Integer goodsStatus;
|
||||||
|
|
||||||
@Schema(description = "产地")
|
@Schema(description = "产地")
|
||||||
@JsonDeserialize(using = DictValueVoDeserializer.class)
|
@JsonDeserialize(using = DictDataDeserializer.class)
|
||||||
private String place;
|
private String place;
|
||||||
|
|
||||||
@Schema(description = "上架状态")
|
@Schema(description = "上架状态")
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.lab1024.sa.admin.module.business.goods.domain.vo;
|
package net.lab1024.sa.admin.module.business.goods.domain.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.lab1024.sa.admin.module.business.goods.constant.GoodsStatusEnum;
|
import net.lab1024.sa.admin.module.business.goods.constant.GoodsStatusEnum;
|
||||||
|
@ -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.common.util.SmartPageUtil;
|
||||||
import net.lab1024.sa.base.module.support.datatracer.constant.DataTracerTypeEnum;
|
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.datatracer.service.DataTracerService;
|
||||||
import net.lab1024.sa.base.module.support.dict.service.DictCacheService;
|
|
||||||
import net.lab1024.sa.base.module.support.dict.service.DictService;
|
import net.lab1024.sa.base.module.support.dict.service.DictService;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -60,7 +59,7 @@ public class GoodsService {
|
|||||||
private DataTracerService dataTracerService;
|
private DataTracerService dataTracerService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private DictCacheService dictCacheService;
|
private DictService dictService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加商品
|
* 添加商品
|
||||||
@ -194,13 +193,13 @@ public class GoodsService {
|
|||||||
*/
|
*/
|
||||||
public List<GoodsExcelVO> getAllGoods() {
|
public List<GoodsExcelVO> getAllGoods() {
|
||||||
List<GoodsEntity> goodsEntityList = goodsDao.selectList(null);
|
List<GoodsEntity> goodsEntityList = goodsDao.selectList(null);
|
||||||
String keyCode="GODOS_PLACE";
|
String dictCode = "GOODS_PLACE";
|
||||||
return goodsEntityList.stream()
|
return goodsEntityList.stream()
|
||||||
.map(e ->
|
.map(e ->
|
||||||
GoodsExcelVO.builder()
|
GoodsExcelVO.builder()
|
||||||
.goodsStatus(SmartEnumUtil.getEnumDescByValue(e.getGoodsStatus(), GoodsStatusEnum.class))
|
.goodsStatus(SmartEnumUtil.getEnumDescByValue(e.getGoodsStatus(), GoodsStatusEnum.class))
|
||||||
.categoryName(categoryQueryService.queryCategoryName(e.getCategoryId()))
|
.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())
|
.price(e.getPrice())
|
||||||
.goodsName(e.getGoodsName())
|
.goodsName(e.getGoodsName())
|
||||||
.remark(e.getRemark())
|
.remark(e.getRemark())
|
||||||
|
@ -21,7 +21,6 @@ import java.util.List;
|
|||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface BankDao extends BaseMapper<BankEntity> {
|
public interface BankDao extends BaseMapper<BankEntity> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,7 +23,6 @@ import java.util.List;
|
|||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface EnterpriseDao extends BaseMapper<EnterpriseEntity> {
|
public interface EnterpriseDao extends BaseMapper<EnterpriseEntity> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,7 +22,6 @@ import java.util.List;
|
|||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface EnterpriseEmployeeDao extends BaseMapper<EnterpriseEmployeeEntity> {
|
public interface EnterpriseEmployeeDao extends BaseMapper<EnterpriseEmployeeEntity> {
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ import java.util.List;
|
|||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface InvoiceDao extends BaseMapper<InvoiceEntity> {
|
public interface InvoiceDao extends BaseMapper<InvoiceEntity> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +27,6 @@ import java.util.List;
|
|||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface NoticeDao extends BaseMapper<NoticeEntity> {
|
public interface NoticeDao extends BaseMapper<NoticeEntity> {
|
||||||
|
|
||||||
// ================================= 数据范围相关 【子表】 =================================
|
// ================================= 数据范围相关 【子表】 =================================
|
||||||
|
@ -15,7 +15,6 @@ import org.springframework.stereotype.Component;
|
|||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface NoticeTypeDao extends BaseMapper<NoticeTypeEntity> {
|
public interface NoticeTypeDao extends BaseMapper<NoticeTypeEntity> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,6 @@ public class DataScopeSqlConfigService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据调用的方法获取,此方法的配置信息
|
* 根据调用的方法获取,此方法的配置信息
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public DataScopeSqlConfig getSqlConfig(String method) {
|
public DataScopeSqlConfig getSqlConfig(String method) {
|
||||||
return this.dataScopeMethodMap.get(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());
|
log.warn("data scope custom strategy class:{} ,bean is null", sqlConfigDTO.getJoinSqlImplClazz());
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return powerStrategy.getCondition(viewTypeEnum,paramMap, sqlConfigDTO);
|
return powerStrategy.getCondition(viewTypeEnum, paramMap, sqlConfigDTO);
|
||||||
}
|
}
|
||||||
if (DataScopeWhereInTypeEnum.EMPLOYEE == sqlConfigDTO.getDataScopeWhereInType()) {
|
if (DataScopeWhereInTypeEnum.EMPLOYEE == sqlConfigDTO.getDataScopeWhereInType()) {
|
||||||
List<Long> canViewEmployeeIds = dataScopeViewService.getCanViewEmployeeId(viewTypeEnum, employeeId);
|
List<Long> canViewEmployeeIds = dataScopeViewService.getCanViewEmployeeId(viewTypeEnum, employeeId);
|
||||||
|
@ -56,6 +56,7 @@ public class DataScopeViewService {
|
|||||||
if (DataScopeViewTypeEnum.DEPARTMENT_AND_SUB == viewType) {
|
if (DataScopeViewTypeEnum.DEPARTMENT_AND_SUB == viewType) {
|
||||||
return this.getDepartmentAndSubEmployeeIdList(employeeId);
|
return this.getDepartmentAndSubEmployeeIdList(employeeId);
|
||||||
}
|
}
|
||||||
|
// 可以查看所有员工数据
|
||||||
return Lists.newArrayList();
|
return Lists.newArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ import java.util.List;
|
|||||||
* @Email lab1024@163.com
|
* @Email lab1024@163.com
|
||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Component
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface DepartmentDao extends BaseMapper<DepartmentEntity> {
|
public interface DepartmentDao extends BaseMapper<DepartmentEntity> {
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public class DepartmentEntity {
|
|||||||
/**
|
/**
|
||||||
* 负责人员工 id
|
* 负责人员工 id
|
||||||
*/
|
*/
|
||||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||||
private Long managerId;
|
private Long managerId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,7 +3,6 @@ package net.lab1024.sa.admin.module.system.department.domain.vo;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@ -19,7 +18,6 @@ import java.time.LocalDateTime;
|
|||||||
@Data
|
@Data
|
||||||
public class DepartmentVO implements Serializable {
|
public class DepartmentVO implements Serializable {
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Schema(description = "部门id")
|
@Schema(description = "部门id")
|
||||||
|
@ -117,7 +117,7 @@ public class EmployeeController {
|
|||||||
@Operation(summary = "查询员工-根据部门id @author 卓大")
|
@Operation(summary = "查询员工-根据部门id @author 卓大")
|
||||||
@GetMapping("/employee/getAllEmployeeByDepartmentId/{departmentId}")
|
@GetMapping("/employee/getAllEmployeeByDepartmentId/{departmentId}")
|
||||||
public ResponseDTO<List<EmployeeVO>> getAllEmployeeByDepartmentId(@PathVariable Long departmentId) {
|
public ResponseDTO<List<EmployeeVO>> getAllEmployeeByDepartmentId(@PathVariable Long departmentId) {
|
||||||
return employeeService.getAllEmployeeByDepartmentId(departmentId, Boolean.FALSE);
|
return employeeService.getAllEmployeeByDepartmentId(departmentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询所有员工 @author 卓大")
|
@Operation(summary = "查询所有员工 @author 卓大")
|
||||||
|
@ -22,7 +22,6 @@ import java.util.List;
|
|||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface EmployeeDao extends BaseMapper<EmployeeEntity> {
|
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);
|
List<EmployeeVO> selectEmployeeByDisabledAndDeleted(@Param("disabledFlag") Boolean disabledFlag, @Param("deletedFlag") Boolean deletedFlag);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新禁用状态
|
* 更新单个
|
||||||
*/
|
*/
|
||||||
void updateDisableFlag(@Param("employeeId") Long employeeId, @Param("disabledFlag") Boolean disabledFlag);
|
void updateDisableFlag(@Param("employeeId") Long employeeId, @Param("disabledFlag") Boolean disabledFlag);
|
||||||
|
|
||||||
|
@ -239,7 +239,6 @@ public class EmployeeService {
|
|||||||
return ResponseDTO.ok();
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新登录人头像
|
* 更新登录人头像
|
||||||
*
|
*
|
||||||
@ -384,11 +383,8 @@ public class EmployeeService {
|
|||||||
/**
|
/**
|
||||||
* 获取某个部门的员工信息
|
* 获取某个部门的员工信息
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<List<EmployeeVO>> getAllEmployeeByDepartmentId(Long departmentId, Boolean disabledFlag) {
|
public ResponseDTO<List<EmployeeVO>> getAllEmployeeByDepartmentId(Long departmentId) {
|
||||||
List<EmployeeEntity> employeeEntityList = employeeDao.selectByDepartmentId(departmentId, disabledFlag);
|
List<EmployeeEntity> employeeEntityList = employeeDao.selectByDepartmentId(departmentId, Boolean.FALSE);
|
||||||
if (disabledFlag != null) {
|
|
||||||
employeeEntityList = employeeEntityList.stream().filter(e -> e.getDisabledFlag().equals(disabledFlag)).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CollectionUtils.isEmpty(employeeEntityList)) {
|
if (CollectionUtils.isEmpty(employeeEntityList)) {
|
||||||
return ResponseDTO.ok(Collections.emptyList());
|
return ResponseDTO.ok(Collections.emptyList());
|
||||||
@ -429,7 +425,7 @@ public class EmployeeService {
|
|||||||
* 根据登录名获取员工
|
* 根据登录名获取员工
|
||||||
*/
|
*/
|
||||||
public EmployeeEntity getByLoginName(String loginName) {
|
public EmployeeEntity getByLoginName(String loginName) {
|
||||||
return employeeDao.getByLoginName(loginName, null);
|
return employeeDao.getByLoginName(loginName, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ public class LoginController {
|
|||||||
return ResponseDTO.ok(loginResult);
|
return ResponseDTO.ok(loginResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "退出登录 @author 卓大")
|
@Operation(summary = "退出登陆 @author 卓大")
|
||||||
@GetMapping("/login/logout")
|
@GetMapping("/login/logout")
|
||||||
public ResponseDTO<String> logout() {
|
public ResponseDTO<String> logout() {
|
||||||
return loginService.logout(SmartRequestUtil.getRequestUser());
|
return loginService.logout(SmartRequestUtil.getRequestUser());
|
||||||
|
@ -142,7 +142,7 @@ public class LoginService implements StpInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 员工登录
|
* 员工登陆
|
||||||
*
|
*
|
||||||
* @return 返回用户登录信息
|
* @return 返回用户登录信息
|
||||||
*/
|
*/
|
||||||
@ -167,12 +167,12 @@ public class LoginService implements StpInterface {
|
|||||||
|
|
||||||
// 验证账号状态
|
// 验证账号状态
|
||||||
if (employeeEntity.getDeletedFlag()) {
|
if (employeeEntity.getDeletedFlag()) {
|
||||||
saveLoginLog(employeeEntity, ip, userAgent, "账号已删除", LoginLogResultEnum.LOGIN_FAIL);
|
saveLoginLog(employeeEntity, ip, userAgent, "账号已删除", LoginLogResultEnum.LOGIN_FAIL, loginDeviceEnum);
|
||||||
return ResponseDTO.userErrorParam("您的账号已被删除,请联系工作人员!");
|
return ResponseDTO.userErrorParam("您的账号已被删除,请联系工作人员!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (employeeEntity.getDisabledFlag()) {
|
if (employeeEntity.getDisabledFlag()) {
|
||||||
saveLoginLog(employeeEntity, ip, userAgent, "账号已禁用", LoginLogResultEnum.LOGIN_FAIL);
|
saveLoginLog(employeeEntity, ip, userAgent, "账号已禁用", LoginLogResultEnum.LOGIN_FAIL, loginDeviceEnum);
|
||||||
return ResponseDTO.userErrorParam("您的账号已被禁用,请联系工作人员!");
|
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());
|
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);
|
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);
|
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
|
// 设置 token
|
||||||
loginResultVO.setToken(token);
|
loginResultVO.setToken(token);
|
||||||
@ -316,7 +316,7 @@ public class LoginService implements StpInterface {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据登录token 获取员请求工信息
|
* 根据登陆token 获取员请求工信息
|
||||||
*/
|
*/
|
||||||
public RequestEmployee getLoginEmployee(String loginId, HttpServletRequest request) {
|
public RequestEmployee getLoginEmployee(String loginId, HttpServletRequest request) {
|
||||||
if (loginId == null) {
|
if (loginId == null) {
|
||||||
@ -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()
|
LoginLogEntity loginEntity = LoginLogEntity.builder()
|
||||||
.userId(employeeEntity.getEmployeeId())
|
.userId(employeeEntity.getEmployeeId())
|
||||||
.userType(UserTypeEnum.ADMIN_EMPLOYEE.getValue())
|
.userType(UserTypeEnum.ADMIN_EMPLOYEE.getValue())
|
||||||
@ -420,6 +420,7 @@ public class LoginService implements StpInterface {
|
|||||||
.loginIp(ip)
|
.loginIp(ip)
|
||||||
.loginIpRegion(SmartIpUtil.getRegion(ip))
|
.loginIpRegion(SmartIpUtil.getRegion(ip))
|
||||||
.remark(remark)
|
.remark(remark)
|
||||||
|
.loginDevice(loginDeviceEnum.getDesc())
|
||||||
.loginResult(result.getValue())
|
.loginResult(result.getValue())
|
||||||
.createTime(LocalDateTime.now())
|
.createTime(LocalDateTime.now())
|
||||||
.build();
|
.build();
|
||||||
|
@ -19,7 +19,6 @@ import java.util.List;
|
|||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface MenuDao extends BaseMapper<MenuEntity> {
|
public interface MenuDao extends BaseMapper<MenuEntity> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,7 +19,6 @@ import org.springframework.stereotype.Component;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface PositionDao extends BaseMapper<PositionEntity> {
|
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>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface RoleDao extends BaseMapper<RoleEntity> {
|
public interface RoleDao extends BaseMapper<RoleEntity> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,7 +19,6 @@ import java.util.List;
|
|||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface RoleDataScopeDao extends BaseMapper<RoleDataScopeEntity> {
|
public interface RoleDataScopeDao extends BaseMapper<RoleDataScopeEntity> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +25,6 @@ import java.util.Set;
|
|||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface RoleEmployeeDao extends BaseMapper<RoleEmployeeEntity> {
|
public interface RoleEmployeeDao extends BaseMapper<RoleEmployeeEntity> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,7 +19,6 @@ import java.util.List;
|
|||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface RoleMenuDao extends BaseMapper<RoleMenuEntity> {
|
public interface RoleMenuDao extends BaseMapper<RoleMenuEntity> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7,7 +7,7 @@ import jakarta.annotation.Resource;
|
|||||||
import net.lab1024.sa.base.common.controller.SupportBaseController;
|
import net.lab1024.sa.base.common.controller.SupportBaseController;
|
||||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||||
import net.lab1024.sa.base.constant.SwaggerTagConst;
|
import net.lab1024.sa.base.constant.SwaggerTagConst;
|
||||||
import net.lab1024.sa.base.module.support.cache.service.CacheService;
|
import net.lab1024.sa.base.module.support.cache.CacheService;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
@ -8,23 +8,21 @@ import jakarta.validation.Valid;
|
|||||||
import net.lab1024.sa.base.common.controller.SupportBaseController;
|
import net.lab1024.sa.base.common.controller.SupportBaseController;
|
||||||
import net.lab1024.sa.base.common.domain.PageResult;
|
import net.lab1024.sa.base.common.domain.PageResult;
|
||||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
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.constant.SwaggerTagConst;
|
||||||
import net.lab1024.sa.base.module.support.dict.domain.form.*;
|
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.DictDataVO;
|
||||||
import net.lab1024.sa.base.module.support.dict.service.DictCacheService;
|
import net.lab1024.sa.base.module.support.dict.domain.vo.DictVO;
|
||||||
import net.lab1024.sa.base.module.support.dict.service.DictService;
|
import net.lab1024.sa.base.module.support.dict.service.DictService;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典
|
* 数据字典 Controller
|
||||||
*
|
*
|
||||||
* @Author 1024创新实验室: 罗伊
|
* @Author 1024创新实验室-主任-卓大
|
||||||
* @Date 2022/5/26 19:40:55
|
* @Date 2025-03-25 22:25:04
|
||||||
* @Wechat zhuoda1024
|
* @Wechat zhuoda1024
|
||||||
* @Email lab1024@163.com
|
* @Email lab1024@163.com
|
||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
@ -36,60 +34,106 @@ public class AdminDictController extends SupportBaseController {
|
|||||||
@Resource
|
@Resource
|
||||||
private DictService dictService;
|
private DictService dictService;
|
||||||
|
|
||||||
@Resource
|
// ------------------- 获取全部数据 -------------------
|
||||||
private DictCacheService dictCacheService;
|
|
||||||
|
|
||||||
@Operation(summary = "分页查询数据字典KEY - @author 罗伊")
|
@Operation(summary = "获取全部数据(供前端缓存使用) @author 1024创新实验室-主任-卓大")
|
||||||
@PostMapping("/dict/key/query")
|
@GetMapping("/dict/getAllDictData")
|
||||||
public ResponseDTO<PageResult<DictKeyVO>> keyQuery(@Valid @RequestBody DictKeyQueryForm queryForm) {
|
public ResponseDTO<List<DictDataVO>> getAll() {
|
||||||
return dictService.keyQuery(queryForm);
|
return ResponseDTO.ok(dictService.getAll());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取所有字典code @author 1024创新实验室-主任-卓大")
|
||||||
@Operation(summary = "数据字典KEY-添加- @author 罗伊")
|
@GetMapping("/dict/getAllDict")
|
||||||
@PostMapping("/dict/key/add")
|
public ResponseDTO<List<DictVO>> getAllDict() {
|
||||||
@SaCheckPermission("support:dict:add")
|
return ResponseDTO.ok(dictService.getAllDict());
|
||||||
public ResponseDTO<String> keyAdd(@Valid @RequestBody DictKeyAddForm keyAddForm) {
|
|
||||||
return dictService.keyAdd(keyAddForm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "数据字典缓存-刷新- @author 罗伊")
|
// ------------------- 字典 -------------------
|
||||||
@GetMapping("/dict/cache/refresh")
|
|
||||||
@SaCheckPermission("support:dict:refresh")
|
@Operation(summary = "分页查询 @author 1024创新实验室-主任-卓大")
|
||||||
public ResponseDTO<String> cacheRefresh() {
|
@PostMapping("/dict/queryPage")
|
||||||
return dictCacheService.cacheRefresh();
|
@SaCheckPermission("dict:query")
|
||||||
|
public ResponseDTO<PageResult<DictVO>> queryPage(@RequestBody @Valid DictQueryForm queryForm) {
|
||||||
|
return ResponseDTO.ok(dictService.queryPage(queryForm));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "数据字典Value-添加- @author 罗伊")
|
@Operation(summary = "添加 @author 1024创新实验室-主任-卓大")
|
||||||
@PostMapping("/dict/value/add")
|
@PostMapping("/dict/add")
|
||||||
public ResponseDTO<String> valueAdd(@Valid @RequestBody DictValueAddForm valueAddForm) {
|
@SaCheckPermission("dict:add")
|
||||||
return dictService.valueAdd(valueAddForm);
|
public ResponseDTO<String> add(@RequestBody @Valid DictAddForm addForm) {
|
||||||
|
return dictService.add(addForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "数据字典KEY-更新- @author 罗伊")
|
@Operation(summary = "更新 @author 1024创新实验室-主任-卓大")
|
||||||
@PostMapping("/dict/key/edit")
|
@PostMapping("/dict/update")
|
||||||
@SaCheckPermission("support:dict:edit")
|
@SaCheckPermission("dict:update")
|
||||||
public ResponseDTO<String> keyEdit(@Valid @RequestBody DictKeyUpdateForm keyUpdateForm) {
|
public ResponseDTO<String> update(@RequestBody @Valid DictUpdateForm updateForm) {
|
||||||
return dictService.keyEdit(keyUpdateForm);
|
return dictService.update(updateForm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "数据字典Value-更新- @author 罗伊")
|
@Operation(summary = "字典数据 启用/禁用 @author 1024创新实验室-主任-卓大")
|
||||||
@PostMapping("/dict/value/edit")
|
@GetMapping("/dict/updateDisabled/{dictId}")
|
||||||
public ResponseDTO<String> valueEdit(@Valid @RequestBody DictValueUpdateForm valueUpdateForm) {
|
@SaCheckPermission("dictData:updateDisabled")
|
||||||
return dictService.valueEdit(valueUpdateForm);
|
public ResponseDTO<String> updateDisabled(@PathVariable Long dictId) {
|
||||||
|
return dictService.updateDisabled(dictId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "数据字典KEY-删除- @author 罗伊")
|
@Operation(summary = "批量删除 @author 1024创新实验室-主任-卓大")
|
||||||
@PostMapping("/dict/key/delete")
|
@PostMapping("/dict/batchDelete")
|
||||||
@SaCheckPermission("support:dict:delete")
|
@SaCheckPermission("dict:delete")
|
||||||
public ResponseDTO<String> keyDelete(@RequestBody List<Long> keyIdList) {
|
public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
|
||||||
return dictService.keyDelete(keyIdList);
|
return dictService.batchDelete(idList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "数据字典Value-删除- @author 罗伊")
|
@Operation(summary = "单个删除 @author 1024创新实验室-主任-卓大")
|
||||||
@PostMapping("/dict/value/delete")
|
@GetMapping("/dict/delete/{dictId}")
|
||||||
public ResponseDTO<String> valueDelete(@RequestBody List<Long> valueIdList) {
|
@SaCheckPermission("dict:delete")
|
||||||
return dictService.valueDelete(valueIdList);
|
public ResponseDTO<String> batchDelete(@PathVariable Long dictId) {
|
||||||
|
return dictService.delete(dictId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------- 字典数据 -------------------
|
||||||
|
|
||||||
|
@Operation(summary = "字典数据 分页查询 @author 1024创新实验室-主任-卓大")
|
||||||
|
@GetMapping("/dict/dictData/queryDictData/{dictId}")
|
||||||
|
@SaCheckPermission("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("dictData:updateDisabled")
|
||||||
|
public ResponseDTO<String> updateDictDataDisabled(@PathVariable Long dictDataId) {
|
||||||
|
return dictService.updateDictDataDisabled(dictDataId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "字典数据 添加 @author 1024创新实验室-主任-卓大")
|
||||||
|
@PostMapping("/dict/dictData/add")
|
||||||
|
@SaCheckPermission("dictData:add")
|
||||||
|
public ResponseDTO<String> addDictData(@RequestBody @Valid DictDataAddForm addForm) {
|
||||||
|
return dictService.addDictData(addForm);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "字典数据 更新 @author 1024创新实验室-主任-卓大")
|
||||||
|
@PostMapping("/dict/dictData/update")
|
||||||
|
@SaCheckPermission("dictData:update")
|
||||||
|
public ResponseDTO<String> updateDictData(@RequestBody @Valid DictDataUpdateForm updateForm) {
|
||||||
|
return dictService.updateDictData(updateForm);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "字典数据 批量删除 @author 1024创新实验室-主任-卓大")
|
||||||
|
@PostMapping("/dict/dictData/batchDelete")
|
||||||
|
@SaCheckPermission("dictData:delete")
|
||||||
|
public ResponseDTO<String> batchDeleteDictData(@RequestBody ValidateList<Long> idList) {
|
||||||
|
return dictService.batchDeleteDictData(idList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "字典数据 单个删除 @author 1024创新实验室-主任-卓大")
|
||||||
|
@GetMapping("/dict/dictData/delete/{dictDataId}")
|
||||||
|
@SaCheckPermission("dictData:delete")
|
||||||
|
public ResponseDTO<String> deleteDictData(@PathVariable Long dictDataId) {
|
||||||
|
return dictService.deleteDictData(dictDataId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ import java.util.List;
|
|||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class DictValueVoDeserializer extends JsonDeserializer<String> {
|
public class DictDataDeserializer extends JsonDeserializer<String> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
|
public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
|
@ -1,8 +1,8 @@
|
|||||||
package net.lab1024.sa.base.module.support.cache.config;
|
package net.lab1024.sa.base.config;
|
||||||
|
|
||||||
import net.lab1024.sa.base.module.support.cache.service.CacheService;
|
import net.lab1024.sa.base.module.support.cache.CacheService;
|
||||||
import net.lab1024.sa.base.module.support.cache.service.CaffeineCacheServiceImpl;
|
import net.lab1024.sa.base.module.support.cache.CaffeineCacheServiceImpl;
|
||||||
import net.lab1024.sa.base.module.support.cache.service.RedisCacheServiceImpl;
|
import net.lab1024.sa.base.module.support.cache.RedisCacheServiceImpl;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
@ -145,7 +145,7 @@ public class DataSourceConfig {
|
|||||||
if (dataScopePlugin != null) {
|
if (dataScopePlugin != null) {
|
||||||
pluginsList.add(dataScopePlugin);
|
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()));
|
factoryBean.setGlobalConfig(new GlobalConfig().setBanner(false).setMetaObjectHandler(new MybatisPlusFillHandler()));
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ public class RedisConfig {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public RedisTemplate<String, Object> redisTemplate() {
|
public RedisTemplate<String, Object> redisTemplate() {
|
||||||
|
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<Object>(Object.class);
|
||||||
ObjectMapper om = new ObjectMapper();
|
ObjectMapper om = new ObjectMapper();
|
||||||
om.registerModule(new JavaTimeModule())
|
om.registerModule(new JavaTimeModule())
|
||||||
.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false)
|
.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false)
|
||||||
@ -42,11 +43,9 @@ public class RedisConfig {
|
|||||||
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||||
|
|
||||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||||
|
// enableDefaultTyping 官方已弃用 所以改为 activateDefaultTyping
|
||||||
om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL);
|
om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL);
|
||||||
|
jackson2JsonRedisSerializer.setObjectMapper(om);
|
||||||
// 由于在 SpringBoot3 中 jackson2JsonRedisSerializer.setObjectMapper 弃用,所以改为
|
|
||||||
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>(om, Object.class);
|
|
||||||
|
|
||||||
RedisTemplate<String, Object> template = new RedisTemplate<>();
|
RedisTemplate<String, Object> template = new RedisTemplate<>();
|
||||||
template.setConnectionFactory(factory);
|
template.setConnectionFactory(factory);
|
||||||
template.setKeySerializer(new StringRedisSerializer());
|
template.setKeySerializer(new StringRedisSerializer());
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package net.lab1024.sa.base.config;
|
package net.lab1024.sa.base.config;
|
||||||
|
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import net.lab1024.sa.base.common.constant.StringConst;
|
import net.lab1024.sa.base.common.constant.StringConst;
|
||||||
import net.lab1024.sa.base.common.util.SmartRequestUtil;
|
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.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.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.data.redis.core.ValueOperations;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重复提交配置
|
* 重复提交配置
|
||||||
@ -19,9 +21,12 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
@Configuration
|
@Configuration
|
||||||
public class RepeatSubmitConfig {
|
public class RepeatSubmitConfig {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ValueOperations<String, String> valueOperations;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public RepeatSubmitAspect repeatSubmitAspect() {
|
public RepeatSubmitAspect repeatSubmitAspect() {
|
||||||
RepeatSubmitCaffeineTicket caffeineTicket = new RepeatSubmitCaffeineTicket(this::ticket);
|
RepeatSubmitRedisTicket caffeineTicket = new RepeatSubmitRedisTicket(valueOperations, this::ticket);
|
||||||
return new RepeatSubmitAspect(caffeineTicket);
|
return new RepeatSubmitAspect(caffeineTicket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,4 +11,10 @@ package net.lab1024.sa.base.constant;
|
|||||||
*/
|
*/
|
||||||
public class CacheKeyConst {
|
public class CacheKeyConst {
|
||||||
|
|
||||||
|
public static class Dict {
|
||||||
|
|
||||||
|
public static final String DICT_DATA = "dict_data_cache";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.lab1024.sa.base.module.support.apiencrypt.advice;
|
package net.lab1024.sa.base.module.support.apiencrypt.advice;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
@ -1,8 +1,17 @@
|
|||||||
package net.lab1024.sa.base.module.support.cache.cache.service;
|
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 org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缓存服务
|
* 缓存服务
|
@ -1,4 +1,4 @@
|
|||||||
package net.lab1024.sa.base.module.support.cache.service;
|
package net.lab1024.sa.base.module.support.cache;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
@ -1,4 +1,4 @@
|
|||||||
package net.lab1024.sa.base.module.support.cache.service;
|
package net.lab1024.sa.base.module.support.cache;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
@ -20,7 +20,6 @@ import org.springframework.stereotype.Component;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface ChangeLogDao extends BaseMapper<ChangeLogEntity> {
|
public interface ChangeLogDao extends BaseMapper<ChangeLogEntity> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,7 +14,6 @@ import org.springframework.stereotype.Component;
|
|||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface CodeGeneratorConfigDao extends BaseMapper<CodeGeneratorConfigEntity> {
|
public interface CodeGeneratorConfigDao extends BaseMapper<CodeGeneratorConfigEntity> {
|
||||||
|
|
||||||
}
|
}
|
@ -18,7 +18,6 @@ import java.util.List;
|
|||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface CodeGeneratorDao {
|
public interface CodeGeneratorDao {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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 net.lab1024.sa.base.module.support.codegenerator.service.variable.CodeGenerateBaseVariableService;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
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创新实验室-主任:卓大
|
* @Author 1024创新实验室-主任:卓大
|
||||||
@ -39,7 +42,7 @@ public class MapperVariableService extends CodeGenerateBaseVariableService {
|
|||||||
List<String> columnNameList = queryField.getColumnNameList();
|
List<String> columnNameList = queryField.getColumnNameList();
|
||||||
if (columnNameList.size() == 1) {
|
if (columnNameList.size() == 1) {
|
||||||
// AND INSTR(t_notice.title,#{query.keywords})
|
// 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(form.getTableName()).append(".").append(queryField.getColumnNameList().get(0))
|
||||||
.append(",#{queryForm.")
|
.append(",#{queryForm.")
|
||||||
.append(queryField.getFieldName())
|
.append(queryField.getFieldName())
|
||||||
@ -47,7 +50,7 @@ public class MapperVariableService extends CodeGenerateBaseVariableService {
|
|||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < columnNameList.size(); i++) {
|
for (int i = 0; i < columnNameList.size(); i++) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
stringBuilder.append("AND ( INSTR(")
|
stringBuilder.append("AND (\n INSTR(")
|
||||||
.append(form.getTableName()).append(".").append(queryField.getColumnNameList().get(i))
|
.append(form.getTableName()).append(".").append(queryField.getColumnNameList().get(i))
|
||||||
.append(",#{queryForm.")
|
.append(",#{queryForm.")
|
||||||
.append(queryField.getFieldName())
|
.append(queryField.getFieldName())
|
||||||
|
@ -19,7 +19,6 @@ import java.util.List;
|
|||||||
* @Email lab1024@163.com
|
* @Email lab1024@163.com
|
||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Component
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface ConfigDao extends BaseMapper<ConfigEntity> {
|
public interface ConfigDao extends BaseMapper<ConfigEntity> {
|
||||||
|
|
||||||
|
@ -18,5 +18,5 @@ import java.lang.annotation.Target;
|
|||||||
@Target(ElementType.FIELD)
|
@Target(ElementType.FIELD)
|
||||||
public @interface DataTracerFieldDict {
|
public @interface DataTracerFieldDict {
|
||||||
|
|
||||||
String keyCode() default "";
|
String dictCode();
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ import java.util.List;
|
|||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface DataTracerDao extends BaseMapper<DataTracerEntity> {
|
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.annoation.*;
|
||||||
import net.lab1024.sa.base.module.support.datatracer.constant.DataTracerConst;
|
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.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.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
@ -48,7 +49,7 @@ public class DataTracerChangeContentService {
|
|||||||
@Resource
|
@Resource
|
||||||
private ApplicationContext applicationContext;
|
private ApplicationContext applicationContext;
|
||||||
@Resource
|
@Resource
|
||||||
private DictCacheService dictCacheService;
|
private DictService dictService;
|
||||||
/**
|
/**
|
||||||
* 字段描述缓存
|
* 字段描述缓存
|
||||||
*/
|
*/
|
||||||
@ -275,7 +276,6 @@ public class DataTracerChangeContentService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取字段值
|
* 获取字段值
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private DataTracerContentBO getFieldValue(Field field, Object object) {
|
private DataTracerContentBO getFieldValue(Field field, Object object) {
|
||||||
Object fieldValue = "";
|
Object fieldValue = "";
|
||||||
@ -303,7 +303,8 @@ public class DataTracerChangeContentService {
|
|||||||
fieldContent = SmartEnumUtil.getEnumDescByValue(fieldValue, dataTracerFieldEnum.enumClass());
|
fieldContent = SmartEnumUtil.getEnumDescByValue(fieldValue, dataTracerFieldEnum.enumClass());
|
||||||
}
|
}
|
||||||
} else if (dataTracerFieldDict != null) {
|
} 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) {
|
} else if (dataTracerFieldSql != null) {
|
||||||
fieldContent = this.getRelateDisplayValue(fieldValue, dataTracerFieldSql);
|
fieldContent = this.getRelateDisplayValue(fieldValue, dataTracerFieldSql);
|
||||||
} else if (fieldValue instanceof Date) {
|
} else if (fieldValue instanceof Date) {
|
||||||
@ -330,7 +331,6 @@ public class DataTracerChangeContentService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取关联字段的显示值
|
* 获取关联字段的显示值
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private String getRelateDisplayValue(Object fieldValue, DataTracerFieldSql dataTracerFieldSql) {
|
private String getRelateDisplayValue(Object fieldValue, DataTracerFieldSql dataTracerFieldSql) {
|
||||||
Class<? extends BaseMapper> relateMapper = dataTracerFieldSql.relateMapper();
|
Class<? extends BaseMapper> relateMapper = dataTracerFieldSql.relateMapper();
|
||||||
@ -351,7 +351,6 @@ public class DataTracerChangeContentService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取字段描述信息 优先 OperateField 没得话swagger判断
|
* 获取字段描述信息 优先 OperateField 没得话swagger判断
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private String getFieldDesc(Field field) {
|
private String getFieldDesc(Field field) {
|
||||||
// 根据字段名称 从缓存中查询
|
// 根据字段名称 从缓存中查询
|
||||||
@ -370,7 +369,6 @@ public class DataTracerChangeContentService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取操作类型
|
* 获取操作类型
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private String getOperateType(Object oldObject, Object newObject) {
|
private String getOperateType(Object oldObject, Object newObject) {
|
||||||
if (oldObject == null && newObject != null) {
|
if (oldObject == null && newObject != null) {
|
||||||
@ -384,7 +382,6 @@ public class DataTracerChangeContentService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验是否进行比对
|
* 校验是否进行比对
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private boolean valid(Object oldObject, Object newObject) {
|
private boolean valid(Object oldObject, Object newObject) {
|
||||||
if (oldObject == null && newObject == null) {
|
if (oldObject == null && newObject == null) {
|
||||||
@ -404,7 +401,6 @@ public class DataTracerChangeContentService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验
|
* 校验
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private <T> boolean valid(List<T> oldObjectList, List<T> newObjectList) {
|
private <T> boolean valid(List<T> oldObjectList, List<T> newObjectList) {
|
||||||
if (CollectionUtils.isEmpty(oldObjectList) && CollectionUtils.isEmpty(newObjectList)) {
|
if (CollectionUtils.isEmpty(oldObjectList) && CollectionUtils.isEmpty(newObjectList)) {
|
||||||
@ -429,7 +425,6 @@ public class DataTracerChangeContentService {
|
|||||||
/**
|
/**
|
||||||
* 查询 包含 file key 注解的字段
|
* 查询 包含 file key 注解的字段
|
||||||
* 使用缓存
|
* 使用缓存
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private List<Field> getField(Object obj) {
|
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;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典
|
* 字典数据表 实体类
|
||||||
*
|
*
|
||||||
* @Author 1024创新实验室: 罗伊
|
* @Author 1024创新实验室-主任-卓大
|
||||||
* @Date 2022/5/26 19:40:55
|
* @Date 2025-03-25 23:12:59
|
||||||
* @Wechat zhuoda1024
|
|
||||||
* @Email lab1024@163.com
|
|
||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@TableName("t_dict_value")
|
@TableName("t_dict_data")
|
||||||
public class DictValueEntity {
|
public class DictDataEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典数据id
|
||||||
|
*/
|
||||||
@TableId(type = IdType.AUTO)
|
@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 String remark;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 排序
|
* 排序(越大越靠前)
|
||||||
*/
|
*/
|
||||||
private Integer sort;
|
private Integer sortOrder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除标识
|
* 禁用状态
|
||||||
*/
|
*/
|
||||||
private Boolean deletedFlag;
|
private Boolean disabledFlag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
@ -55,4 +64,5 @@ public class DictValueEntity {
|
|||||||
* 更新时间
|
* 更新时间
|
||||||
*/
|
*/
|
||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
}
|
}
|
@ -8,39 +8,42 @@ import lombok.Data;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典
|
* 数据字典 实体类
|
||||||
*
|
*
|
||||||
* @Author 1024创新实验室: 罗伊
|
* @Author 1024创新实验室-主任-卓大
|
||||||
* @Date 2022/5/26 19:40:55
|
* @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>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@TableName("t_dict_key")
|
@TableName("t_dict")
|
||||||
public class DictKeyEntity {
|
public class DictEntity {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典id
|
||||||
|
*/
|
||||||
@TableId(type = IdType.AUTO)
|
@TableId(type = IdType.AUTO)
|
||||||
private Long dictKeyId;
|
private Long dictId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编码
|
* 字典名字
|
||||||
*/
|
*/
|
||||||
private String keyCode;
|
private String dictName;
|
||||||
/**
|
|
||||||
* 名称
|
|
||||||
*/
|
|
||||||
private String keyName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 字典编码
|
||||||
|
*/
|
||||||
|
private String dictCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典备注
|
||||||
*/
|
*/
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除标识
|
* 禁用状态
|
||||||
*/
|
*/
|
||||||
private Boolean deletedFlag;
|
private Boolean disabledFlag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
@ -51,4 +54,5 @@ public class DictKeyEntity {
|
|||||||
* 更新时间
|
* 更新时间
|
||||||
*/
|
*/
|
||||||
private LocalDateTime updateTime;
|
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,133 +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(keyCode);
|
|
||||||
if (CollectionUtils.isEmpty(dictValueVOList)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Optional<DictValueVO> option = dictValueVOList.stream().filter(e->e.getValueCode().equals(valueCode)).findFirst();
|
|
||||||
return option.orElse(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;
|
package net.lab1024.sa.base.module.support.dict.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
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 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.PageResult;
|
||||||
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
import net.lab1024.sa.base.common.domain.ResponseDTO;
|
||||||
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
import net.lab1024.sa.base.common.util.SmartBeanUtil;
|
||||||
import net.lab1024.sa.base.common.util.SmartPageUtil;
|
import net.lab1024.sa.base.common.util.SmartPageUtil;
|
||||||
import net.lab1024.sa.base.module.support.dict.dao.DictKeyDao;
|
import net.lab1024.sa.base.common.util.SmartStringUtil;
|
||||||
import net.lab1024.sa.base.module.support.dict.dao.DictValueDao;
|
import net.lab1024.sa.base.constant.CacheKeyConst;
|
||||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictKeyEntity;
|
import net.lab1024.sa.base.module.support.dict.dao.DictDao;
|
||||||
import net.lab1024.sa.base.module.support.dict.domain.entity.DictValueEntity;
|
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.form.*;
|
||||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictKeyVO;
|
import net.lab1024.sa.base.module.support.dict.domain.vo.DictDataVO;
|
||||||
import net.lab1024.sa.base.module.support.dict.domain.vo.DictValueVO;
|
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.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 org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典 服务
|
* 数据字典 Service
|
||||||
*
|
*
|
||||||
* @Author 1024创新实验室: 罗伊
|
* @Author 1024创新实验室-主任-卓大
|
||||||
* @Date 2022/5/26 19:40:55
|
* @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>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class DictService {
|
public class DictService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private DictKeyDao dictKeyDao;
|
private DictDao dictDao;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private DictValueDao dictValueDao;
|
private DictDataDao dictDataDao;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private DictCacheService dictCacheService;
|
private CacheManager cacheManager;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DictManager dictManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* key添加
|
* 获取全部数据
|
||||||
*
|
|
||||||
* @param keyAddForm
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public synchronized ResponseDTO<String> keyAdd(DictKeyAddForm keyAddForm) {
|
public List<DictDataVO> getAll() {
|
||||||
DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyAddForm.getKeyCode(), false);
|
return dictDataDao.getAll();
|
||||||
if (dictKeyEntity != null) {
|
|
||||||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
|
||||||
}
|
|
||||||
dictKeyEntity = SmartBeanUtil.copy(keyAddForm, DictKeyEntity.class);
|
|
||||||
dictKeyDao.insert(dictKeyEntity);
|
|
||||||
//刷新缓存
|
|
||||||
dictCacheService.cacheRefresh();
|
|
||||||
return ResponseDTO.ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 值添加
|
* 获取所有字典
|
||||||
*
|
|
||||||
* @param valueAddForm
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public synchronized ResponseDTO<String> valueAdd(DictValueAddForm valueAddForm) {
|
public List<DictVO> getAllDict() {
|
||||||
DictValueEntity dictValueEntity = dictValueDao.selectByCode(valueAddForm.getDictKeyId(),valueAddForm.getValueCode(), false);
|
List<DictEntity> dictEntityList = dictDao.selectList(null).stream().filter(e -> !e.getDisabledFlag()).collect(Collectors.toList());
|
||||||
if (dictValueEntity != null) {
|
return SmartBeanUtil.copyList(dictEntityList, DictVO.class);
|
||||||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
|
||||||
}
|
|
||||||
dictValueEntity = SmartBeanUtil.copy(valueAddForm, DictValueEntity.class);
|
|
||||||
dictValueDao.insert(dictValueEntity);
|
|
||||||
//刷新缓存
|
|
||||||
dictCacheService.cacheRefresh();
|
|
||||||
return ResponseDTO.ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* key 编辑
|
* 分页查询
|
||||||
*
|
|
||||||
* @param keyUpdateForm
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public synchronized ResponseDTO<String> keyEdit(DictKeyUpdateForm keyUpdateForm) {
|
public PageResult<DictVO> queryPage(DictQueryForm queryForm) {
|
||||||
DictKeyEntity dictKeyEntity = dictKeyDao.selectByCode(keyUpdateForm.getKeyCode(), false);
|
|
||||||
if (dictKeyEntity != null && !dictKeyEntity.getDictKeyId().equals(keyUpdateForm.getDictKeyId())) {
|
|
||||||
return ResponseDTO.error(UserErrorCode.ALREADY_EXIST);
|
|
||||||
}
|
|
||||||
DictKeyEntity dictKeyUpdateEntity = SmartBeanUtil.copy(keyUpdateForm, DictKeyEntity.class);
|
|
||||||
dictKeyDao.updateById(dictKeyUpdateEntity);
|
|
||||||
//刷新缓存
|
|
||||||
dictCacheService.cacheRefresh();
|
|
||||||
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)) {
|
|
||||||
return ResponseDTO.ok();
|
|
||||||
}
|
|
||||||
dictKeyDao.updateDeletedFlagByIdList(keyIdList, true);
|
|
||||||
//刷新缓存
|
|
||||||
dictCacheService.cacheRefresh();
|
|
||||||
return ResponseDTO.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 值删除
|
|
||||||
*
|
|
||||||
* @param valueIdList
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public synchronized ResponseDTO<String> valueDelete(List<Long> valueIdList) {
|
|
||||||
if (CollectionUtils.isEmpty(valueIdList)) {
|
|
||||||
return ResponseDTO.ok();
|
|
||||||
}
|
|
||||||
dictValueDao.updateDeletedFlagByIdList(valueIdList, true);
|
|
||||||
//刷新缓存
|
|
||||||
dictCacheService.cacheRefresh();
|
|
||||||
return ResponseDTO.ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询key
|
|
||||||
*
|
|
||||||
* @param queryForm
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public ResponseDTO<PageResult<DictKeyVO>> keyQuery(DictKeyQueryForm queryForm) {
|
|
||||||
queryForm.setDeletedFlag(false);
|
|
||||||
Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
|
Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
|
||||||
List<DictKeyVO> list = dictKeyDao.query(page, queryForm);
|
List<DictVO> list = dictDao.queryPage(page, queryForm);
|
||||||
PageResult<DictKeyVO> pageResult = SmartPageUtil.convert2PageResult(page, list);
|
return SmartPageUtil.convert2PageResult(page, list);
|
||||||
if (pageResult.getEmptyFlag()) {
|
|
||||||
return ResponseDTO.ok(pageResult);
|
|
||||||
}
|
|
||||||
return ResponseDTO.ok(pageResult);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 所有key
|
* 添加
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public List<DictKeyVO> queryAllKey() {
|
public synchronized ResponseDTO<String> add(DictAddForm addForm) {
|
||||||
return SmartBeanUtil.copyList(dictKeyDao.selectByDeletedFlag(false), DictKeyVO.class);
|
DictEntity existDictCode = dictDao.selectByCode(addForm.getDictCode());
|
||||||
|
if (null != existDictCode) {
|
||||||
|
return ResponseDTO.userErrorParam("数据字典编码已经存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
DictEntity dictEntity = SmartBeanUtil.copy(addForm, DictEntity.class);
|
||||||
|
dictDao.insert(dictEntity);
|
||||||
|
return ResponseDTO.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询值
|
* 禁用 启用
|
||||||
*
|
|
||||||
* @param queryForm
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public ResponseDTO<PageResult<DictValueVO>> valueQuery(DictValueQueryForm queryForm) {
|
public ResponseDTO<String> updateDisabled(Long dictId) {
|
||||||
queryForm.setDeletedFlag(false);
|
DictEntity dictEntity = dictDao.selectById(dictId);
|
||||||
Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
|
if (dictEntity == null) {
|
||||||
List<DictValueVO> list = dictValueDao.query(page, queryForm);
|
return ResponseDTO.userErrorParam("数据不存在");
|
||||||
PageResult<DictValueVO> pageResult = SmartPageUtil.convert2PageResult(page, list);
|
|
||||||
if (pageResult.getEmptyFlag()) {
|
|
||||||
return ResponseDTO.ok(pageResult);
|
|
||||||
}
|
|
||||||
return ResponseDTO.ok(pageResult);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dictEntity.setDisabledFlag(!dictEntity.getDisabledFlag());
|
||||||
|
dictDao.updateById(dictEntity);
|
||||||
|
return ResponseDTO.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新
|
||||||
|
*/
|
||||||
|
@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("数据字典编码已经存在!");
|
||||||
|
}
|
||||||
|
|
||||||
|
DictEntity dictEntity = SmartBeanUtil.copy(updateForm, DictEntity.class);
|
||||||
|
dictDao.updateById(dictEntity);
|
||||||
|
return ResponseDTO.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除
|
||||||
|
*/
|
||||||
|
@CacheEvict(CacheKeyConst.Dict.DICT_DATA)
|
||||||
|
public synchronized ResponseDTO<String> batchDelete(List<Long> idList) {
|
||||||
|
if (CollectionUtils.isEmpty(idList)) {
|
||||||
|
return ResponseDTO.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
dictDao.deleteBatchIds(idList);
|
||||||
|
return ResponseDTO.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单个删除
|
||||||
|
*/
|
||||||
|
@CacheEvict(CacheKeyConst.Dict.DICT_DATA)
|
||||||
|
public synchronized ResponseDTO<String> delete(Long dictId) {
|
||||||
|
if (null == dictId) {
|
||||||
|
return ResponseDTO.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新
|
||||||
|
*/
|
||||||
|
@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("数据字典不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除
|
||||||
|
*/
|
||||||
|
public synchronized ResponseDTO<String> batchDeleteDictData(List<Long> idList) {
|
||||||
|
if (CollectionUtils.isEmpty(idList)) {
|
||||||
|
return ResponseDTO.ok();
|
||||||
|
}
|
||||||
|
// 清除缓存
|
||||||
|
clearDictDataCache(idList);
|
||||||
|
// 删除
|
||||||
|
dictDataDao.deleteBatchIds(idList);
|
||||||
|
return ResponseDTO.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单个删除
|
||||||
|
*/
|
||||||
|
public synchronized ResponseDTO<String> deleteDictData(Long dictDataId) {
|
||||||
|
if (null == dictDataId) {
|
||||||
|
return ResponseDTO.ok();
|
||||||
|
}
|
||||||
|
// 清除缓存
|
||||||
|
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>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface FeedbackDao extends BaseMapper<FeedbackEntity> {
|
public interface FeedbackDao extends BaseMapper<FeedbackEntity> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,7 +22,6 @@ import java.util.List;
|
|||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface FileDao extends BaseMapper<FileEntity> {
|
public interface FileDao extends BaseMapper<FileEntity> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,7 +21,6 @@ import java.util.List;
|
|||||||
* @Email lab1024@163.com
|
* @Email lab1024@163.com
|
||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Component
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface HeartBeatRecordDao extends BaseMapper<HeartBeatRecordEntity> {
|
public interface HeartBeatRecordDao extends BaseMapper<HeartBeatRecordEntity> {
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ import org.springframework.stereotype.Component;
|
|||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface HelpDocCatalogDao extends BaseMapper<HelpDocCatalogEntity> {
|
public interface HelpDocCatalogDao extends BaseMapper<HelpDocCatalogEntity> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ import java.util.List;
|
|||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface HelpDocDao extends BaseMapper<HelpDocEntity> {
|
public interface HelpDocDao extends BaseMapper<HelpDocEntity> {
|
||||||
|
|
||||||
// ================================= 帮助文档【主表 t_help_doc 】 =================================
|
// ================================= 帮助文档【主表 t_help_doc 】 =================================
|
||||||
|
@ -18,7 +18,6 @@ import java.util.List;
|
|||||||
* @date 2024/6/17 21:30
|
* @date 2024/6/17 21:30
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface SmartJobDao extends BaseMapper<SmartJobEntity> {
|
public interface SmartJobDao extends BaseMapper<SmartJobEntity> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +18,6 @@ import java.util.List;
|
|||||||
* @date 2024/6/17 21:30
|
* @date 2024/6/17 21:30
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface SmartJobLogDao extends BaseMapper<SmartJobLogEntity> {
|
public interface SmartJobLogDao extends BaseMapper<SmartJobLogEntity> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,7 +21,6 @@ import java.util.List;
|
|||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface LoginLogDao extends BaseMapper<LoginLogEntity> {
|
public interface LoginLogDao extends BaseMapper<LoginLogEntity> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,6 +60,11 @@ public class LoginLogEntity {
|
|||||||
*/
|
*/
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录设备
|
||||||
|
*/
|
||||||
|
private String loginDevice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录类型
|
* 登录类型
|
||||||
*/
|
*/
|
||||||
|
@ -46,6 +46,8 @@ public class LoginLogVO {
|
|||||||
@SchemaEnum(LoginLogResultEnum.class)
|
@SchemaEnum(LoginLogResultEnum.class)
|
||||||
private Integer loginResult;
|
private Integer loginResult;
|
||||||
|
|
||||||
|
private String loginDevice;
|
||||||
|
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ import org.springframework.stereotype.Component;
|
|||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a> ,Since 2012
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a> ,Since 2012
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface MailTemplateDao extends BaseMapper<MailTemplateEntity> {
|
public interface MailTemplateDao extends BaseMapper<MailTemplateEntity> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ import java.util.List;
|
|||||||
* @author luoyi
|
* @author luoyi
|
||||||
* @date 2024/06/22 20:20
|
* @date 2024/06/22 20:20
|
||||||
*/
|
*/
|
||||||
@Component
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface MessageDao extends BaseMapper<MessageEntity> {
|
public interface MessageDao extends BaseMapper<MessageEntity> {
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ import java.util.List;
|
|||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface OperateLogDao extends BaseMapper<OperateLogEntity> {
|
public interface OperateLogDao extends BaseMapper<OperateLogEntity> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,7 +17,6 @@ import java.util.List;
|
|||||||
* @Email lab1024@163.com
|
* @Email lab1024@163.com
|
||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Component
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface ReloadItemDao extends BaseMapper<ReloadItemEntity> {
|
public interface ReloadItemDao extends BaseMapper<ReloadItemEntity> {
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ import java.util.List;
|
|||||||
* @Email lab1024@163.com
|
* @Email lab1024@163.com
|
||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Component
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface ReloadResultDao extends BaseMapper<ReloadResultEntity> {
|
public interface ReloadResultDao extends BaseMapper<ReloadResultEntity> {
|
||||||
|
|
||||||
|
@ -28,12 +28,10 @@ import java.lang.reflect.Method;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class RepeatSubmitAspect {
|
public class RepeatSubmitAspect {
|
||||||
|
|
||||||
private AbstractRepeatSubmitTicket repeatSubmitTicket;
|
private final AbstractRepeatSubmitTicket repeatSubmitTicket;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取凭证信息
|
* 获取凭证信息
|
||||||
*
|
|
||||||
* @param repeatSubmitTicket
|
|
||||||
*/
|
*/
|
||||||
public RepeatSubmitAspect(AbstractRepeatSubmitTicket repeatSubmitTicket) {
|
public RepeatSubmitAspect(AbstractRepeatSubmitTicket repeatSubmitTicket) {
|
||||||
this.repeatSubmitTicket = repeatSubmitTicket;
|
this.repeatSubmitTicket = repeatSubmitTicket;
|
||||||
@ -41,10 +39,6 @@ public class RepeatSubmitAspect {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 定义切入点
|
* 定义切入点
|
||||||
*
|
|
||||||
* @param point
|
|
||||||
* @return
|
|
||||||
* @throws Throwable
|
|
||||||
*/
|
*/
|
||||||
@Around("@annotation(net.lab1024.sa.base.module.support.repeatsubmit.annoation.RepeatSubmit)")
|
@Around("@annotation(net.lab1024.sa.base.module.support.repeatsubmit.annoation.RepeatSubmit)")
|
||||||
public Object around(ProceedingJoinPoint point) throws Throwable {
|
public Object around(ProceedingJoinPoint point) throws Throwable {
|
||||||
@ -55,20 +49,24 @@ public class RepeatSubmitAspect {
|
|||||||
if (StringUtils.isEmpty(ticket)) {
|
if (StringUtils.isEmpty(ticket)) {
|
||||||
return point.proceed();
|
return point.proceed();
|
||||||
}
|
}
|
||||||
Long lastRequestTime = this.repeatSubmitTicket.getTicketTimestamp(ticket);
|
|
||||||
if (lastRequestTime != null) {
|
|
||||||
Method method = ((MethodSignature) point.getSignature()).getMethod();
|
Method method = ((MethodSignature) point.getSignature()).getMethod();
|
||||||
RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class);
|
RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class);
|
||||||
int interval = Math.min(annotation.value(), RepeatSubmit.MAX_INTERVAL);
|
int limit = annotation.value();
|
||||||
if (System.currentTimeMillis() < lastRequestTime + interval) {
|
|
||||||
// 提交频繁
|
// 获取上一次请求时间
|
||||||
|
Long lastRequestTime = this.repeatSubmitTicket.getTicketTimestamp(ticket);
|
||||||
|
// 校验是否限制时间内重复提交
|
||||||
|
if (lastRequestTime != null && System.currentTimeMillis() < lastRequestTime + limit) {
|
||||||
return ResponseDTO.error(UserErrorCode.REPEAT_SUBMIT);
|
return ResponseDTO.error(UserErrorCode.REPEAT_SUBMIT);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// 执行
|
||||||
Object obj = null;
|
Object obj = null;
|
||||||
try {
|
try {
|
||||||
// 先给 ticket 设置在执行中
|
// 给 ticket 设置在执行中
|
||||||
this.repeatSubmitTicket.putTicket(ticket);
|
this.repeatSubmitTicket.putTicket(ticket);
|
||||||
|
// 执行
|
||||||
obj = point.proceed();
|
obj = point.proceed();
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
log.error("", throwable);
|
log.error("", throwable);
|
||||||
|
@ -21,13 +21,7 @@ public @interface RepeatSubmit {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 重复提交间隔时间/毫秒
|
* 重复提交间隔时间/毫秒
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
int value() default 300;
|
int value() default 300;
|
||||||
|
|
||||||
/**
|
|
||||||
* 最长间隔30s
|
|
||||||
*/
|
|
||||||
int MAX_INTERVAL = 30000;
|
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import java.util.function.Function;
|
|||||||
*/
|
*/
|
||||||
public abstract class AbstractRepeatSubmitTicket {
|
public abstract class AbstractRepeatSubmitTicket {
|
||||||
|
|
||||||
private Function<String, String> ticketFunction;
|
private final Function<String, String> ticketFunction;
|
||||||
|
|
||||||
|
|
||||||
public AbstractRepeatSubmitTicket(Function<String, String> ticketFunction) {
|
public AbstractRepeatSubmitTicket(Function<String, String> ticketFunction) {
|
||||||
@ -23,9 +23,6 @@ public abstract class AbstractRepeatSubmitTicket {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取凭证
|
* 获取凭证
|
||||||
*
|
|
||||||
* @param ticketToken
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public String getTicket(String ticketToken) {
|
public String getTicket(String ticketToken) {
|
||||||
return this.ticketFunction.apply(ticketToken);
|
return this.ticketFunction.apply(ticketToken);
|
||||||
@ -33,24 +30,13 @@ public abstract class AbstractRepeatSubmitTicket {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取凭证 时间戳
|
* 获取凭证 时间戳
|
||||||
*
|
|
||||||
* @param ticket
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public abstract Long getTicketTimestamp(String ticket);
|
public abstract Long getTicketTimestamp(String ticket);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置本次请求时间
|
* 设置本次请求时间
|
||||||
*
|
|
||||||
* @param ticket
|
|
||||||
*/
|
*/
|
||||||
public abstract void putTicket(String ticket);
|
public abstract void putTicket(String ticket);
|
||||||
|
|
||||||
/**
|
|
||||||
* 移除凭证
|
|
||||||
*
|
|
||||||
* @param ticket
|
|
||||||
*/
|
|
||||||
public abstract void removeTicket(String ticket);
|
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,9 @@ public class RepeatSubmitCaffeineTicket extends AbstractRepeatSubmitTicket {
|
|||||||
* 默认缓存时间
|
* 默认缓存时间
|
||||||
* 初始大小为:100万
|
* 初始大小为:100万
|
||||||
*/
|
*/
|
||||||
private static Cache<String, Long> cache = Caffeine.newBuilder()
|
private static final Cache<String, Long> cache = Caffeine.newBuilder()
|
||||||
.maximumSize(100 * 10000)
|
.maximumSize(100 * 10000)
|
||||||
.expireAfterWrite(RepeatSubmit.MAX_INTERVAL, TimeUnit.MILLISECONDS).build();
|
.expireAfterWrite(300 * 1000L, TimeUnit.MILLISECONDS).build();
|
||||||
|
|
||||||
|
|
||||||
public RepeatSubmitCaffeineTicket(Function<String, String> ticketFunction) {
|
public RepeatSubmitCaffeineTicket(Function<String, String> ticketFunction) {
|
||||||
@ -42,9 +42,4 @@ public class RepeatSubmitCaffeineTicket extends AbstractRepeatSubmitTicket {
|
|||||||
public void putTicket(String ticket) {
|
public void putTicket(String ticket) {
|
||||||
cache.put(ticket, System.currentTimeMillis());
|
cache.put(ticket, System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeTicket(String ticket) {
|
|
||||||
cache.invalidate(ticket);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ import java.util.function.Function;
|
|||||||
*/
|
*/
|
||||||
public class RepeatSubmitRedisTicket extends AbstractRepeatSubmitTicket {
|
public class RepeatSubmitRedisTicket extends AbstractRepeatSubmitTicket {
|
||||||
|
|
||||||
private ValueOperations<String, String> redisValueOperations;
|
private final ValueOperations<String, String> redisValueOperations;
|
||||||
|
|
||||||
public RepeatSubmitRedisTicket(ValueOperations<String, String> redisValueOperations,
|
public RepeatSubmitRedisTicket(ValueOperations<String, String> redisValueOperations,
|
||||||
Function<String, String> ticketFunction) {
|
Function<String, String> ticketFunction) {
|
||||||
@ -27,12 +27,8 @@ public class RepeatSubmitRedisTicket extends AbstractRepeatSubmitTicket {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long getTicketTimestamp(String ticket) {
|
public Long getTicketTimestamp(String ticket) {
|
||||||
Long timeStamp = System.currentTimeMillis();
|
String ticketLastTime = redisValueOperations.get(ticket);
|
||||||
boolean setFlag = redisValueOperations.setIfAbsent(ticket, String.valueOf(timeStamp), RepeatSubmit.MAX_INTERVAL, TimeUnit.MILLISECONDS);
|
return ticketLastTime == null ? null : Long.valueOf(ticketLastTime);
|
||||||
if (!setFlag) {
|
|
||||||
timeStamp = Long.valueOf(redisValueOperations.get(ticket));
|
|
||||||
}
|
|
||||||
return timeStamp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -41,8 +37,4 @@ public class RepeatSubmitRedisTicket extends AbstractRepeatSubmitTicket {
|
|||||||
this.getTicketTimestamp(ticket);
|
this.getTicketTimestamp(ticket);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeTicket(String ticket) {
|
|
||||||
redisValueOperations.getOperations().delete(ticket);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ import java.util.List;
|
|||||||
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
* @Copyright <a href="https://1024lab.net">1024创新实验室</a>
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface LoginFailDao extends BaseMapper<LoginFailEntity> {
|
public interface LoginFailDao extends BaseMapper<LoginFailEntity> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,7 +9,6 @@ import org.springframework.stereotype.Component;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
@Component
|
|
||||||
public interface PasswordLogDao extends BaseMapper<PasswordLogEntity> {
|
public interface PasswordLogDao extends BaseMapper<PasswordLogEntity> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user