feat():新增版本激活/添加/ID查询接口
parent
4bd28d41c7
commit
01563c5b41
|
@ -79,6 +79,7 @@ public class RuleVersion extends BaseEntity {
|
|||
.ruleVersionCode(ruleVersionAddReq.getRuleVersionCode())
|
||||
.ruleVersionActivate(ruleVersionAddReq.getRuleVersionActivate())
|
||||
.ruleVersionStatus(ruleVersionAddReq.getRuleVersionStatus())
|
||||
.ruleVersionRemark(ruleVersionAddReq.getRuleVersionRemark())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -58,5 +58,9 @@ public class RuleVersionAddReq {
|
|||
*/
|
||||
@Schema(title = "版本状态",type = "String",description = "I")
|
||||
private String ruleVersionStatus ;
|
||||
|
||||
/**
|
||||
* 版本备注
|
||||
*/
|
||||
@Schema(title = "版本备注",type = "String")
|
||||
private String ruleVersionRemark;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.muyu.controller;
|
||||
|
||||
import cn.hutool.core.util.DesensitizedUtil;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
|
|
@ -45,6 +45,11 @@ public class RuleVersionController {
|
|||
return Result.success(ruleVersionService.selectList(ruleId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 规则版本接口添加
|
||||
* @param ruleVersionAddReq
|
||||
* @return 添加结果
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
@Operation(summary = "规则版本接口添加",description = "根据客户需求创建对应规则版本")
|
||||
public Result<String> add(
|
||||
|
@ -54,6 +59,12 @@ public class RuleVersionController {
|
|||
return Result.success(null,"操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 规则版本接口修改
|
||||
* @param ruleVersionId
|
||||
* @param ruleVersionUpdReq
|
||||
* @return 修改结果
|
||||
*/
|
||||
@PutMapping("/upd/{ruleVersionId}")
|
||||
@Operation(summary = "规则版本接口修改",description = "对激活、测试、状态等进行修改")
|
||||
public Result<String> update(
|
||||
|
@ -64,4 +75,39 @@ public class RuleVersionController {
|
|||
return Result.success(null,"操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID获取规则版本信息
|
||||
* @param ruleVersionId
|
||||
* @return ID查询返回信息
|
||||
*/
|
||||
@GetMapping("/{ruleVersionId}")
|
||||
@Operation(summary = "根据ID获取规则版本信息",description = "通过ID获取接口规则版本信息")
|
||||
public Result<RuleVersion> findById(@PathVariable("ruleVersionId") Long ruleVersionId){
|
||||
return Result.success(ruleVersionService.getById(ruleVersionId),"操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
*通过ID关闭激活
|
||||
* @param ruleVersionId 请求ID
|
||||
* @return 禁用结果
|
||||
*/
|
||||
@GetMapping("/unstart/{ruleVersionId}")
|
||||
@Operation(summary = "通过ID关闭激活",description = "通过ID关闭激活之后,禁止用户在使用此规则")
|
||||
public Result<String> unstart(@PathVariable("ruleVersionId") Long ruleVersionId){
|
||||
this.ruleVersionService.unstart(ruleVersionId);
|
||||
return Result.success(null,"操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
*通过ID启动激活
|
||||
* @param ruleVersionId 请求ID
|
||||
* @return 启动结果
|
||||
*/
|
||||
@GetMapping("/start/{ruleVersionId}")
|
||||
@Operation(summary = "通过ID启动激活",description = "通过ID启动激活之后,禁止用户在使用此规则")
|
||||
public Result<String> start(@PathVariable("ruleVersionId") Long ruleVersionId){
|
||||
this.ruleVersionService.start(ruleVersionId);
|
||||
return Result.success(null,"操作成功");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,5 +20,5 @@ import java.util.List;
|
|||
public interface RuleVersionMapper extends BaseMapper<RuleVersion> {
|
||||
List<RuleVersionResp> selectByIdList(@Param("ruleId") Long ruleId);
|
||||
|
||||
void updateStatus(@Param("ruleVersionId") Long ruleVersionId, RuleVersionUpdReq ruleVersionUpdReq);
|
||||
void updateStatus(@Param("ruleVersionId") Long ruleVersionId, @Param("ruleVersionUpdReq") RuleVersionUpdReq ruleVersionUpdReq);
|
||||
}
|
||||
|
|
|
@ -18,4 +18,14 @@ public interface RuleVersionService extends IService<RuleVersion> {
|
|||
List<RuleVersionResp> selectList(Long ruleId);
|
||||
|
||||
void updateStatus(Long ruleVersionId, RuleVersionUpdReq ruleVersionUpdReq);
|
||||
|
||||
void unstart(Long ruleVersionId);
|
||||
|
||||
void start(Long ruleVersionId);
|
||||
/**
|
||||
* 通过规则ID设置激活状态
|
||||
* @param ruleVersionId ID
|
||||
* @param activate 状态 SysIsYesNo
|
||||
*/
|
||||
public void settingActivate(Long ruleVersionId, String activate);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
package com.muyu.servier.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.core.enums.SysRuleActivate;
|
||||
import com.muyu.common.core.exception.ServiceException;
|
||||
import com.muyu.common.domain.RuleData;
|
||||
import com.muyu.common.domain.RuleVersion;
|
||||
import com.muyu.common.domain.req.RuleVersionUpdReq;
|
||||
import com.muyu.common.domain.resp.RuleVersionResp;
|
||||
|
@ -35,4 +40,32 @@ public class RuleVersionServiceImpl
|
|||
public void updateStatus(Long ruleVersionId, RuleVersionUpdReq ruleVersionUpdReq) {
|
||||
ruleVersionMapper.updateStatus(ruleVersionId,ruleVersionUpdReq);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unstart(Long ruleVersionId) {
|
||||
this.settingActivate(ruleVersionId, SysRuleActivate.UNSTART.getCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Long ruleVersionId) {
|
||||
this.settingActivate(ruleVersionId, SysRuleActivate.START.getCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingActivate(Long ruleVersionId, String activate) {
|
||||
LambdaQueryWrapper<RuleVersion> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(RuleVersion::getRuleVersionId,ruleVersionId);
|
||||
boolean isExists = this.exists(queryWrapper);
|
||||
if (!isExists) {
|
||||
throw new ServiceException("操作规则不存在");
|
||||
}
|
||||
if (!SysRuleActivate.isCode(activate)){
|
||||
throw new ServiceException("设置状态值违法");
|
||||
}
|
||||
LambdaUpdateWrapper<RuleVersion> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(RuleVersion::getRuleVersionId,ruleVersionId);
|
||||
updateWrapper.set(RuleVersion::getRuleVersionActivate,activate);
|
||||
this.update(updateWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
package com.muyu.util;
|
||||
|
||||
import cn.hutool.core.util.DesensitizedUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
public class DesensitizationUtil {
|
||||
|
||||
/**
|
||||
* 对字符串进行脱敏处理,保留最后几位,其余替换为星号。
|
||||
*
|
||||
* @param data 原始字符串
|
||||
* @param keep 保留的字符数,从字符串末尾开始计数
|
||||
* @param symbol 脱敏使用的字符,默认为星号 '*'
|
||||
* @return 脱敏后的字符串
|
||||
*/
|
||||
public static String desensitize(String data, int keep, char symbol) {
|
||||
if (data == null || data.isEmpty() || keep >= data.length()) {
|
||||
return data;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(data);
|
||||
for (int i = 0; i < data.length() - keep; i++) {
|
||||
sb.setCharAt(i, symbol);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 手机号码 前三位,后4位,其他隐藏
|
||||
*
|
||||
* @param num 移动电话;
|
||||
* @return 脱敏后的移动电话;
|
||||
*/
|
||||
public static String mobilePhone(String num) {
|
||||
if (StrUtil.isBlank(num)) {
|
||||
return StrUtil.EMPTY;
|
||||
}
|
||||
return StrUtil.hide(num, 3, num.length() - 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* 对邮箱地址进行脱敏处理,通常保留最后两位。
|
||||
*
|
||||
* @param email 邮箱地址
|
||||
* @return 脱敏后的邮箱地址
|
||||
*/
|
||||
public static String desensitizeEmail(String email) {
|
||||
int atIndex = email.lastIndexOf('@');
|
||||
if (atIndex == -1) {
|
||||
return email;
|
||||
}
|
||||
String localPart = email.substring(0, atIndex - 2); // 邮箱本地部分减去最后两位
|
||||
return desensitize(localPart, 2, '*') + email.substring(atIndex - 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* 身份证号 前1位 和后2位
|
||||
*
|
||||
* @param idCardNum 身份证
|
||||
* @param front 保留:前面的front位数;从1开始
|
||||
* @param end 保留:后面的end位数;从1开始
|
||||
* @return 脱敏后的身份证
|
||||
*/
|
||||
public static String idCardNum(String idCardNum, int front, int end) {
|
||||
if (StrUtil.isBlank(idCardNum)) {
|
||||
return StrUtil.EMPTY;
|
||||
}
|
||||
if ((front + end) > idCardNum.length()) {
|
||||
return StrUtil.EMPTY;
|
||||
}
|
||||
if (front < 0 || end < 0) {
|
||||
return StrUtil.EMPTY;
|
||||
}
|
||||
return StrUtil.hide(idCardNum, front, idCardNum.length() - end);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -4,17 +4,18 @@
|
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.muyu.mapper.RuleVersionMapper">
|
||||
<update id="updateStatus">
|
||||
UPDATE `rule_version` SET
|
||||
UPDATE `rule_version`
|
||||
SET
|
||||
<if test="ruleVersionActivate != null">
|
||||
`rule_version_activate` = NULL,
|
||||
`rule_version_activate` = #{ruleVersionUpdReq.ruleVersionActivate},
|
||||
</if>
|
||||
<if test="ruleVersionStatus != null">
|
||||
`rule_version_status` = NULL,
|
||||
`rule_version_status` = #{ruleVersionUpdReq.ruleVersionStatus},
|
||||
</if>
|
||||
<if test="ruleVersionTest != null">
|
||||
`rule_version_test` = NULL
|
||||
`rule_version_test` = #{ruleVersionUpdReq.ruleVersionTest}
|
||||
</if>
|
||||
WHERE `rule_version_id` = #{ruleVersionId};
|
||||
WHERE `rule_version_id` = #{ruleVersionId}
|
||||
</update>
|
||||
<select id="selectByIdList" resultType="com.muyu.common.domain.resp.RuleVersionResp">
|
||||
SELECT
|
||||
|
|
Loading…
Reference in New Issue