parent
1152e9b42c
commit
91e03bee52
@ -0,0 +1,34 @@ |
||||
package rition.backend.api.v1.dto.response; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Builder; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
import java.time.Instant; |
||||
|
||||
@Data |
||||
@Builder |
||||
@NoArgsConstructor |
||||
@AllArgsConstructor |
||||
public class AlertResponse { |
||||
/** |
||||
* id |
||||
*/ |
||||
private Long id; |
||||
|
||||
/** |
||||
* 出现警告的实例id |
||||
*/ |
||||
private String instanceId; |
||||
|
||||
/** |
||||
* 触发的规则 |
||||
*/ |
||||
private Long rule; |
||||
|
||||
/** |
||||
* 警告出现的时间 |
||||
*/ |
||||
private Instant time; |
||||
} |
@ -0,0 +1,34 @@ |
||||
package rition.backend.api.v1.dto.response; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Builder; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
import java.time.Instant; |
||||
|
||||
@Data |
||||
@Builder |
||||
@NoArgsConstructor |
||||
@AllArgsConstructor |
||||
public class ContractResponse { |
||||
/** |
||||
* id |
||||
*/ |
||||
private Long id; |
||||
|
||||
/** |
||||
* 联系方式 |
||||
*/ |
||||
private String contract; |
||||
|
||||
/** |
||||
* 联系方式类型 |
||||
*/ |
||||
private Integer type; |
||||
|
||||
/** |
||||
* create_time |
||||
*/ |
||||
private Instant createTime; |
||||
} |
@ -0,0 +1,54 @@ |
||||
package rition.backend.api.v1.dto.response; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Builder; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
import java.time.Instant; |
||||
|
||||
@Data |
||||
@Builder |
||||
@AllArgsConstructor |
||||
@NoArgsConstructor |
||||
public class RuleResponse { |
||||
/** |
||||
* 规则id |
||||
*/ |
||||
private Long id; |
||||
|
||||
/** |
||||
* 需要计算的指标项或者表达式 |
||||
*/ |
||||
private String expression; |
||||
|
||||
/** |
||||
* 触发条件 |
||||
*/ |
||||
private Integer condition; |
||||
|
||||
/** |
||||
* 阈值 |
||||
*/ |
||||
private Double threshold; |
||||
|
||||
/** |
||||
* 触发方法,实时计算或定时计算 |
||||
*/ |
||||
private Integer trigger; |
||||
|
||||
/** |
||||
* 规则描述 |
||||
*/ |
||||
private String description; |
||||
|
||||
/** |
||||
* create_time |
||||
*/ |
||||
private Instant createTime; |
||||
|
||||
/** |
||||
* update_time |
||||
*/ |
||||
private Instant updateTime; |
||||
} |
@ -0,0 +1,33 @@ |
||||
package rition.backend.api.v1.panel; |
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
import rition.backend.api.v1.dto.response.Response; |
||||
import rition.common.data.dto.PagingData; |
||||
import rition.common.data.entity.AlertEntity; |
||||
import rition.service.panel.AlertHistoryService; |
||||
|
||||
@RestController |
||||
@RequestMapping("/panel/alerts") |
||||
public class AlertHistoryController { |
||||
private final AlertHistoryService alertHistoryService; |
||||
|
||||
public AlertHistoryController(AlertHistoryService alertHistoryService) { |
||||
this.alertHistoryService = alertHistoryService; |
||||
} |
||||
|
||||
@GetMapping("/list") |
||||
public Response<PagingData<AlertEntity>> getContractList( |
||||
@RequestParam(value = "instance_id", required = false) String instanceId, |
||||
@RequestParam(value = "page", required = false, defaultValue = "1") Integer page, |
||||
@RequestParam(value = "page_size", required = false, defaultValue = "10") Integer pageSize |
||||
) { |
||||
|
||||
PagingData<AlertEntity> alertEntityPagingData = new PagingData<>(page, pageSize); |
||||
var result = alertHistoryService.getAlertHistory(instanceId, alertEntityPagingData); |
||||
|
||||
return Response.success(result); |
||||
} |
||||
} |
@ -1,10 +0,0 @@ |
||||
package rition.backend.api.v1.panel; |
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
@RestController |
||||
@RequestMapping("/panel") |
||||
public class PanelController { |
||||
|
||||
} |
@ -0,0 +1,35 @@ |
||||
package rition.backend.configure; |
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI; |
||||
import io.swagger.v3.oas.models.info.Info; |
||||
import io.swagger.v3.oas.models.servers.Server; |
||||
import lombok.Getter; |
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.util.ArrayList; |
||||
|
||||
@Getter |
||||
@Component |
||||
@Configuration |
||||
public class OpenAPIConfigure { |
||||
private String serverUrl; |
||||
|
||||
@Value("${wusthelper.docs.server-url:/}") |
||||
public void setServerUrl(String serverUrl) { |
||||
this.serverUrl = serverUrl; |
||||
} |
||||
|
||||
@Bean |
||||
public OpenAPI openAPI() { |
||||
var info = new Info() |
||||
.title("Rition-center") |
||||
.description("Rition-center api") |
||||
.version("v1"); |
||||
|
||||
return new OpenAPI() |
||||
.info(info); |
||||
} |
||||
} |
@ -0,0 +1,7 @@ |
||||
package rition.backend.service.panel; |
||||
|
||||
import org.springframework.stereotype.Service; |
||||
|
||||
@Service |
||||
public class PanelMetricService { |
||||
} |
@ -0,0 +1,39 @@ |
||||
package panel; |
||||
|
||||
import org.junit.jupiter.api.Test; |
||||
import org.mybatis.spring.boot.test.autoconfigure.AutoConfigureMybatis; |
||||
import org.mybatis.spring.boot.test.autoconfigure.MybatisTest; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; |
||||
import org.springframework.boot.test.context.SpringBootTest; |
||||
import org.springframework.test.context.ContextConfiguration; |
||||
import rition.backend.RitionBackendMain; |
||||
import rition.common.data.dao.mapper.MetricRecordMapper; |
||||
|
||||
import java.time.Instant; |
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
|
||||
@MybatisTest |
||||
@ContextConfiguration(classes = RitionBackendMain.class) |
||||
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) |
||||
public class MetricServiceTest { |
||||
@Autowired |
||||
MetricRecordMapper metricRecordMapper; |
||||
|
||||
@Test |
||||
public void testGetMetricRecord() { |
||||
List<String> metricItems = new ArrayList<>(); |
||||
metricItems.add("node_network_receive_packets_total"); |
||||
metricItems.add("node_sockstat_TCP_tw"); |
||||
var result = metricRecordMapper.getMetricDataGroupByHour( |
||||
"7273a1ea-0089-4674-b606-b1b8d809d866", |
||||
metricItems, |
||||
Instant.parse("2024-04-17T14:00:00.00Z"), |
||||
Instant.parse("2024-04-17T16:00:00.00Z") |
||||
); |
||||
|
||||
System.out.println(Arrays.toString(result.toArray())); |
||||
} |
||||
} |
@ -0,0 +1,21 @@ |
||||
package rition.common.configure; |
||||
|
||||
import org.springframework.context.annotation.Bean; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.core.io.ClassPathResource; |
||||
import org.springframework.core.io.Resource; |
||||
import org.springframework.data.redis.core.script.DefaultRedisScript; |
||||
import org.springframework.data.redis.core.script.RedisScript; |
||||
import org.springframework.scripting.support.ResourceScriptSource; |
||||
|
||||
@Configuration |
||||
public class RedisLuaConfigure { |
||||
@Bean(name = "constLenQueueRedisScript") |
||||
public RedisScript<Object> constLenQueueRedisScript() { |
||||
Resource luaResource = new ClassPathResource("redis/const_len_queue.lua"); |
||||
DefaultRedisScript<Object> redisScript = new DefaultRedisScript<>(); |
||||
redisScript.setScriptSource(new ResourceScriptSource(luaResource)); |
||||
|
||||
return redisScript; |
||||
} |
||||
} |
@ -0,0 +1,9 @@ |
||||
package rition.common.data.dao.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import rition.common.data.entity.AlertEntity; |
||||
|
||||
@Mapper |
||||
public interface AlertMapper extends BaseMapper<AlertEntity> { |
||||
} |
@ -0,0 +1,7 @@ |
||||
package rition.common.data.dao.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import rition.common.data.entity.ContractEntity; |
||||
|
||||
public interface ContractMapper extends BaseMapper<ContractEntity> { |
||||
} |
@ -0,0 +1,9 @@ |
||||
package rition.common.data.dao.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import rition.common.data.entity.RuleEntity; |
||||
|
||||
@Mapper |
||||
public interface RuleMapper extends BaseMapper<RuleEntity> { |
||||
} |
@ -0,0 +1,52 @@ |
||||
package rition.common.data.dto; |
||||
|
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Builder; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
import java.util.Collection; |
||||
|
||||
@Data |
||||
@Builder |
||||
@NoArgsConstructor |
||||
@AllArgsConstructor |
||||
public class PagingData<T> { |
||||
private long currentPage; |
||||
private long pageSize; |
||||
private long totalPage; |
||||
|
||||
private long totalResult; |
||||
|
||||
private Collection<T> data; |
||||
|
||||
public PagingData(long currentPage, long pageSize) { |
||||
this.currentPage = currentPage; |
||||
this.pageSize = pageSize; |
||||
} |
||||
|
||||
public PagingData<T> copy() { |
||||
PagingData<T> pagingData = new PagingData<>(); |
||||
|
||||
pagingData.setCurrentPage(this.getCurrentPage()); |
||||
pagingData.setPageSize(this.getPageSize()); |
||||
pagingData.setTotalPage(this.getTotalPage()); |
||||
pagingData.setTotalResult(this.getTotalResult()); |
||||
pagingData.setData(this.getData()); |
||||
|
||||
return pagingData; |
||||
} |
||||
|
||||
public static <K> PagingData<K> copyOnlyPagingValues(PagingData<?> source) { |
||||
PagingData<K> pagingData = new PagingData<>(); |
||||
|
||||
pagingData.setCurrentPage(source.getCurrentPage()); |
||||
pagingData.setPageSize(source.getPageSize()); |
||||
pagingData.setTotalPage(source.getTotalPage()); |
||||
pagingData.setTotalResult(source.getTotalResult()); |
||||
|
||||
return pagingData; |
||||
} |
||||
} |
||||
|
@ -0,0 +1,54 @@ |
||||
package rition.common.data.dto.service; |
||||
|
||||
import lombok.AllArgsConstructor; |
||||
import lombok.Builder; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
import java.time.Instant; |
||||
|
||||
@Data |
||||
@Builder |
||||
@AllArgsConstructor |
||||
@NoArgsConstructor |
||||
public class AlertRuleDto { |
||||
/** |
||||
* 规则id |
||||
*/ |
||||
private Long id; |
||||
|
||||
/** |
||||
* 规则对应的实例id |
||||
*/ |
||||
private String instanceId; |
||||
|
||||
/** |
||||
* 需要计算的指标项或者表达式 |
||||
*/ |
||||
private String expression; |
||||
|
||||
/** |
||||
* 触发条件 |
||||
*/ |
||||
private Integer condition; |
||||
|
||||
/** |
||||
* 阈值 |
||||
*/ |
||||
private Double threshold; |
||||
|
||||
/** |
||||
* 触发方法,实时计算或定时计算 |
||||
*/ |
||||
private Integer trigger; |
||||
|
||||
/** |
||||
* 规则描述 |
||||
*/ |
||||
private String description; |
||||
|
||||
/** |
||||
* create_time |
||||
*/ |
||||
private Instant createTime; |
||||
} |
@ -0,0 +1,36 @@ |
||||
package rition.common.data.dto.service.panel; |
||||
|
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class AlertRuleAddDto { |
||||
/** |
||||
* 规则对应的实例id |
||||
*/ |
||||
private String instanceId; |
||||
|
||||
/** |
||||
* 需要计算的指标项或者表达式 |
||||
*/ |
||||
private String expression; |
||||
|
||||
/** |
||||
* 触发条件 |
||||
*/ |
||||
private Integer condition; |
||||
|
||||
/** |
||||
* 阈值 |
||||
*/ |
||||
private Double threshold; |
||||
|
||||
/** |
||||
* 触发方法,实时计算或定时计算 |
||||
*/ |
||||
private Integer trigger; |
||||
|
||||
/** |
||||
* 规则描述 |
||||
*/ |
||||
private String description; |
||||
} |
@ -0,0 +1,36 @@ |
||||
package rition.common.data.dto.service.panel; |
||||
|
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class AlertRuleDto { |
||||
/** |
||||
* 规则对应的实例id |
||||
*/ |
||||
private String instanceId; |
||||
|
||||
/** |
||||
* 需要计算的指标项或者表达式 |
||||
*/ |
||||
private String expression; |
||||
|
||||
/** |
||||
* 触发条件 |
||||
*/ |
||||
private Integer condition; |
||||
|
||||
/** |
||||
* 阈值 |
||||
*/ |
||||
private Double threshold; |
||||
|
||||
/** |
||||
* 触发方法,实时计算或定时计算 |
||||
*/ |
||||
private Integer trigger; |
||||
|
||||
/** |
||||
* 规则描述 |
||||
*/ |
||||
private String description; |
||||
} |
@ -0,0 +1,17 @@ |
||||
package rition.common.data.dto.service.panel; |
||||
|
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class ContractAddDto { |
||||
|
||||
/** |
||||
* 联系方式 |
||||
*/ |
||||
private String contract; |
||||
|
||||
/** |
||||
* 联系方式类型 |
||||
*/ |
||||
private Integer type; |
||||
} |
@ -0,0 +1,7 @@ |
||||
local key = KEYS[1] |
||||
local max_len = tonumber(ARGV[1]) |
||||
local val = ARGV[2] |
||||
if (redis.call('llen', key) > max_len) then |
||||
redis.call('lpop', key) |
||||
end |
||||
redis.call('rpush', key, val) |
@ -0,0 +1,48 @@ |
||||
package rition.service.panel; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import org.springframework.stereotype.Service; |
||||
import rition.common.data.dao.mapper.AlertMapper; |
||||
import rition.common.data.dto.PagingData; |
||||
import rition.common.data.entity.AlertEntity; |
||||
import rition.common.data.enums.Constants; |
||||
|
||||
@Service |
||||
public class AlertHistoryService { |
||||
private final AlertMapper alertMapper; |
||||
|
||||
public AlertHistoryService(AlertMapper alertMapper) { |
||||
this.alertMapper = alertMapper; |
||||
} |
||||
|
||||
/** |
||||
* 分页获取报警信息 |
||||
* |
||||
* @param instanceId 实例id |
||||
* @param pagingData 分页数据,查询完成后会对此对象进行修改 |
||||
* @return 分页数据,含结果,实际上与参数里的pagingData是同一个对象 |
||||
*/ |
||||
public PagingData<AlertEntity> getAlertHistory(String instanceId, PagingData<AlertEntity> pagingData) { |
||||
LambdaQueryWrapper<AlertEntity> query; |
||||
if (instanceId != null) { |
||||
query = new LambdaQueryWrapper<AlertEntity>() |
||||
.eq(AlertEntity::getInstanceId, instanceId) |
||||
.eq(AlertEntity::getStatus, Constants.EntityCommonStatus.NORMAL); |
||||
} else { |
||||
query = new LambdaQueryWrapper<AlertEntity>() |
||||
.eq(AlertEntity::getStatus, Constants.EntityCommonStatus.NORMAL); |
||||
} |
||||
|
||||
Page<AlertEntity> page = new Page<>(pagingData.getCurrentPage(), pagingData.getPageSize()); |
||||
var result = alertMapper.selectPage(page, query); |
||||
|
||||
pagingData.setData(result.getRecords()); |
||||
pagingData.setTotalResult(result.getTotal()); |
||||
pagingData.setTotalPage(result.getPages()); |
||||
pagingData.setCurrentPage(result.getCurrent()); |
||||
pagingData.setPageSize(result.getSize()); |
||||
|
||||
return pagingData; |
||||
} |
||||
} |
@ -0,0 +1,78 @@ |
||||
package rition.service.panel; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
||||
import com.github.yitter.idgen.YitIdHelper; |
||||
import org.springframework.data.redis.core.RedisTemplate; |
||||
import org.springframework.stereotype.Service; |
||||
import rition.common.data.dao.mapper.RuleMapper; |
||||
import rition.common.data.dto.service.AlertRuleDto; |
||||
import rition.common.data.dto.service.panel.AlertRuleAddDto; |
||||
import rition.common.data.entity.RuleEntity; |
||||
import rition.common.data.enums.Constants; |
||||
|
||||
import java.time.Instant; |
||||
import java.util.List; |
||||
|
||||
@Service |
||||
public class AlertRuleService { |
||||
|
||||
private final RuleMapper ruleMapper; |
||||
private final RedisTemplate<String, AlertRuleDto> redisTemplate; |
||||
|
||||
public AlertRuleService(RuleMapper ruleMapper, |
||||
RedisTemplate<String, AlertRuleDto> redisTemplate) { |
||||
this.ruleMapper = ruleMapper; |
||||
this.redisTemplate = redisTemplate; |
||||
} |
||||
|
||||
public void addAlertRule(AlertRuleAddDto alertRuleAddDto) { |
||||
RuleEntity ruleEntity = new RuleEntity(); |
||||
ruleEntity.setId(YitIdHelper.nextId()); |
||||
ruleEntity.setExpression(alertRuleAddDto.getExpression()); |
||||
ruleEntity.setCondition(alertRuleAddDto.getCondition()); |
||||
ruleEntity.setThreshold(alertRuleAddDto.getThreshold()); |
||||
ruleEntity.setTrigger(alertRuleAddDto.getTrigger()); |
||||
ruleEntity.setDescription(alertRuleAddDto.getDescription()); |
||||
|
||||
var now = Instant.now(); |
||||
ruleEntity.setCreateTime(now); |
||||
ruleEntity.setUpdateTime(now); |
||||
ruleEntity.setStatus(Constants.EntityCommonStatus.NORMAL); |
||||
|
||||
ruleMapper.insert(ruleEntity); |
||||
|
||||
AlertRuleDto alertRuleDto = new AlertRuleDto(); |
||||
alertRuleDto.setId(ruleEntity.getId()); |
||||
alertRuleDto.setExpression(ruleEntity.getExpression()); |
||||
alertRuleDto.setCondition(ruleEntity.getCondition()); |
||||
alertRuleDto.setThreshold(ruleEntity.getThreshold()); |
||||
alertRuleDto.setTrigger(ruleEntity.getTrigger()); |
||||
alertRuleDto.setDescription(ruleEntity.getDescription()); |
||||
alertRuleDto.setCreateTime(now); |
||||
|
||||
// 规则缓存到redis
|
||||
redisTemplate.opsForHash().put(Constants.RedisKeys.RULE_CACHE, alertRuleDto.getId(), alertRuleDto); |
||||
} |
||||
|
||||
public List<RuleEntity> getRule() { |
||||
var query = new LambdaQueryWrapper<RuleEntity>() |
||||
.eq(RuleEntity::getStatus, Constants.EntityCommonStatus.NORMAL); |
||||
|
||||
return ruleMapper.selectList(query); |
||||
} |
||||
|
||||
public int deleteRule(Long ruleId) { |
||||
var query = new LambdaUpdateWrapper<RuleEntity>() |
||||
.set(RuleEntity::getStatus, Constants.EntityCommonStatus.DELETED) |
||||
.eq(RuleEntity::getId, ruleId) |
||||
.eq(RuleEntity::getStatus, Constants.EntityCommonStatus.NORMAL); |
||||
var updatedRows = ruleMapper.update(query); |
||||
// 删除相应的缓存
|
||||
if (updatedRows != 0) { |
||||
redisTemplate.opsForHash().delete(Constants.RedisKeys.RULE_CACHE, ruleId); |
||||
} |
||||
|
||||
return updatedRows; |
||||
} |
||||
} |
@ -0,0 +1,64 @@ |
||||
package rition.service.panel; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
||||
import com.github.yitter.idgen.YitIdHelper; |
||||
import org.springframework.stereotype.Service; |
||||
import rition.common.data.dao.mapper.ContractMapper; |
||||
import rition.common.data.dto.service.panel.ContractAddDto; |
||||
import rition.common.data.entity.ContractEntity; |
||||
import rition.common.data.enums.Constants; |
||||
import rition.common.exception.ServiceException; |
||||
import rition.common.exception.code.ServiceCode; |
||||
|
||||
import java.time.Instant; |
||||
import java.util.List; |
||||
|
||||
@Service |
||||
public class ContractService { |
||||
|
||||
private final ContractMapper contractMapper; |
||||
|
||||
public ContractService(ContractMapper contractMapper) { |
||||
this.contractMapper = contractMapper; |
||||
} |
||||
|
||||
public List<ContractEntity> getContractList() { |
||||
var query = new LambdaQueryWrapper<ContractEntity>() |
||||
.eq(ContractEntity::getStatus, Constants.EntityCommonStatus.NORMAL) |
||||
.last("limit 100"); |
||||
|
||||
return contractMapper.selectList(query); |
||||
} |
||||
|
||||
private static final int MAX_CONTRACT_NUM = 20; |
||||
|
||||
public void addContract(ContractAddDto contractAddDto) { |
||||
var countQuery = new LambdaQueryWrapper<ContractEntity>() |
||||
.eq(ContractEntity::getStatus, Constants.EntityCommonStatus.NORMAL); |
||||
var count = contractMapper.selectCount(countQuery); |
||||
if (count > MAX_CONTRACT_NUM) { |
||||
ServiceException.error(ServiceCode.ContractTooManyData); |
||||
} |
||||
|
||||
var now = Instant.now(); |
||||
var entity = ContractEntity.builder() |
||||
.id(YitIdHelper.nextId()) |
||||
.contract(contractAddDto.getContract()) |
||||
.type(contractAddDto.getType()) |
||||
.createTime(now) |
||||
.updateTime(now) |
||||
.status(Constants.EntityCommonStatus.NORMAL) |
||||
.build(); |
||||
|
||||
contractMapper.insert(entity); |
||||
} |
||||
|
||||
public void deleteContract(Long id) { |
||||
var query = new LambdaUpdateWrapper<ContractEntity>() |
||||
.set(ContractEntity::getStatus, Constants.EntityCommonStatus.DELETED) |
||||
.eq(ContractEntity::getId, id) |
||||
.eq(ContractEntity::getStatus, Constants.EntityCommonStatus.NORMAL); |
||||
contractMapper.update(query); |
||||
} |
||||
} |
@ -1,7 +0,0 @@ |
||||
package rition.service.panel; |
||||
|
||||
import org.springframework.stereotype.Service; |
||||
|
||||
@Service |
||||
public class PanelService { |
||||
} |
Loading…
Reference in new issue