feat():增加查、改(数据,状态)、删接口
parent
4c12e90952
commit
fefc7b04f2
|
@ -1,10 +1,15 @@
|
||||||
package com.muyu.common.domain;
|
package com.muyu.common.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import com.muyu.common.domain.req.RuleDataUpdReq;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:yang
|
* @Author:yang
|
||||||
* @Package:com.muyu.common.domain
|
* @Package:com.muyu.common.domain
|
||||||
|
@ -19,18 +24,46 @@ import lombok.experimental.SuperBuilder;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@TableName("rule_data")
|
@TableName("rule_data")
|
||||||
public class RuleData extends BaseEntity {
|
public class RuleData extends BaseEntity {
|
||||||
/**
|
|
||||||
* 类型ID
|
|
||||||
*/
|
|
||||||
private Integer ruleId;
|
|
||||||
/**
|
|
||||||
* 规则类型名称
|
|
||||||
*/
|
|
||||||
private String ruleRemark;
|
|
||||||
/**
|
|
||||||
* 规则类型状态(是否启用)
|
|
||||||
*/
|
|
||||||
private String ruleClassify;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则ID
|
||||||
|
*/
|
||||||
|
@TableId(value = "id",type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 规则分类
|
||||||
|
*/
|
||||||
|
private Integer ruleClassify;
|
||||||
|
/**
|
||||||
|
* 规则名称
|
||||||
|
*/
|
||||||
|
private String ruleName;
|
||||||
|
/**
|
||||||
|
* 规则代码
|
||||||
|
*/
|
||||||
|
private String ruleCode;
|
||||||
|
/**
|
||||||
|
* 规则说明
|
||||||
|
*/
|
||||||
|
private String ruleExplain;
|
||||||
|
/**
|
||||||
|
* 响应示例
|
||||||
|
*/
|
||||||
|
private String ruleRespond;
|
||||||
|
/**
|
||||||
|
* 规则状态
|
||||||
|
*/
|
||||||
|
private String ruleStatus;
|
||||||
|
|
||||||
|
public static RuleData updBuild(RuleDataUpdReq ruleDataUpdReq, Supplier<Long> idSupplier) {
|
||||||
|
return RuleData.builder()
|
||||||
|
.id(idSupplier.get())
|
||||||
|
.ruleClassify(ruleDataUpdReq.getRuleClassify())
|
||||||
|
.ruleName(ruleDataUpdReq.getRuleName())
|
||||||
|
.ruleCode(ruleDataUpdReq.getRuleCode())
|
||||||
|
.ruleExplain(ruleDataUpdReq.getRuleExplain())
|
||||||
|
.ruleRespond(ruleDataUpdReq.getRuleRespond())
|
||||||
|
.ruleStatus(ruleDataUpdReq.getRuleStatus())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.muyu.common.domain;
|
package com.muyu.common.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
@ -19,33 +21,19 @@ import lombok.experimental.SuperBuilder;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@TableName("rule_data_classify")
|
@TableName("rule_data_classify")
|
||||||
public class RuleDataClassify extends BaseEntity {
|
public class RuleDataClassify extends BaseEntity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类型ID
|
* 类型ID
|
||||||
*/
|
*/
|
||||||
private Integer id;
|
@TableId(value = "id",type = IdType.AUTO)
|
||||||
|
private Long ruleId;
|
||||||
/**
|
/**
|
||||||
* 规则分类
|
* 规则类型名称
|
||||||
*/
|
*/
|
||||||
private Integer ruleClassify;
|
private String ruleRemark;
|
||||||
/**
|
/**
|
||||||
* 规则名称
|
* 规则类型状态(是否启用)
|
||||||
*/
|
*/
|
||||||
private String ruleName;
|
private String ruleClassify;
|
||||||
/**
|
|
||||||
* 规则代码
|
|
||||||
*/
|
|
||||||
private String ruleCode;
|
|
||||||
/**
|
|
||||||
* 规则说明
|
|
||||||
*/
|
|
||||||
private String ruleExplain;
|
|
||||||
/**
|
|
||||||
* 响应示例
|
|
||||||
*/
|
|
||||||
private String ruleRespond;
|
|
||||||
/**
|
|
||||||
* 规则状态
|
|
||||||
*/
|
|
||||||
private Integer ruleStatus;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.muyu.common.domain.req;
|
||||||
|
|
||||||
|
import com.muyu.common.core.validation.custom.IsSystemYesNo;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.common.domain.req
|
||||||
|
* @Project:cloud-rule
|
||||||
|
* @name:RuleDataListReq
|
||||||
|
* @Date:2024/8/22 下午10:12
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Tag(name = "接口列表请求对象")
|
||||||
|
public class RuleDataListReq {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则名称
|
||||||
|
*/
|
||||||
|
@Schema(description = "规则名称",defaultValue = "邮箱规则接口",type = "String")
|
||||||
|
private String ruleName;
|
||||||
|
/**
|
||||||
|
* 规则状态
|
||||||
|
*/
|
||||||
|
@Schema(description = "规则状态",defaultValue = "Y",type = "String")
|
||||||
|
@IsSystemYesNo
|
||||||
|
private String ruleStatus;
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
@Schema(description = "创建人",defaultValue = "yuan",type = "String")
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.muyu.common.domain.req;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.muyu.common.core.validation.custom.IsSystemYesNo;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.common.domain.req
|
||||||
|
* @Project:cloud-rule
|
||||||
|
* @name:RuleDataUpdReq
|
||||||
|
* @Date:2024/8/23 上午1:09
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class RuleDataUpdReq {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则分类
|
||||||
|
*/
|
||||||
|
@Schema(title = "规则分类", type = "Integer",description = "选择规则分类" )
|
||||||
|
private Integer ruleClassify;
|
||||||
|
/**
|
||||||
|
* 规则名称
|
||||||
|
*/
|
||||||
|
@NotEmpty(message = "规则名称不可为空 ")
|
||||||
|
@Schema(title = "规则名称" , type = "String",defaultValue = "XX规则"
|
||||||
|
,description = "规则名称一般为类型名称,方便使用者进行区分" ,requiredProperties = {"ruleName"})
|
||||||
|
private String ruleName;
|
||||||
|
/**
|
||||||
|
* 规则代码
|
||||||
|
*/
|
||||||
|
@Schema(title = "规则代码",type = "String")
|
||||||
|
private String ruleCode;
|
||||||
|
/**
|
||||||
|
* 规则说明
|
||||||
|
*/
|
||||||
|
@Schema(title = "规则说明",type = "String")
|
||||||
|
private String ruleExplain;
|
||||||
|
/**
|
||||||
|
* 响应示例
|
||||||
|
*/
|
||||||
|
@Schema(title = "响应示例",type = "String")
|
||||||
|
private String ruleRespond;
|
||||||
|
/**
|
||||||
|
* 规则状态
|
||||||
|
*/
|
||||||
|
@NotEmpty(message = "规则状态不可为空 ")
|
||||||
|
@IsSystemYesNo
|
||||||
|
@Schema(title = "接口开通状态" , type = "String" , defaultValue = "Y",
|
||||||
|
description = "状态为Y和N,如果为Y则客户可以使用接口规则,若为N则客户不可以使用接口规则")
|
||||||
|
private String ruleStatus;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
package com.muyu.common.domain.resp;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.muyu.common.domain.RuleData;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.common.domain.resp
|
||||||
|
* @Project:cloud-rule
|
||||||
|
* @name:RuleDataResp
|
||||||
|
* @Date:2024/8/22 下午9:54
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Tag(name = "接口规则信息对应对象",description = "负责接口规则信息查询的相应结果")
|
||||||
|
public class RuleDataResp {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规则ID
|
||||||
|
*/
|
||||||
|
@Schema(description = "规则ID",defaultValue = "1",type = "Long")
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 规则名称
|
||||||
|
*/
|
||||||
|
@Schema(description = "规则名称",defaultValue = "邮箱规则接口",type = "String")
|
||||||
|
private String ruleName;
|
||||||
|
/**
|
||||||
|
* 规则代码
|
||||||
|
*/
|
||||||
|
@Schema(description = "规则代码",defaultValue = "sql",type = "String")
|
||||||
|
private String ruleCode;
|
||||||
|
/**
|
||||||
|
* 规则说明
|
||||||
|
*/
|
||||||
|
@Schema(description = "规则说明",defaultValue = "说明123",type = "String")
|
||||||
|
private String ruleExplain;
|
||||||
|
/**
|
||||||
|
* 响应示例
|
||||||
|
*/
|
||||||
|
@Schema(description = "响应示例",defaultValue = "json{...}",type = "String")
|
||||||
|
private String ruleRespond;
|
||||||
|
/**
|
||||||
|
* 规则状态
|
||||||
|
*/
|
||||||
|
@Schema(description = "规则状态",defaultValue = "Y",type = "String")
|
||||||
|
private String ruleStatus;
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
@Schema(description = "创建人",defaultValue = "yuan",type = "String")
|
||||||
|
private String createBy;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Schema(description = "创建时间",defaultValue = "2024-08-22 08:50:39",type = "Date")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
public static RuleDataResp ruleDataBuild(RuleData ruleData, Supplier<List<RuleDataResp>> function) {
|
||||||
|
return RuleDataResp.builder()
|
||||||
|
.id(ruleData.getId())
|
||||||
|
.ruleName(ruleData.getRuleName())
|
||||||
|
.ruleCode(ruleData.getRuleCode())
|
||||||
|
.ruleExplain(ruleData.getRuleExplain())
|
||||||
|
.ruleRespond(ruleData.getRuleRespond())
|
||||||
|
.ruleStatus(ruleData.getRuleStatus())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,19 @@
|
||||||
package com.muyu.controller;
|
package com.muyu.controller;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.domain.RuleData;
|
||||||
|
import com.muyu.common.domain.req.RuleDataListReq;
|
||||||
|
import com.muyu.common.domain.req.RuleDataUpdReq;
|
||||||
|
import com.muyu.common.domain.resp.RuleDataResp;
|
||||||
|
import com.muyu.servier.RuleDataService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
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 org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:yang
|
* @Author:yang
|
||||||
|
@ -13,6 +24,87 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/rule_data")
|
@RequestMapping("/rule_data")
|
||||||
@Tag(name = "查询源规则",description = "从自由数据库查询")
|
@Tag(name = "规则控制层",description = "进行规则制定,查看等操作")
|
||||||
public class RuleDataController {
|
public class RuleDataController {
|
||||||
|
|
||||||
|
@Autowired private RuleDataService ruleDataService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有接口规则
|
||||||
|
* @param ruleDataListReq
|
||||||
|
* @return 规则列表
|
||||||
|
*/
|
||||||
|
@RequestMapping(path = "/list",method = RequestMethod.POST)
|
||||||
|
@Operation(summary = "查询接口规则",description = "根据规则名称、创建人、启动状态进行规则的筛选")
|
||||||
|
public Result<List<RuleDataResp>> selectList(
|
||||||
|
@Validated @RequestBody RuleDataListReq ruleDataListReq
|
||||||
|
){
|
||||||
|
return Result.success(
|
||||||
|
ruleDataService.selectList(ruleDataListReq)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改接口规则
|
||||||
|
* @param id
|
||||||
|
* @param ruleDataUpdReq
|
||||||
|
* @return 修改结果
|
||||||
|
*/
|
||||||
|
@PutMapping("/upd/{id}")
|
||||||
|
@Operation(summary = "接口规则修改",description = "通过ID修改接口规则信息")
|
||||||
|
public Result<String> update(
|
||||||
|
@Schema(title = "客户ID",type = "Long",defaultValue = "1",description = "修改接口规则信息需要唯一条件")
|
||||||
|
@PathVariable("id") Long id,
|
||||||
|
@Validated @RequestBody RuleDataUpdReq ruleDataUpdReq){
|
||||||
|
ruleDataService.updateById(RuleData.updBuild(ruleDataUpdReq,() -> id));
|
||||||
|
return Result.success(null,"操作成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除接口规则
|
||||||
|
* @param id 请求ID
|
||||||
|
* @return 删除结果
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/del/{id}")
|
||||||
|
@Operation(summary = "接口规则删除",description = "通过ID删除接口规则")
|
||||||
|
public Result<String> delete(@PathVariable("id") Long id){
|
||||||
|
ruleDataService.getOptById(id);
|
||||||
|
return Result.success(null,"操作成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ID获取接口规则信息
|
||||||
|
* @param id 请求ID
|
||||||
|
* @return 规则信息
|
||||||
|
*/
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
@Operation(summary = "根据ID获取客户信息",description = "通过ID获取接口规则信息")
|
||||||
|
public Result<RuleData> findById(@PathVariable("id") Long id){
|
||||||
|
return Result.success(ruleDataService.getById(id),"操作成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*通过ID禁用规则
|
||||||
|
* @param id 请求ID
|
||||||
|
* @return 禁用结果
|
||||||
|
*/
|
||||||
|
@GetMapping("/disable/{id}")
|
||||||
|
@Operation(summary = "通过ID禁用规则",description = "通过ID禁用规则之后,禁止用户在使用此规则")
|
||||||
|
public Result<String> disable(@PathVariable("id") Long id){
|
||||||
|
this.ruleDataService.disable(id);
|
||||||
|
return Result.success(null,"操作成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*通过ID启动规则
|
||||||
|
* @param id 请求ID
|
||||||
|
* @return 启动结果
|
||||||
|
*/
|
||||||
|
@GetMapping("/enable/{id}")
|
||||||
|
@Operation(summary = "通过ID启动规则",description = "通过ID禁用规则之后,禁止用户在使用此规则")
|
||||||
|
public Result<String> enable(@PathVariable("id") Long id){
|
||||||
|
this.ruleDataService.enable(id);
|
||||||
|
return Result.success(null,"操作成功");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.muyu.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.common.domain.resp.RuleDataResp;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.mapper
|
||||||
|
* @Project:cloud-rule
|
||||||
|
* @name:RuleDataInfoMapper
|
||||||
|
* @Date:2024/8/23 上午12:58
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface RuleDataInfoMapper extends BaseMapper<RuleDataResp> {
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.muyu.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.muyu.common.domain.RuleData;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.mapper
|
||||||
|
* @Project:cloud-rule
|
||||||
|
* @name:RuleDataMapper
|
||||||
|
* @Date:2024/8/22 下午10:20
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface RuleDataMapper extends BaseMapper<RuleData> {
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.muyu.servier;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.common.domain.resp.RuleDataResp;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.servier
|
||||||
|
* @Project:cloud-rule
|
||||||
|
* @name:RuleDataInfoService
|
||||||
|
* @Date:2024/8/23 上午12:57
|
||||||
|
*/
|
||||||
|
public interface RuleDataInfoService extends IService<RuleDataResp> {
|
||||||
|
List<RuleDataResp> selectRuleDataAndLimit(Long id, int limit);
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.muyu.servier;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.common.domain.RuleData;
|
||||||
|
import com.muyu.common.domain.req.RuleDataListReq;
|
||||||
|
import com.muyu.common.domain.resp.RuleDataResp;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.servier
|
||||||
|
* @Project:cloud-rule
|
||||||
|
* @name:RuleDataService
|
||||||
|
* @Date:2024/8/22 下午10:20
|
||||||
|
*/
|
||||||
|
public interface RuleDataService extends IService<RuleData> {
|
||||||
|
List<RuleDataResp> selectList(RuleDataListReq ruleDataListReq);
|
||||||
|
|
||||||
|
void disable(Long id);
|
||||||
|
|
||||||
|
void enable(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过规则ID设置规则状态
|
||||||
|
* @param id ID
|
||||||
|
* @param status 状态 SysIsYesNo
|
||||||
|
*/
|
||||||
|
public void settingStatus(Long id, String status);
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.muyu.servier.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.common.domain.resp.RuleDataResp;
|
||||||
|
import com.muyu.mapper.RuleDataInfoMapper;
|
||||||
|
import com.muyu.servier.RuleDataInfoService;
|
||||||
|
import com.muyu.servier.RuleDataService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.servier.impl
|
||||||
|
* @Project:cloud-rule
|
||||||
|
* @name:RuleDataInfoServiceImpl
|
||||||
|
* @Date:2024/8/23 上午12:58
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class RuleDataInfoServiceImpl
|
||||||
|
extends ServiceImpl<RuleDataInfoMapper, RuleDataResp>
|
||||||
|
implements RuleDataInfoService {
|
||||||
|
@Override
|
||||||
|
public List<RuleDataResp> selectRuleDataAndLimit(Long id, int limit) {
|
||||||
|
LambdaQueryWrapper<RuleDataResp> objectLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
objectLambdaQueryWrapper.eq(RuleDataResp::getId,id);
|
||||||
|
objectLambdaQueryWrapper.orderBy(true,false,RuleDataResp::getCreateTime);
|
||||||
|
objectLambdaQueryWrapper.last("limit "+limit);
|
||||||
|
return this.list(objectLambdaQueryWrapper);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
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.SystemYesNo;
|
||||||
|
import com.muyu.common.core.exception.ServiceException;
|
||||||
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
|
import com.muyu.common.domain.RuleData;
|
||||||
|
import com.muyu.common.domain.req.RuleDataListReq;
|
||||||
|
import com.muyu.common.domain.resp.RuleDataResp;
|
||||||
|
import com.muyu.mapper.RuleDataMapper;
|
||||||
|
import com.muyu.servier.RuleDataInfoService;
|
||||||
|
import com.muyu.servier.RuleDataService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:蓬叁
|
||||||
|
* @Package:com.muyu.servier.impl
|
||||||
|
* @Project:cloud-rule
|
||||||
|
* @name:RuleDataServiceImpl
|
||||||
|
* @Date:2024/8/22 下午10:21
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class RuleDataServiceImpl
|
||||||
|
extends ServiceImpl<RuleDataMapper, RuleData>
|
||||||
|
implements RuleDataService {
|
||||||
|
|
||||||
|
@Autowired private RuleDataMapper ruleDataMapper;
|
||||||
|
@Autowired private RuleDataService ruleDataService;
|
||||||
|
@Autowired private RuleDataInfoService ruleDataInfoService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RuleDataResp> selectList(RuleDataListReq ruleDataListReq) {
|
||||||
|
LambdaQueryWrapper<RuleData> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.like(
|
||||||
|
StringUtils.isNotEmpty(ruleDataListReq.getRuleName()),
|
||||||
|
RuleData::getRuleName, ruleDataListReq.getRuleName()
|
||||||
|
);
|
||||||
|
queryWrapper.eq(
|
||||||
|
StringUtils.isNotEmpty(ruleDataListReq.getCreateBy()),
|
||||||
|
RuleData::getCreateBy, ruleDataListReq.getCreateBy()
|
||||||
|
);
|
||||||
|
queryWrapper.eq(
|
||||||
|
StringUtils.isNotEmpty(ruleDataListReq.getRuleStatus()),
|
||||||
|
RuleData::getRuleStatus, ruleDataListReq.getRuleStatus()
|
||||||
|
);
|
||||||
|
List<RuleData> ruleDataList = this.list(queryWrapper);
|
||||||
|
return ruleDataList.stream()
|
||||||
|
.map(ruleData -> RuleDataResp.ruleDataBuild(ruleData,() ->
|
||||||
|
ruleDataInfoService.selectRuleDataAndLimit(ruleData.getId(),5)
|
||||||
|
.stream()
|
||||||
|
.toList()
|
||||||
|
))
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable(Long id) {
|
||||||
|
this.settingStatus(id, SystemYesNo.NO.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enable(Long id) {
|
||||||
|
this.settingStatus(id, SystemYesNo.YES.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void settingStatus(Long id, String status) {
|
||||||
|
LambdaQueryWrapper<RuleData> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(RuleData::getId,id);
|
||||||
|
boolean isExists = this.exists(queryWrapper);
|
||||||
|
if (!isExists) {
|
||||||
|
throw new ServiceException("操作规则不存在");
|
||||||
|
}
|
||||||
|
if (SystemYesNo.isCode(status)){
|
||||||
|
throw new ServiceException("设置状态值违法");
|
||||||
|
}
|
||||||
|
LambdaUpdateWrapper<RuleData> updateWrapper = new LambdaUpdateWrapper<>();
|
||||||
|
updateWrapper.eq(RuleData::getId,id);
|
||||||
|
updateWrapper.set(RuleData::getRuleStatus,status);
|
||||||
|
this.update(updateWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue