Commit 24e7a3f2 authored by fangxinjiang's avatar fangxinjiang

附属信息

parent 07ebe7a2
......@@ -43,7 +43,7 @@ public class TEmpDisabilityInfo extends BaseEntity {
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description ="主键")
private Long id;
private String id;
/**
* 员工ID
......
......@@ -43,7 +43,7 @@ public class TEmpEducation extends BaseEntity {
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description ="主键")
private Long id;
private String id;
/**
* 员工ID
......@@ -123,17 +123,16 @@ public class TEmpEducation extends BaseEntity {
@Schema(description ="是否删除 0未删除/1删除")
private String deleteFlag;
/**
* 结算主体ID
*/
@Schema(description ="结算主体ID")
private String settleDomain;
/**
* 派单标识 1 代表派单生成, 派单审核通过后清空标识 专门用于派单作废
*/
@Schema(description ="派单标识 1 代表派单生成, 派单审核通过后清空标识 专门用于派单作废")
private String dispatchFlag;
/**
* 备注
*/
@Schema(description ="备注")
private String remark;
}
......@@ -43,7 +43,7 @@ public class TEmpFamily extends BaseEntity {
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description ="主键")
private Long id;
private String id;
/**
* 员工主键
......@@ -104,11 +104,10 @@ public class TEmpFamily extends BaseEntity {
*/
@Schema(description ="0删除作废1正常")
private String deleteFlag;
/**
* 结算主体ID
*/
@Schema(description ="结算主体ID")
private String settleDomain;
/**
* 备注
*/
@Schema(description ="备注")
private String remark;
}
......@@ -41,7 +41,7 @@ public class TEmpProfessionalQualification extends BaseEntity {
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description ="主键")
private Long id;
private String id;
/**
* 员工主键
......@@ -114,11 +114,9 @@ public class TEmpProfessionalQualification extends BaseEntity {
*/
@Schema(description ="0删除作废1正常")
private String deleteFlag;
/**
* 结算主体ID
*/
@Schema(description ="结算主体ID")
private String settleDomain;
/**
* 备注
*/
@Schema(description ="备注")
private String remark;
}
......@@ -43,7 +43,7 @@ public class TEmpWorkRecording extends BaseEntity {
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description ="主键")
private Long id;
private String id;
/**
* 员工ID
......@@ -116,11 +116,10 @@ public class TEmpWorkRecording extends BaseEntity {
*/
@Schema(description ="0删除作废1正常")
private String deleteFlag;
/**
* 结算主体ID
*/
@Schema(description ="结算主体ID")
private String settleDomain;
/**
* 备注
*/
@Schema(description ="备注")
private String remark;
}
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 员工伤残excel 对应的实体
*
* @author fxz
* @date 2022/3/21
*/
@Data
@ColumnWidth(30)
public class EmpFamilyExcelVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 员工身份证
*/
@NotNull(message = "员工身份证不可为空")
@ExcelProperty(value ="员工身份证")
private String empIdcard;
/**
* 员工姓名
*/
@NotNull(message = "员工编码不可为空")
@ExcelProperty(value ="员工姓名")
private String empName;
/**
* 与本人关系
*/
@NotNull(message = "与本人关系不可为空")
@ExcelProperty(value ="与本人关系")
private String relationshipSelf;
/**
* 家庭成员姓名
*/
@NotNull(message = "家庭成员姓名不可为空")
@ExcelProperty(value ="家庭成员姓名")
private String familyName;
/**
* 出生日期
*/
@Past
@ExcelProperty(value ="出生日期")
private LocalDateTime birthday;
/**
* 工作/学习单位
*/
@ExcelProperty(value ="工作单位")
private String workUnit;
/**
* 联系电话
*/
@NotNull(message = "联系电话不可为空")
@ExcelProperty(value ="联系电话")
private String contractTel;
/*JSR303 是一套JavaBean参数校验的标准,它定义了很多常用的校验注解,我们可以直接将这些注解加在我们JavaBean的属性上面,就可以在需要校验的时候进行校验了。注解如下:
参考配置
@Null 限制只能为null
@NotNull 限制必须不为null
@AssertFalse 限制必须为false
@AssertTrue 限制必须为true
@DecimalMax(value) 限制必须为一个不大于指定值的数字
@DecimalMin(value) 限制必须为一个不小于指定值的数字
@Digits(integer,fraction) 限制必须为一个小数,且整数部分的位数不能超过integer,小数部分的位数不能超过fraction
@Future 限制必须是一个将来的日期
@Max(value) 限制必须为一个不大于指定值的数字
@Min(value) 限制必须为一个不小于指定值的数字
@Past 限制必须是一个过去的日期
@Pattern(value) 限制必须符合指定的正则表达式
@Size(max,min) 限制字符长度必须在min到max之间
@Past 验证注解的元素值(日期类型)比当前时间早
@NotEmpty 验证注解的元素值不为null且不为空(字符串长度不为0、集合大小不为0)
@NotBlank 验证注解的元素值不为空(不为null、去除首位空格后长度为0),不同于@NotEmpty,@NotBlank只应用于字符串且在比较时会去除字符串的空格
@Email 验证注解的元素值是Email,也可以通过正则表达式和flag指定自定义的email格式*/
}
......@@ -19,8 +19,13 @@ package com.yifu.cloud.plus.v1.yifu.archives.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.plugin.excel.annotation.RequestExcel;
import com.pig4cloud.plugin.excel.vo.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpFamily;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpFamilyService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpDisabilityExcelVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpFamilyExcelVO;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.Operation;
......@@ -29,8 +34,11 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 员工家庭信息表
......@@ -74,7 +82,7 @@ public class TEmpFamilyController {
}
/**
* 新增员工家庭信息表
* 新增员工家庭信息表 // TODO 新增变更档案学历最高学历信息
* @param tEmpFamily 员工家庭信息表
* @return R
*/
......@@ -82,7 +90,11 @@ public class TEmpFamilyController {
@SysLog("新增员工家庭信息表" )
@PostMapping
@PreAuthorize("@pms.hasPermission('archives_tempfamily_add')" )
public R save(@RequestBody TEmpFamily tEmpFamily) {
public R<Boolean> save(@RequestBody TEmpFamily tEmpFamily) {
String checkRes = tEmpFamilyService.checkRepeat(tEmpFamily.getEmpIdcard(),tEmpFamily.getFamilyName(),null);
if (Common.isNotNull(checkRes)){
return R.failed(checkRes);
}
return R.ok(tEmpFamilyService.save(tEmpFamily));
}
......@@ -96,6 +108,10 @@ public class TEmpFamilyController {
@PutMapping
@PreAuthorize("@pms.hasPermission('archives_tempfamily_edit')" )
public R updateById(@RequestBody TEmpFamily tEmpFamily) {
String checkRes = tEmpFamilyService.checkRepeat(tEmpFamily.getEmpIdcard(),tEmpFamily.getFamilyName(),tEmpFamily.getId());
if (Common.isNotNull(checkRes)){
return R.failed(checkRes);
}
return R.ok(tEmpFamilyService.updateById(tEmpFamily));
}
......@@ -112,4 +128,20 @@ public class TEmpFamilyController {
return R.ok(tEmpFamilyService.removeById(id));
}
/**
* 批量新增员工家庭信息
*
* @param excelVOList
* @return
* @Author fxj
* @Date 2019-08-16
**/
@Operation(description = "批量新增员工家庭信息 hasPermission('archives_tempfamily_importListAdd')")
@SysLog("批量新增员工家庭信息")
@PostMapping("/importListAdd")
@PreAuthorize("@pms.hasPermission('archives_tempfamily_importListAdd')")
public R<List<ErrorMessage>> batchAddByJsonString(@RequestExcel List<EmpFamilyExcelVO> excelVOList, BindingResult bindingResult) {
return tEmpFamilyService.importEmpFamilys(excelVOList, bindingResult);
}
}
......@@ -18,7 +18,13 @@
package com.yifu.cloud.plus.v1.yifu.archives.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.pig4cloud.plugin.excel.vo.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpFamily;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpFamilyExcelVO;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import org.springframework.validation.BindingResult;
import java.util.List;
/**
* 员工家庭信息表
......@@ -28,4 +34,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpFamily;
*/
public interface TEmpFamilyService extends IService<TEmpFamily> {
R<List<ErrorMessage>> importEmpFamilys(List<EmpFamilyExcelVO> excelVOList, BindingResult bindingResult);
String checkRepeat(String empIdcard, String familyName, String updateId);
}
......@@ -16,11 +16,35 @@
*/
package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.plugin.excel.vo.ErrorMessage;
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysRole;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpDisabilityInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpFamily;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmpFamilyMapper;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmployeeInfoMapper;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpFamilyService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpDisabilityExcelVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpFamilyExcelVO;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.MsgUtils;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import lombok.RequiredArgsConstructor;
import org.omg.PortableInterceptor.INACTIVE;
import org.springframework.stereotype.Service;
import org.springframework.validation.BindingResult;
import java.util.*;
/**
* 员工家庭信息表
......@@ -28,7 +52,107 @@ import org.springframework.stereotype.Service;
* @author fxj
* @date 2022-06-18 09:39:46
*/
@RequiredArgsConstructor
@Service
public class TEmpFamilyServiceImpl extends ServiceImpl<TEmpFamilyMapper, TEmpFamily> implements TEmpFamilyService {
private final TEmployeeInfoMapper employeeInfoMapper;
/**
* @Author fxj
* @Description 家庭信息 批量导出
* @Date 9:45 2022/6/20
* @Param
* @return
**/
@Override
public R<List<ErrorMessage>> importEmpFamilys(List<EmpFamilyExcelVO> excelVOList, BindingResult bindingResult) {
// 通用校验获取失败的数据
List<ErrorMessage> errorMessageList = (List<ErrorMessage>) bindingResult.getTarget();
Map<Long,ErrorMessage> errorMsgMap = new HashMap<>();
if (Common.isNotNull(errorMessageList)){
errorMessageList.stream().forEach(errorMessage -> errorMsgMap.put(errorMessage.getLineNum(),errorMessage));
}
// 个性化校验逻辑
List<TEmpFamily> list = this.list();
TEmployeeInfo emp;
TEmpFamily exist;
Set<String> errorMsg;
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
// 已有验证报错直接下一个
if (Common.isNotNull(errorMsgMap.get(i+2))){
continue;
}
errorMsg = new HashSet<>();
EmpFamilyExcelVO excel = excelVOList.get(i);
emp = employeeInfoMapper.selectOne(Wrappers.<TEmployeeInfo>query().lambda()
.eq(TEmployeeInfo::getEmpIdcard,excel.getEmpIdcard())
.eq(TEmployeeInfo::getDeleteFlag,CommonConstants.ZERO_STRING)
.last(CommonConstants.LAST_ONE_SQL));
if (Common.isEmpty(emp)){
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_NOT_EXIST, excel.getEmpIdcard()));
}
if (CommonConstants.ONE_STRING.equals(emp.getFileStatus())){
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_REDUCED, excel.getEmpIdcard()));
}
// 检查添加人员是否已经存在
boolean match = list.stream().anyMatch(info -> excel.getFamilyName().equals(info.getFamilyName())
&& excel.getEmpIdcard().equals(info.getEmpIdcard()));
if (match) {
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_FAMILY_NAME_EXISTING, excel.getFamilyName()));
}
exist = baseMapper.selectOne(Wrappers.<TEmpFamily>query().lambda()
.eq(TEmpFamily::getEmpIdcard,excel.getEmpIdcard())
.eq(TEmpFamily::getFamilyName,excel.getFamilyName())
.eq(TEmpFamily::getDeleteFlag,CommonConstants.ZERO_STRING)
.last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(exist)){
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_FAMILY_NAME_EXISTING, excel.getFamilyName()));
}
// 数据合法情况
if (CollUtil.isEmpty(errorMsg)) {
insertExcelPost(excel,emp);
} else {
// 数据不合法
errorMessageList.add(new ErrorMessage((long) (i + 2), errorMsg));
}
}
if (CollUtil.isNotEmpty(errorMessageList)) {
return R.failed(errorMessageList);
}
return R.ok();
}
@Override
public String checkRepeat(String empIdcard, String familyName, String updateId) {
LambdaQueryWrapper<TEmpFamily> wrapper = Wrappers.lambdaQuery();
if (StrUtil.isNotBlank(empIdcard)){
wrapper.eq(TEmpFamily::getEmpIdcard,empIdcard);
}
if (StrUtil.isNotBlank(familyName)){
wrapper.eq(TEmpFamily::getFamilyName,familyName);
}
if (StrUtil.isNotBlank(updateId)){
wrapper.ne(TEmpFamily::getId,updateId);
}
wrapper.last(CommonConstants.LAST_ONE_SQL);
if (Common.isNotNull(baseMapper.selectOne(wrapper))){
return MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_FAMILY_NAME_EXISTING, familyName);
}
return null;
}
/**
* 插入excel Post
*/
private void insertExcelPost(EmpFamilyExcelVO excel,TEmployeeInfo emp) {
TEmpFamily insert = new TEmpFamily();
BeanUtil.copyProperties(excel, insert);
insert.setDeleteFlag(CommonConstants.ZERO_STRING);
insert.setEmpCode(emp.getEmpCode());
insert.setEmpId(emp.getId());
insert.setEmpCode(emp.getEmpCode());
this.save(insert);
}
}
......@@ -36,11 +36,11 @@
<result property="endTime" column="END_TIME"/>
<result property="occupationalDisease" column="OCCUPATIONAL_DISEASE"/>
<result property="deleteFlag" column="DELETE_FLAG"/>
<result property="settleDomain" column="SETTLE_DOMAIN"/>
<result property="createBy" column="CREATE_BY"/>
<result property="updateBy" column="UPDATE_BY"/>
<result property="createName" column="CREATE_NAME"/>
<result property="createTime" column="CREATE_TIME"/>
<result property="updateTime" column="UPDATE_TIME"/>
<result property="remark" column="REMARK"/>
</resultMap>
</mapper>
......@@ -38,12 +38,12 @@
<result property="type" column="TYPE"/>
<result property="collageSystem" column="COLLAGE_SYSTEM"/>
<result property="deleteFlag" column="DELETE_FLAG"/>
<result property="settleDomain" column="SETTLE_DOMAIN"/>
<result property="dispatchFlag" column="DISPATCH_FLAG"/>
<result property="createBy" column="CREATE_BY"/>
<result property="updateBy" column="UPDATE_BY"/>
<result property="createName" column="CREATE_NAME"/>
<result property="createTime" column="CREATE_TIME"/>
<result property="updateTime" column="UPDATE_TIME"/>
<result property="remark" column="REMARK"/>
</resultMap>
</mapper>
......@@ -35,11 +35,11 @@
<result property="workUnit" column="WORK_UNIT"/>
<result property="contractTel" column="CONTRACT_TEL"/>
<result property="deleteFlag" column="DELETE_FLAG"/>
<result property="settleDomain" column="SETTLE_DOMAIN"/>
<result property="createBy" column="CREATE_BY"/>
<result property="updateBy" column="UPDATE_BY"/>
<result property="createName" column="CREATE_NAME"/>
<result property="createTime" column="CREATE_TIME"/>
<result property="updateTime" column="UPDATE_TIME"/>
<result property="remark" column="REMARK"/>
</resultMap>
</mapper>
......@@ -37,11 +37,11 @@
<result property="declareYear" column="DECLARE_YEAR"/>
<result property="heightIdentification" column="HEIGHT_IDENTIFICATION"/>
<result property="deleteFlag" column="DELETE_FLAG"/>
<result property="settleDomain" column="SETTLE_DOMAIN"/>
<result property="createBy" column="CREATE_BY"/>
<result property="updateBy" column="UPDATE_BY"/>
<result property="createName" column="CREATE_NAME"/>
<result property="createTime" column="CREATE_TIME"/>
<result property="updateTime" column="UPDATE_TIME"/>
<result property="remark" column="REMARK"/>
</resultMap>
</mapper>
......@@ -37,11 +37,11 @@
<result property="workingStatus" column="WORKING_STATUS"/>
<result property="workingType" column="WORKING_TYPE"/>
<result property="deleteFlag" column="DELETE_FLAG"/>
<result property="settleDomain" column="SETTLE_DOMAIN"/>
<result property="createBy" column="CREATE_BY"/>
<result property="updateBy" column="UPDATE_BY"/>
<result property="createName" column="CREATE_NAME"/>
<result property="createTime" column="CREATE_TIME"/>
<result property="updateTime" column="UPDATE_TIME"/>
<result property="remark" column="REMARK"/>
</resultMap>
</mapper>
......@@ -161,11 +161,13 @@ public interface CommonConstants {
/**
* 逗号
* @Author fxj
* @Date
* @param null
* @return
**/
public static final char COMMA_CHAR = ',';
public static final char SPOT_CHAR = '.';
/**
* 100
* @Author fxj
**/
int INTEGER_HUNDRED = 100;
}
......@@ -165,4 +165,19 @@ public interface ErrorCodes {
* 已存在对应伤残病名称的数据
*/
String ARCHIVES_EMP_DISABILITY_NAME_EXISTING = "archives.emp.disability.name.existing";
/**
* 已存在对应身份证的家庭成员信息
*/
String ARCHIVES_EMP_FAMILY_NAME_EXISTING = "archives.emp.family.name.existing";
/**
* 已存在对应身份证的家庭成员信息
*/
String ARCHIVES_EMP_NOT_EXIST = "archives.emp.not.exist";
/**
* 员工已减档
*/
String ARCHIVES_EMP_REDUCED = "archives.emp.reduced";
}
......@@ -3,6 +3,7 @@ package com.yifu.cloud.plus.v1.yifu.common.core.util;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
......@@ -41,6 +42,10 @@ public class Common {
return null != obj;
}
public static boolean isNotEmpty(List obj) {
return (null != obj && obj.size() > 0);
}
public static boolean isNotNull(String obj) {
if (null != obj && !"".equals(obj) && !"undefined".equals(obj)){
return true;
......
......@@ -41,6 +41,11 @@ sys.role.delete.existing.user=\u8BE5\u89D2\u8272\u4E0B\u8FD8\u6709\u5173\u8054\u
archives.emp.disability.name.existing=\u5DF2\u5B58\u5728\u5BF9\u5E94\u4F24\u6B8B\u75C5\u540D\u79F0\u7684\u6570\u636E
archives.emp.family.name.existing=\u5DF2\u5B58\u5728\u5BF9\u5E94\u8EAB\u4EFD\u8BC1\u7684\u5BB6\u5EAD\u6210\u5458\u4FE1\u606F
archives.emp.not.exist=\u65E0\u5BF9\u5E94\u8EAB\u4EFD\u8BC1\u7684\u5458\u5DE5\u4FE1\u606F
archives.emp.reduced=\u5458\u5DE5\u5DF2\u51CF\u6863
......
......@@ -16,6 +16,7 @@
package com.yifu.cloud.plus.v1.yifu.admin.api.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
......@@ -101,4 +102,11 @@ public class SysDictItem extends BaseEntity {
@Schema(description = "删除标记,1:已删除,0:正常")
private String delFlag;
/**
* 上级字典项标签
*/
@TableField(exist = false)
@Schema(description = "上级字典项标签")
private String parentLabelOfValue;
}
......@@ -178,7 +178,11 @@ public class DictController {
@SysLog("通过id查询字典项")
@GetMapping("/item/{id:\\d+}")
public R<SysDictItem> getDictItemById(@PathVariable("id") Long id) {
return R.ok(sysDictItemService.getById(id));
SysDictItem item = sysDictItemService.getById(id);
if (Common.isNotNull(item)){
item.setParentLabelOfValue(sysDictService.getParentDicLabelById(item.getType(),item.getValue()));
}
return R.ok(item);
}
/**
......
......@@ -19,6 +19,7 @@ package com.yifu.cloud.plus.v1.yifu.admin.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDict;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* <p>
......@@ -31,4 +32,5 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SysDictMapper extends BaseMapper<SysDict> {
String getParentDicLabelById(@Param("type")String type,@Param("value")String value);
}
......@@ -48,4 +48,6 @@ public interface SysDictService extends IService<SysDict> {
void clearDictCache();
IPage<SysDict> pageAsso(Page page, SysDict sysDict);
String getParentDicLabelById(String type, String value);
}
......@@ -27,7 +27,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDict;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDictItem;
import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysRole;
import com.yifu.cloud.plus.v1.yifu.admin.mapper.SysDictItemMapper;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysDictItemService;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysDictService;
......@@ -35,8 +34,8 @@ import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.enums.DictTypeEnum;
import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.MsgUtils;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
......@@ -125,7 +124,15 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
@Override
public IPage<SysDictItem> pageItem(Page page, SysDictItem sysDictItem) {
return baseMapper.selectPage(page, buildQueryWrapper(sysDictItem));
IPage<SysDictItem> dictItemIPage = baseMapper.selectPage(page, buildQueryWrapper(sysDictItem));
List<SysDictItem> pageRecords = dictItemIPage.getRecords();
if (Common.isNotNull(pageRecords)){
for (SysDictItem item:pageRecords){
item.setParentLabelOfValue(dictService.getParentDicLabelById(item.getType(),item.getValue()));
}
}
dictItemIPage.setRecords(pageRecords);
return dictItemIPage;
}
/**
......
......@@ -98,6 +98,12 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
public IPage<SysDict> pageAsso(Page page, SysDict sysDict) {
return this.page(page,buildQueryWrapper(sysDict));
}
@Override
public String getParentDicLabelById(String type, String value) {
return baseMapper.getParentDicLabelById(type,value);
}
/**
* 构建查询的 wrapper
* @param sysDict 查询条件
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ Copyright (c) 2018-2025, lengleng All rights reserved.
~
~ Redistribution and use in source and binary forms, with or without
~ modification, are permitted provided that the following conditions are met:
~
~ Redistributions of source code must retain the above copyright notice,
~ this list of conditions and the following disclaimer.
~ Redistributions in binary form must reproduce the above copyright
~ notice, this list of conditions and the following disclaimer in the
~ documentation and/or other materials provided with the distribution.
~ Neither the name of the yifu4cloud.com developer nor the names of its
~ contributors may be used to endorse or promote products derived from
~ this software without specific prior written permission.
~ Author: lengleng (wangiegie@gmail.com)
~
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yifu.cloud.plus.v1.yifu.admin.mapper.SysDictMapper">
<resultMap id="sysDictMap" type="com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDict">
<id property="id" column="id"/>
<result property="type" column="type"/>
<result property="description" column="description"/>
<result property="remark" column="remark"/>
<result property="systemFlag" column="system_flag"/>
<result property="delFlag" column="del_flag"/>
<result property="parentItemType" column="parent_item_type"/>
<result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="createName" column="create_name"/>
</resultMap>
<select id="getParentDicLabelById" resultType="java.lang.String">
SELECT
i.label,
i.type
FROM
sys_dict_item a
LEFT JOIN sys_dict d ON d.type = a.type
LEFT JOIN sys_dict_item i ON i.type = d.parent_item_type
WHERE
a.type = #{type}
AND i.`value` = a.parent_id
AND a.`value` = #{value}
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment