二次更改

dev.saas.customer
chentaisen 2024-09-25 15:49:41 +08:00 committed by 少年梦与砖
parent f4cd9174e2
commit 9d0cbb6b8d
9 changed files with 70 additions and 68 deletions

View File

@ -3,7 +3,9 @@ package com.muyu.warning.domain;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.muyu.common.core.annotation.Excel; import com.muyu.common.core.annotation.Excel;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* @ClassName WarnRule * @ClassName WarnRule
@ -12,6 +14,8 @@ import lombok.Data;
* @Date 2024/9/22 11:53 * @Date 2024/9/22 11:53
*/ */
@Data @Data
@AllArgsConstructor
@NoArgsConstructor
public class WarnRuleDTO { public class WarnRuleDTO {
/** 规则id */ /** 规则id */
@TableId( type = IdType.AUTO) @TableId( type = IdType.AUTO)

View File

@ -6,6 +6,7 @@ import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.yulichang.query.MPJLambdaQueryWrapper; import com.github.yulichang.query.MPJLambdaQueryWrapper;
import com.muyu.warning.domain.WarnRule; import com.muyu.warning.domain.WarnRule;
import com.muyu.warning.domain.WarnRuleDTO;
import com.muyu.warning.domain.WarnStrategy; import com.muyu.warning.domain.WarnStrategy;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
@ -45,9 +46,9 @@ public class WarnRuleController extends BaseController {
*/ */
@RequiresPermissions("warning:list") @RequiresPermissions("warning:list")
@GetMapping("/list") @GetMapping("/list")
public Result<TableDataInfo<WarnRule>> list(WarnRule warnRule) { public Result<TableDataInfo<WarnRuleDTO>> list(WarnRuleDTO warnRuleDTO) {
startPage(); startPage();
List<WarnRule> list = warnRuleService.selectWarnRuleList(warnRule); List<WarnRuleDTO> list = warnRuleService.selectWarnRuleList(warnRuleDTO);
// MPJLambdaQueryWrapper<WarnRule> objectMPJLambdaQueryWrapper = new MPJLambdaQueryWrapper<>() // MPJLambdaQueryWrapper<WarnRule> objectMPJLambdaQueryWrapper = new MPJLambdaQueryWrapper<>()
// .selectAll(WarnRule.class) // .selectAll(WarnRule.class)
// .select(WarnStrategy::getStrategyName) // .select(WarnStrategy::getStrategyName)
@ -61,9 +62,9 @@ public class WarnRuleController extends BaseController {
*/ */
@RequiresPermissions("warning:export") @RequiresPermissions("warning:export")
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, WarnRule warnRule) { public void export(HttpServletResponse response, WarnRuleDTO warnRuleDTO) {
List<WarnRule> list = warnRuleService.selectWarnRuleList(warnRule); List<WarnRuleDTO> list = warnRuleService.selectWarnRuleList(warnRuleDTO);
ExcelUtil<WarnRule> util = new ExcelUtil<WarnRule>(WarnRule.class); ExcelUtil<WarnRuleDTO> util = new ExcelUtil<WarnRuleDTO>(WarnRuleDTO.class);
util.exportExcel(response, list, "预警规则数据"); util.exportExcel(response, list, "预警规则数据");
} }
@ -82,11 +83,11 @@ public class WarnRuleController extends BaseController {
@RequiresPermissions("warning:add") @RequiresPermissions("warning:add")
@PostMapping @PostMapping
public Result<Integer> add( public Result<Integer> add(
@Validated @RequestBody WarnRule warnRule) { @Validated @RequestBody WarnRuleDTO warnRuleDTO) {
if (warnRuleService.checkIdUnique(warnRule)) { if (warnRuleService.checkIdUnique(warnRuleDTO)) {
return error("新增 预警规则 '" + warnRule + "'失败,预警规则已存在"); return error("新增 预警规则 '" + warnRuleDTO + "'失败,预警规则已存在");
} }
return toAjax(warnRuleService.save(warnRule)); return toAjax(warnRuleService.save(warnRuleDTO));
} }
/** /**
@ -95,11 +96,11 @@ public class WarnRuleController extends BaseController {
@RequiresPermissions("warning:edit") @RequiresPermissions("warning:edit")
@PutMapping @PutMapping
public Result<Integer> edit( public Result<Integer> edit(
@Validated @RequestBody WarnRule warnRule) { @Validated @RequestBody WarnRuleDTO warnRuleDTO) {
if (!warnRuleService.checkIdUnique(warnRule)) { if (!warnRuleService.checkIdUnique(warnRuleDTO)) {
return error("修改 预警规则 '" + warnRule + "'失败,预警规则不存在"); return error("修改 预警规则 '" + warnRuleDTO + "'失败,预警规则不存在");
} }
return toAjax(warnRuleService.updateById(warnRule)); return toAjax(warnRuleService.updateById(warnRuleDTO));
} }
/** /**

View File

@ -35,6 +35,12 @@ public class WarnRulesController {
return Result.success(list); return Result.success(list);
} }
/**
*
*
* @param warnRuleDTO
* @return
*/
@PostMapping("/listAll") @PostMapping("/listAll")
public Result<List<WarnRuleDTO>> listAll(WarnRuleDTO warnRuleDTO) { public Result<List<WarnRuleDTO>> listAll(WarnRuleDTO warnRuleDTO) {
List<WarnRuleDTO> list = warnRulesService.selectWarnRulesListAll(warnRuleDTO); List<WarnRuleDTO> list = warnRulesService.selectWarnRulesListAll(warnRuleDTO);

View File

@ -4,6 +4,7 @@ import com.github.yulichang.base.MPJBaseMapper;
import com.muyu.warning.domain.WarnRule; import com.muyu.warning.domain.WarnRule;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.warning.domain.WarnRule; import com.muyu.warning.domain.WarnRule;
import com.muyu.warning.domain.WarnRuleDTO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
/** /**
@ -13,6 +14,6 @@ import org.apache.ibatis.annotations.Mapper;
* @date 2024-09-20 * @date 2024-09-20
*/ */
@Mapper @Mapper
public interface WarnRuleMapper extends MPJBaseMapper<WarnRule> { public interface WarnRuleMapper extends BaseMapper<WarnRuleDTO> {
} }

View File

@ -15,7 +15,7 @@ import java.util.List;
*/ */
@Mapper @Mapper
public interface WarnRulesMapper extends BaseMapper<WarnRuleDTO> { public interface WarnRulesMapper extends BaseMapper<WarnRuleDTO> {
@Select("select r.*,s.strategy_name FROM warn_rule r left join warn_strategy s on r.strategy_id=s.id") @Select("select r.*,s.id,s.strategy_name FROM warn_rule r left join warn_strategy s on r.strategy_id=s.id where r.strategy_id = #{s.id}")
List<WarnRuleDTO> selectWarnRulesListAll(WarnRuleDTO warnRuleDTO); List<WarnRuleDTO> selectWarnRulesListAll(WarnRuleDTO warnRuleDTO);
} }

View File

@ -8,7 +8,7 @@ import java.util.List;
public interface IWarRulesService extends IService<WarnRuleDTO> { public interface IWarRulesService extends IService<WarnRuleDTO> {
List<WarnRuleDTO> selectWarnRulesList(); List<WarnRuleDTO> selectWarnRulesList();
//联查
List<WarnRuleDTO> selectWarnRulesListAll(WarnRuleDTO warnRuleDTO); List<WarnRuleDTO> selectWarnRulesListAll(WarnRuleDTO warnRuleDTO);
} }

View File

@ -1,11 +1,10 @@
package com.muyu.warning.service; package com.muyu.warning.service;
import java.util.List;
import com.github.yulichang.base.MPJBaseService;
import com.muyu.warning.domain.WarnRule;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.warning.domain.WarnRule; import com.github.yulichang.base.MPJBaseService;
import com.muyu.warning.domain.WarnRuleDTO;
import java.util.List;
/** /**
* Service * Service
@ -13,28 +12,28 @@ import com.muyu.warning.domain.WarnRule;
* @author muyu * @author muyu
* @date 2024-09-20 * @date 2024-09-20
*/ */
public interface IWarnRuleService extends MPJBaseService<WarnRule> { public interface IWarnRuleService extends IService<WarnRuleDTO> {
/** /**
* *
* *
* @param id * @param id
* @return * @return
*/ */
public WarnRule selectWarnRuleById(Long id); public WarnRuleDTO selectWarnRuleById(Long id);
/** /**
* *
* *
* @param warnRule * @param warnRuleDTO
* @return * @return
*/ */
public List<WarnRule> selectWarnRuleList(WarnRule warnRule); public List<WarnRuleDTO> selectWarnRuleList(WarnRuleDTO warnRuleDTO);
/** /**
* id * id
* @param warnRule * @param warnRuleDTO
* @return * @return
*/ */
Boolean checkIdUnique(WarnRule warnRule); Boolean checkIdUnique(WarnRuleDTO warnRuleDTO);
} }

View File

@ -1,25 +1,18 @@
package com.muyu.warning.service.impl; package com.muyu.warning.service.impl;
import java.util.List;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.github.yulichang.query.MPJLambdaQueryWrapper;
import com.github.yulichang.query.MPJQueryWrapper;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.muyu.warning.domain.WarnLogs;
import com.muyu.warning.domain.WarnRule;
import com.muyu.warning.domain.WarnStrategy;
import com.muyu.warning.mapper.WarnRuleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.muyu.warning.domain.WarnRule;
import com.muyu.warning.service.IWarnRuleService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.muyu.common.core.utils.StringUtils; import com.muyu.common.core.utils.StringUtils;
import com.muyu.warning.domain.WarnRuleDTO;
import com.muyu.warning.mapper.WarnRuleMapper;
import com.muyu.warning.service.IWarnRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import java.util.List;
/** /**
* Service * Service
* *
@ -28,10 +21,9 @@ import org.springframework.util.Assert;
*/ */
@Service @Service
public class WarnRuleServiceImpl public class WarnRuleServiceImpl
extends MPJBaseServiceImpl<WarnRuleMapper, WarnRule> extends ServiceImpl<WarnRuleMapper, WarnRuleDTO>
implements IWarnRuleService { implements IWarnRuleService {
@Autowired
private WarnRuleMapper warnRuleMapper;
/** /**
* *
@ -40,10 +32,10 @@ public class WarnRuleServiceImpl
* @return * @return
*/ */
@Override @Override
public WarnRule selectWarnRuleById(Long id) { public WarnRuleDTO selectWarnRuleById(Long id) {
LambdaQueryWrapper<WarnRule> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<WarnRuleDTO> queryWrapper = new LambdaQueryWrapper<>();
Assert.notNull(id, "id不可为空"); Assert.notNull(id, "id不可为空");
queryWrapper.eq(WarnRule::getId, id); queryWrapper.eq(WarnRuleDTO::getId, id);
return this.getOne(queryWrapper); return this.getOne(queryWrapper);
} }
@ -51,11 +43,11 @@ public class WarnRuleServiceImpl
/** /**
* *
* *
* @param warnRule * @param warnRuleDTO
* @return * @return
*/ */
@Override @Override
public List<WarnRule> selectWarnRuleList(WarnRule warnRule) { public List<WarnRuleDTO> selectWarnRuleList(WarnRuleDTO warnRuleDTO) {
// MPJLambdaWrapper<WarnRule> queryWrapper = new MPJLambdaWrapper<WarnRule>() // MPJLambdaWrapper<WarnRule> queryWrapper = new MPJLambdaWrapper<WarnRule>()
// .selectAll(WarnRule.class) // .selectAll(WarnRule.class)
@ -75,25 +67,25 @@ public class WarnRuleServiceImpl
// } // }
// //
LambdaQueryWrapper<WarnRule> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<WarnRuleDTO> queryWrapper = new LambdaQueryWrapper<>();
if (StringUtils.isNotNull(warnRule.getStrategyId())) { if (StringUtils.isNotNull(warnRuleDTO.getStrategyId())) {
queryWrapper.eq(WarnRule::getStrategyId, warnRule.getStrategyId()); queryWrapper.eq(WarnRuleDTO::getStrategyId, warnRuleDTO.getStrategyId());
// queryWrapper.eq("strategy_id", warnRule.getStrategyId()); // queryWrapper.eq("strategy_id", warnRule.getStrategyId());
} }
if (StringUtils.isNotNull(warnRule.getMsgTypeId())) { if (StringUtils.isNotNull(warnRuleDTO.getMsgTypeId())) {
queryWrapper.eq(WarnRule::getMsgTypeId, warnRule.getMsgTypeId()); queryWrapper.eq(WarnRuleDTO::getMsgTypeId, warnRuleDTO.getMsgTypeId());
} }
if (StringUtils.isNotNull(warnRule.getSlideTime())) { if (StringUtils.isNotNull(warnRuleDTO.getSlideTime())) {
queryWrapper.eq(WarnRule::getSlideTime, warnRule.getSlideTime()); queryWrapper.eq(WarnRuleDTO::getSlideTime, warnRuleDTO.getSlideTime());
} }
if (StringUtils.isNotNull(warnRule.getSlideFrequency())) { if (StringUtils.isNotNull(warnRuleDTO.getSlideFrequency())) {
queryWrapper.eq(WarnRule::getSlideFrequency, warnRule.getSlideFrequency()); queryWrapper.eq(WarnRuleDTO::getSlideFrequency, warnRuleDTO.getSlideFrequency());
} }
if (StringUtils.isNotNull(warnRule.getMaxValue())) { if (StringUtils.isNotNull(warnRuleDTO.getMaxValue())) {
queryWrapper.eq(WarnRule::getMaxValue, warnRule.getMaxValue()); queryWrapper.eq(WarnRuleDTO::getMaxValue, warnRuleDTO.getMaxValue());
} }
if (StringUtils.isNotNull(warnRule.getMinValue())) { if (StringUtils.isNotNull(warnRuleDTO.getMinValue())) {
queryWrapper.eq(WarnRule::getMinValue, warnRule.getMinValue()); queryWrapper.eq(WarnRuleDTO::getMinValue, warnRuleDTO.getMinValue());
} }
return this.list(queryWrapper); return this.list(queryWrapper);
@ -103,13 +95,13 @@ public class WarnRuleServiceImpl
/** /**
* *
* *
* @param warnRule * @param warnRuleDTO
* @return * @return
*/ */
@Override @Override
public Boolean checkIdUnique(WarnRule warnRule) { public Boolean checkIdUnique(WarnRuleDTO warnRuleDTO) {
LambdaQueryWrapper<WarnRule> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<WarnRuleDTO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(WarnRule::getId, warnRule.getId()); queryWrapper.eq(WarnRuleDTO::getId, warnRuleDTO.getId());
return this.count(queryWrapper) > 0; return this.count(queryWrapper) > 0;
} }

View File

@ -41,7 +41,6 @@ public class WarnRulesServiceImpl
*/ */
@Override @Override
public List<WarnRuleDTO> selectWarnRulesListAll(WarnRuleDTO warnRuleDTO) { public List<WarnRuleDTO> selectWarnRulesListAll(WarnRuleDTO warnRuleDTO) {
warnRuleDTO.setStrategyId(warnRuleDTO.getId());
List<WarnRuleDTO> list = warnRulesMapper.selectWarnRulesListAll(warnRuleDTO); List<WarnRuleDTO> list = warnRulesMapper.selectWarnRulesListAll(warnRuleDTO);
return list; return list;
} }