Commit 57e8b86f authored by huyuchen's avatar huyuchen

Merge remote-tracking branch 'origin/develop' into develop

# Conflicts:
#	yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/TEmployeeProjectServiceImpl.java
#	yifu-common/yifu-common-core/src/main/java/com/yifu.cloud.plus.v1/yifu/common/core/constant/CommonConstants.java
parents e27b7b96 8a8fb30c
...@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType; ...@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model; import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.Data; import lombok.Data;
...@@ -12,20 +12,18 @@ import lombok.EqualsAndHashCode; ...@@ -12,20 +12,18 @@ import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length; import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;
/** /**
* 附件信息表 * @Author fxj
* * @Description 附件信息表
* @author pwang * @Date 11:07 2022/6/22
* @date 2021-02-19 16:16:07 **/
*/
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName("t_atta_info") @TableName("t_atta_info")
@Tag(name = "附件信息表") @Tag(name = "附件信息表")
public class TAttaInfo extends Model<TAttaInfo> { public class TAttaInfo extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 主键 * 主键
...@@ -58,17 +56,6 @@ public class TAttaInfo extends Model<TAttaInfo> { ...@@ -58,17 +56,6 @@ public class TAttaInfo extends Model<TAttaInfo> {
@Length(max = 10, message = "资源类型不能超过10个字符") @Length(max = 10, message = "资源类型不能超过10个字符")
@Schema(description = "资源类型") @Schema(description = "资源类型")
private String attaType; private String attaType;
/**
* 创建人
*/
@Length(max = 32, message = "创建人不能超过32个字符")
@Schema(description = "创建人")
private String createUser;
/**
* 创建时间
*/
@Schema(description = "创建时间")
private LocalDateTime createTime;
/** /**
* 关系类型(0客户附件1联系人附件2跟进记录附件3合同附件4合同归档附件5报价单) * 关系类型(0客户附件1联系人附件2跟进记录附件3合同附件4合同归档附件5报价单)
*/ */
......
...@@ -5,6 +5,7 @@ import com.alibaba.excel.annotation.write.style.ColumnWidth; ...@@ -5,6 +5,7 @@ import com.alibaba.excel.annotation.write.style.ColumnWidth;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past; import javax.validation.constraints.Past;
import java.io.Serializable; import java.io.Serializable;
......
...@@ -162,8 +162,6 @@ public class FileUploadController { ...@@ -162,8 +162,6 @@ public class FileUploadController {
unitAtta.setAttaType(key.substring(key.lastIndexOf(point))); unitAtta.setAttaType(key.substring(key.lastIndexOf(point)));
} }
unitAtta.setCreateTime(LocalDateTime.now()); unitAtta.setCreateTime(LocalDateTime.now());
YifuUser user = SecurityUtils.getUser();
unitAtta.setCreateUser(null == user ? "" : user.getId().toString());
return unitAtta; return unitAtta;
} }
......
...@@ -98,5 +98,17 @@ public class TCheckBankNo extends BaseEntity { ...@@ -98,5 +98,17 @@ public class TCheckBankNo extends BaseEntity {
@Schema(description ="银行卡类别 样例:借记卡") @Schema(description ="银行卡类别 样例:借记卡")
private String cardCategory; private String cardCategory;
/**
* 姓名
*/
@Schema(description ="姓名")
private String name;
/**
* 身份证
*/
@Schema(description ="身份证")
private String idNum;
} }
...@@ -100,6 +100,8 @@ public class ChecksUtil { ...@@ -100,6 +100,8 @@ public class ChecksUtil {
checkBankNo.setMessage(message); checkBankNo.setMessage(message);
checkBankNo.setRemark(getJsonElementValue(resJson.getAsJsonObject().get(ChecksConstants.REMARK))); checkBankNo.setRemark(getJsonElementValue(resJson.getAsJsonObject().get(ChecksConstants.REMARK)));
checkBankNo.setType(CommonConstants.ONE_STRING); checkBankNo.setType(CommonConstants.ONE_STRING);
checkBankNo.setName(name);
checkBankNo.setIdNum(idNum);
} }
} else { } else {
// 记录错误日志,正式项目中请换成log打印 // 记录错误日志,正式项目中请换成log打印
......
...@@ -120,7 +120,6 @@ public class TCheckBankNoController { ...@@ -120,7 +120,6 @@ public class TCheckBankNoController {
*/ */
@Operation(description = "银行卡号校验") @Operation(description = "银行卡号校验")
@SysLog("银行卡号校验" ) @SysLog("银行卡号校验" )
//@Inner
@GetMapping("/checkBankNo" ) @GetMapping("/checkBankNo" )
public R<TCheckBankNo> checkBankNo(@RequestParam(value = "name",required = true)String name, public R<TCheckBankNo> checkBankNo(@RequestParam(value = "name",required = true)String name,
@RequestParam(value = "idNum",required = true)String idNum, @RequestParam(value = "idNum",required = true)String idNum,
...@@ -128,4 +127,22 @@ public class TCheckBankNoController { ...@@ -128,4 +127,22 @@ public class TCheckBankNoController {
@RequestParam(value = "mobile",required = false) String mobile) { @RequestParam(value = "mobile",required = false) String mobile) {
return tCheckBankNoService.checkBankNo(name,idNum,cardNo,mobile); return tCheckBankNoService.checkBankNo(name,idNum,cardNo,mobile);
} }
/**
* 银行卡号校验
* @param name 姓名 是 [string]
* @param idNum 身份证号码,限单个 是 [string]
* @param cardNo 银行卡号,限单个 是 [string]
* @param mobile 银行预留手机号,仅支持国内11位号码
*/
@Operation(description = "银行卡号校验")
@SysLog("银行卡号校验" )
@Inner
@GetMapping("/inner/checkBankNo" )
public R<TCheckBankNo> checkBankNoInner(@RequestParam(value = "name",required = true)String name,
@RequestParam(value = "idNum",required = true)String idNum,
@RequestParam(value = "cardNo",required = true)String cardNo,
@RequestParam(value = "mobile",required = false) String mobile) {
return tCheckBankNoService.checkBankNo(name,idNum,cardNo,mobile);
}
} }
...@@ -132,4 +132,19 @@ public class TCheckIdCardController { ...@@ -132,4 +132,19 @@ public class TCheckIdCardController {
public R<List<TCheckIdCard>> checkIdCard(@RequestBody List<TCheckIdCard> checkList) { public R<List<TCheckIdCard>> checkIdCard(@RequestBody List<TCheckIdCard> checkList) {
return tCheckIdCardService.checkIdCard(checkList); return tCheckIdCardService.checkIdCard(checkList);
} }
/**
* @param checkList
* @Description: 校验姓名身份证
* @Author: fxj
* @Date: 2022-5-12 15:18:53
* @return: com.yifu.cloud.v1.common.core.util.R
**/
@Operation(description = "校验姓名身份证")
@SysLog("校验姓名身份证")
@Inner
@PostMapping("/inner/checkIdCard")
public R<List<TCheckIdCard>> checkIdCardInner(@RequestBody List<TCheckIdCard> checkList) {
return tCheckIdCardService.checkIdCard(checkList);
}
} }
...@@ -32,6 +32,8 @@ import org.springframework.http.HttpHeaders; ...@@ -32,6 +32,8 @@ import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Map;
/** /**
* 手机号码校验 * 手机号码校验
...@@ -118,10 +120,22 @@ public class TCheckMobileController { ...@@ -118,10 +120,22 @@ public class TCheckMobileController {
*/ */
@Operation(description = "检测手机号,多个手机号码用英文半角逗号隔开,仅支持国内号码") @Operation(description = "检测手机号,多个手机号码用英文半角逗号隔开,仅支持国内号码")
@SysLog("检测手机号状态" ) @SysLog("检测手机号状态" )
//@Inner
@GetMapping("/checkMobiles" ) @GetMapping("/checkMobiles" )
public R checkMobiles(String mobiles) { public R<Map<String,TCheckMobile>> checkMobiles(String mobiles) {
return R.ok(tCheckMobileService.checkMobiles(mobiles)); return tCheckMobileService.checkMobiles(mobiles);
}
/**
* 手机号码状态校验
* @param mobiles 检测手机号,多个手机号码用英文半角逗号隔开,仅支持国内号码
* @return R
*/
@Operation(description = "检测手机号,多个手机号码用英文半角逗号隔开,仅支持国内号码")
@SysLog("检测手机号状态" )
@Inner
@GetMapping("/inner/checkMobiles" )
public R<Map<String,TCheckMobile>> checkMobilesInner(String mobiles) {
return tCheckMobileService.checkMobiles(mobiles);
} }
} }
...@@ -16,12 +16,14 @@ ...@@ -16,12 +16,14 @@
*/ */
package com.yifu.cloud.plus.v1.check.service.impl; package com.yifu.cloud.plus.v1.check.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.check.entity.TCheckBankNo; import com.yifu.cloud.plus.v1.check.entity.TCheckBankNo;
import com.yifu.cloud.plus.v1.check.mapper.TCheckBankNoMapper; import com.yifu.cloud.plus.v1.check.mapper.TCheckBankNoMapper;
import com.yifu.cloud.plus.v1.check.service.TCanCheckService; import com.yifu.cloud.plus.v1.check.service.TCanCheckService;
import com.yifu.cloud.plus.v1.check.service.TCheckBankNoService; import com.yifu.cloud.plus.v1.check.service.TCheckBankNoService;
import com.yifu.cloud.plus.v1.check.utils.ChecksUtil; import com.yifu.cloud.plus.v1.check.utils.ChecksUtil;
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.exception.ErrorCodes;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common; 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.MsgUtils;
...@@ -40,11 +42,24 @@ import org.springframework.stereotype.Service; ...@@ -40,11 +42,24 @@ import org.springframework.stereotype.Service;
public class TCheckBankNoServiceImpl extends ServiceImpl<TCheckBankNoMapper, TCheckBankNo> implements TCheckBankNoService { public class TCheckBankNoServiceImpl extends ServiceImpl<TCheckBankNoMapper, TCheckBankNo> implements TCheckBankNoService {
private final TCanCheckService canCheckService; private final TCanCheckService canCheckService;
@Override @Override
public R<TCheckBankNo> checkBankNo(String name, String idNum, String cardNo, String mobile) { public R<TCheckBankNo> checkBankNo(String name, String idNum, String cardNo, String mobile) {
if (Common.isEmpty(name) || Common.isEmpty(idNum) || Common.isEmpty(cardNo)){ if (Common.isEmpty(name) || Common.isEmpty(idNum) || Common.isEmpty(cardNo)){
return R.failed(MsgUtils.getMessage(ErrorCodes.CHECKS_BANK_NO_REQUEST_PARAM_ERROR)); return R.failed(MsgUtils.getMessage(ErrorCodes.CHECKS_BANK_NO_REQUEST_PARAM_ERROR));
} }
return ChecksUtil.checkBankNo(name,idNum,cardNo,mobile,canCheckService.getCanCheck()); TCheckBankNo checkBankNo = baseMapper.selectOne(Wrappers.<TCheckBankNo>query().lambda()
.eq(TCheckBankNo::getBankNo,cardNo)
.eq(TCheckBankNo::getName,name)
.eq(TCheckBankNo::getIdNum,idNum)
.last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(checkBankNo)){
return R.ok(checkBankNo);
}
R<TCheckBankNo> res = ChecksUtil.checkBankNo(name,idNum,cardNo,mobile,canCheckService.getCanCheck());
if (Common.isNotNull(res) && Common.isNotNull(res.getData())){
baseMapper.insert(res.getData());
}
return res;
} }
} }
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
*/ */
package com.yifu.cloud.plus.v1.check.service.impl; package com.yifu.cloud.plus.v1.check.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.check.entity.TCheckMobile; import com.yifu.cloud.plus.v1.check.entity.TCheckMobile;
import com.yifu.cloud.plus.v1.check.mapper.TCheckMobileMapper; import com.yifu.cloud.plus.v1.check.mapper.TCheckMobileMapper;
...@@ -30,8 +31,10 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.R; ...@@ -30,8 +31,10 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
/** /**
* 手机号码校验 * 手机号码校验
...@@ -44,6 +47,7 @@ import java.util.Map; ...@@ -44,6 +47,7 @@ import java.util.Map;
public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCheckMobile> implements TCheckMobileService { public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCheckMobile> implements TCheckMobileService {
private final TCanCheckService canCheckService; private final TCanCheckService canCheckService;
/** /**
* @Author fxj * @Author fxj
* @Description 号码状态校验,单次请求上限100 多一个号码请以逗号分割 * @Description 号码状态校验,单次请求上限100 多一个号码请以逗号分割
...@@ -51,41 +55,60 @@ public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCh ...@@ -51,41 +55,60 @@ public class TCheckMobileServiceImpl extends ServiceImpl<TCheckMobileMapper, TCh
**/ **/
@Override @Override
public R<Map<String,TCheckMobile>> checkMobiles(String mobiles){ public R<Map<String,TCheckMobile>> checkMobiles(String mobiles){
R<Map<String,TCheckMobile>> mobileMapR; R<Map<String,TCheckMobile>> mobileMapR = null;
Map<String,TCheckMobile> checkMobileMap; Map<String,TCheckMobile> checkMobileMap = null;
Map<String,TCheckMobile> existMap = new HashMap<>();
if (Common.isNotNull(mobiles)){ if (Common.isNotNull(mobiles)){
List<String> mobileList = Common.initStrToList(mobiles,CommonConstants.COMMA_STRING); List<String> mobileList = Common.initStrToList(mobiles,CommonConstants.COMMA_STRING);
if (Common.isNotEmpty(mobileList) && mobileList.size() > CommonConstants.INTEGER_HUNDRED){ if (Common.isNotEmpty(mobileList) && mobileList.size() > CommonConstants.INTEGER_HUNDRED){
return R.failed(MsgUtils.getMessage(ErrorCodes.CHECKS_MOBILE_REQUEST_LIMIT_HUNDRED)); return R.failed(MsgUtils.getMessage(ErrorCodes.CHECKS_MOBILE_REQUEST_LIMIT_HUNDRED));
} }
mobileMapR = ChecksUtil.checkMobile(mobiles,canCheckService.getCanCheck()); //1.先从本地库获取正常数据
if (Common.isEmpty(mobileMapR) && Common.isEmpty(mobileMapR.getData())){ List<TCheckMobile> checkMobiles = baseMapper.selectList(Wrappers.<TCheckMobile>query().lambda()
return R.failed(MsgUtils.getMessage(ErrorCodes.CHECKS_MOBILE_REQUEST_ERROR)); .in(TCheckMobile::getMobile,mobileList)
.eq(TCheckMobile::getStatus,CommonConstants.ONE_STRING));
if (Common.isNotNull(checkMobiles)){
existMap = checkMobiles.stream().collect(Collectors.toMap(TCheckMobile::getMobile,TCheckMobile -> TCheckMobile));
} }
checkMobileMap = mobileMapR.getData(); mobileList.removeAll(existMap.keySet());
if (Common.isNotNull(mobileList) && Common.isNotNull(checkMobileMap)){ //2.从远处端获取数据
TCheckMobile checkMobile = null; if (Common.isNotNull(mobileList)){
for (String mobile:mobileList){ mobileMapR = ChecksUtil.checkMobile(Common.ListToStr(mobileList,CommonConstants.COMMA_STRING),canCheckService.getCanCheck());
if (Common.isEmpty(checkMobileMap.get(mobile))){ if (Common.isEmpty(mobileMapR) || Common.isEmpty(mobileMapR.getData())){
checkMobile = new TCheckMobile(); return R.failed(MsgUtils.getMessage(ErrorCodes.CHECKS_MOBILE_REQUEST_ERROR)
checkMobile.setType(CommonConstants.ONE_STRING); +(Common.isNotNull(mobileMapR)?mobileMapR.getMsg():CommonConstants.EMPTY_STRING));
checkMobile.setMobile(mobile); }
checkMobile.setStatus(CommonConstants.TEN_STRING); checkMobileMap = mobileMapR.getData();
checkMobile.setMessage(Common.isEmpty(mobileMapR)?MsgUtils.getMessage(ErrorCodes.CHECKS_MOBILE_REQUEST_ERROR):mobileMapR.getMsg()); if (Common.isNotNull(mobileList) && Common.isNotNull(checkMobileMap)){
checkMobile.setChargesstatus(CommonConstants.ZERO_STRING); TCheckMobile checkMobile = null;
checkMobile.setNumbertype(CommonConstants.EMPTY_STRING); for (String mobile:mobileList){
checkMobile.setArea(CommonConstants.EMPTY_STRING); if (Common.isEmpty(checkMobileMap.get(mobile))){
checkMobileMap.put(mobile,checkMobile); checkMobile = new TCheckMobile();
checkMobile.setType(CommonConstants.ONE_STRING);
checkMobile.setMobile(mobile);
checkMobile.setStatus(CommonConstants.TEN_STRING);
checkMobile.setMessage(Common.isEmpty(mobileMapR)?MsgUtils.getMessage(ErrorCodes.CHECKS_MOBILE_REQUEST_ERROR):mobileMapR.getMsg());
checkMobile.setChargesstatus(CommonConstants.ZERO_STRING);
checkMobile.setNumbertype(CommonConstants.EMPTY_STRING);
checkMobile.setArea(CommonConstants.EMPTY_STRING);
checkMobileMap.put(mobile,checkMobile);
}
} }
} }
mobileMapR.setData(checkMobileMap);
} }
}else { }else {
return R.failed(MsgUtils.getMessage(ErrorCodes.PARAM_NOT_EMPTY)); return R.failed(MsgUtils.getMessage(ErrorCodes.PARAM_NOT_EMPTY));
} }
if (Common.isNotNull(checkMobileMap)){ if (Common.isNotNull(checkMobileMap)){
this.saveBatch(checkMobileMap.values()); this.saveBatch(checkMobileMap.values());
}else {
checkMobileMap = new HashMap<>();
}
checkMobileMap.putAll(existMap);
if (Common.isEmpty(mobileMapR)){
mobileMapR = new R<>();
} }
mobileMapR.setData(checkMobileMap);
return mobileMapR; return mobileMapR;
} }
......
...@@ -38,5 +38,7 @@ ...@@ -38,5 +38,7 @@
<result property="bankNo" column="bank_no"/> <result property="bankNo" column="bank_no"/>
<result property="cardType" column="card_type"/> <result property="cardType" column="card_type"/>
<result property="cardCategory" column="card_category"/> <result property="cardCategory" column="card_category"/>
<result property="name" column="name"/>
<result property="idNum" column="id_num"/>
</resultMap> </resultMap>
</mapper> </mapper>
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
package com.yifu.cloud.plus.v1.yifu.common.core.constant; package com.yifu.cloud.plus.v1.yifu.common.core.constant;
import java.util.List;
/** /**
* @author lengleng * @author lengleng
* @date 2019/2/1 * @date 2019/2/1
...@@ -215,6 +217,7 @@ public interface CommonConstants { ...@@ -215,6 +217,7 @@ public interface CommonConstants {
**/ **/
public static final int EMPLOYEE_INIT_NO_START = 7; public static final int EMPLOYEE_INIT_NO_START = 7;
String SAVE_FAILED = "保存失败!"; String SAVE_FAILED = "保存失败!";
String RESULT_EMPTY = "获取结果为空";
/** /**
* @Author fxj * @Author fxj
......
...@@ -4,6 +4,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; ...@@ -4,6 +4,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
...@@ -123,4 +124,38 @@ public class Common { ...@@ -123,4 +124,38 @@ public class Common {
} }
return result; return result;
} }
/**
* 将集合拼成串
*
* @param <T>
* @param str
* @param regex 分隔符默认,
* @return
*/
public static <T> String ListToStr(Collection<T> str, String regex) {
String result = "";
try {
if (isNotNull(str)) {
// 默认用,分割
if (!isNotNull(regex)) {
regex = ",";
}
for (Object strtemp : str) {
if ("".equals(result)) {
result = String.valueOf(strtemp);
} else {
result = result + regex + strtemp;
}
}
}
} catch (Exception e) {
// 数据异常
}
return result;
}
public static <T> boolean isNotNull(Collection<T> obj) {
return null != obj && obj.size() > 0;
}
} }
...@@ -40,7 +40,10 @@ import org.springframework.security.access.prepost.PreAuthorize; ...@@ -40,7 +40,10 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* <p> * <p>
...@@ -170,6 +173,25 @@ public class DictController { ...@@ -170,6 +173,25 @@ public class DictController {
return R.ok(sysDictItemService.pageItem(page, sysDictItem)); return R.ok(sysDictItemService.pageItem(page, sysDictItem));
} }
/**
* 获取所有字典数据
* @return
*/
@GetMapping("/item/getAllDictItem")
public R<Map<String, Object>> getSysDictItemPage() {
return sysDictItemService.getSysDictItemPage();
}
/**
* 通过id查询父级字典的字典值
* @param itemTypes
* @return R
*/
@SysLog("通过id查询父级字典的字典值")
@GetMapping("/getParentDictItemByTypes")
public R<Map<String, Object>> getParentDictItemByTypes(String itemTypes) {
return sysDictItemService.getParentDictItemByTypes(itemTypes);
}
/** /**
* 通过id查询字典项 * 通过id查询字典项
* @param id id * @param id id
......
...@@ -23,6 +23,7 @@ import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDictItem; ...@@ -23,6 +23,7 @@ import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDictItem;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 字典项 * 字典项
...@@ -57,4 +58,9 @@ public interface SysDictItemService extends IService<SysDictItem> { ...@@ -57,4 +58,9 @@ public interface SysDictItemService extends IService<SysDictItem> {
IPage<SysDictItem> pageItem(Page page, SysDictItem sysDictItem); IPage<SysDictItem> pageItem(Page page, SysDictItem sysDictItem);
R<Boolean> removeDictItemDiy(Long id); R<Boolean> removeDictItemDiy(Long id);
R<Map<String, Object>> getParentDictItemByTypes(String itemTypes);
R<Map<String, Object>> getSysDictItemPage();
} }
...@@ -146,6 +146,43 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi ...@@ -146,6 +146,43 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
return R.ok(baseMapper.deleteById(id) > 0); return R.ok(baseMapper.deleteById(id) > 0);
} }
@Override
public R<Map<String, Object>> getParentDictItemByTypes(String itemTypes) {
if (Common.isEmpty(itemTypes)){
return R.failed(CommonConstants.RESULT_EMPTY);
}
Map<String, Object> resultMap = new HashMap<>();
List<SysDictItem> allList = baseMapper.selectList(Wrappers.<SysDictItem>query().lambda()
.in(SysDictItem::getType,Common.initStrToList(itemTypes,CommonConstants.COMMA_STRING))
.eq(SysDictItem::getDelFlag,CommonConstants.ZERO_STRING));
extracted(allList, resultMap);
return R.ok(resultMap);
}
@Override
public R<Map<String, Object>> getSysDictItemPage() {
List<SysDictItem> allList = baseMapper.selectList(Wrappers.<SysDictItem>query().lambda()
.eq(SysDictItem::getDelFlag,CommonConstants.ZERO_STRING));
Map<String, Object> resultMap = new HashMap<>();
extracted(allList, resultMap);
return R.ok(resultMap);
}
private void extracted(List<SysDictItem> allList, Map<String, Object> resultMap) {
if (Common.isNotNull(allList)){
for (SysDictItem item : allList) {
String dictCode = item.getType();
if (resultMap.get(dictCode) == null) {
Map<String, Object> dictMap = new HashMap<String, Object>();
dictMap.put(item.getValue(), item.getLabel());
resultMap.put(dictCode, dictMap);
} else {
Map dictMap = (Map) resultMap.get(dictCode);
dictMap.put(item.getValue(), item.getLabel());
}
}
}
}
/** /**
* 构建查询的 wrapper * 构建查询的 wrapper
* @param sysDictItem 查询条件 * @param sysDictItem 查询条件
......
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