二次更改
parent
ba3361da94
commit
06362f725c
|
@ -0,0 +1,43 @@
|
|||
package com.muyu.warning.controller;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.warning.domain.WarnRule;
|
||||
import com.muyu.warning.domain.WarnRuleDTO;
|
||||
import com.muyu.warning.service.IWarRulesService;
|
||||
import lombok.val;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName WarnRulesController
|
||||
* @Description 描述
|
||||
* @Author Chen
|
||||
* @Date 2024/9/23 21:07
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/rules")
|
||||
public class WarnRulesController {
|
||||
@Autowired
|
||||
private IWarRulesService warnRulesService;
|
||||
|
||||
/**
|
||||
* 联查策略规则 联查
|
||||
*/
|
||||
|
||||
@GetMapping("/list")
|
||||
public Result<List<WarnRuleDTO>> list() {
|
||||
List<WarnRuleDTO> list = warnRulesService.selectWarnRulesList();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
@PostMapping("/listAll")
|
||||
public Result<List<WarnRuleDTO>> listAll() {
|
||||
List<WarnRuleDTO> list = warnRulesService.selectWarnRulesListAll();
|
||||
return Result.success(list);
|
||||
}
|
||||
}
|
|
@ -2,8 +2,11 @@ package com.muyu.warning.controller;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
|
@ -29,8 +32,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/strategy")
|
||||
public class WarnStrategyController extends BaseController
|
||||
{
|
||||
public class WarnStrategyController extends BaseController {
|
||||
@Resource
|
||||
private IWarnStrategyService warnStrategyService;
|
||||
|
||||
|
@ -39,8 +41,7 @@ public class WarnStrategyController extends BaseController
|
|||
*/
|
||||
@RequiresPermissions("warning:strategy:list")
|
||||
@GetMapping("/list")
|
||||
public Result<TableDataInfo<WarnStrategy>> list(WarnStrategy warnStrategy)
|
||||
{
|
||||
public Result<TableDataInfo<WarnStrategy>> list(WarnStrategy warnStrategy) {
|
||||
startPage();
|
||||
List<WarnStrategy> list = warnStrategyService.selectWarnStrategyList(warnStrategy);
|
||||
return getDataTable(list);
|
||||
|
@ -51,8 +52,7 @@ public class WarnStrategyController extends BaseController
|
|||
*/
|
||||
@RequiresPermissions("warning:strategy:export")
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, WarnStrategy warnStrategy)
|
||||
{
|
||||
public void export(HttpServletResponse response, WarnStrategy warnStrategy) {
|
||||
List<WarnStrategy> list = warnStrategyService.selectWarnStrategyList(warnStrategy);
|
||||
ExcelUtil<WarnStrategy> util = new ExcelUtil<WarnStrategy>(WarnStrategy.class);
|
||||
util.exportExcel(response, list, "预警策略数据");
|
||||
|
@ -63,8 +63,7 @@ public class WarnStrategyController extends BaseController
|
|||
*/
|
||||
@RequiresPermissions("warning:strategy:query")
|
||||
@GetMapping(value = "/{id}")
|
||||
public Result<List<WarnStrategy>> getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
public Result<List<WarnStrategy>> getInfo(@PathVariable("id") Long id) {
|
||||
return success(warnStrategyService.selectWarnStrategyById(id));
|
||||
}
|
||||
|
||||
|
@ -74,8 +73,7 @@ public class WarnStrategyController extends BaseController
|
|||
@RequiresPermissions("warning:strategy:add")
|
||||
@PostMapping
|
||||
public Result<Integer> add(
|
||||
@Validated @RequestBody WarnStrategy warnStrategy)
|
||||
{
|
||||
@Validated @RequestBody WarnStrategy warnStrategy) {
|
||||
if (warnStrategyService.checkIdUnique(warnStrategy)) {
|
||||
return error("新增 预警策略 '" + warnStrategy + "'失败,预警策略已存在");
|
||||
}
|
||||
|
@ -88,8 +86,7 @@ public class WarnStrategyController extends BaseController
|
|||
@RequiresPermissions("warning:strategy:edit")
|
||||
@PutMapping
|
||||
public Result<Integer> edit(
|
||||
@Validated @RequestBody WarnStrategy warnStrategy)
|
||||
{
|
||||
@Validated @RequestBody WarnStrategy warnStrategy) {
|
||||
if (!warnStrategyService.checkIdUnique(warnStrategy)) {
|
||||
return error("修改 预警策略 '" + warnStrategy + "'失败,预警策略不存在");
|
||||
}
|
||||
|
@ -100,9 +97,8 @@ public class WarnStrategyController extends BaseController
|
|||
* 删除预警策略
|
||||
*/
|
||||
@RequiresPermissions("warning:strategy:remove")
|
||||
@DeleteMapping("/{ids}")
|
||||
public Result<Integer> remove(@PathVariable("ids") Long[] ids)
|
||||
{
|
||||
@DeleteMapping("/{ids}")
|
||||
public Result<Integer> remove(@PathVariable("ids") Long[] ids) {
|
||||
warnStrategyService.removeBatchByIds(Arrays.asList(ids));
|
||||
return success();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package com.muyu.warning.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.warning.domain.WarnRuleDTO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName WarnRulesMapper
|
||||
* @Description 描述
|
||||
* @Author Chen
|
||||
* @Date 2024/9/23 21:07
|
||||
*/
|
||||
@Mapper
|
||||
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")
|
||||
List<WarnRuleDTO> selectWarnRulesListAll();
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.muyu.warning.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.warning.domain.WarnRule;
|
||||
import com.muyu.warning.domain.WarnRuleDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IWarRulesService extends IService<WarnRuleDTO> {
|
||||
List<WarnRuleDTO> selectWarnRulesList();
|
||||
|
||||
List<WarnRuleDTO> selectWarnRulesListAll();
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.muyu.warning.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.muyu.warning.domain.WarnRule;
|
||||
import com.muyu.warning.domain.WarnRuleDTO;
|
||||
import com.muyu.warning.domain.WarnStrategy;
|
||||
import com.muyu.warning.mapper.WarnRulesMapper;
|
||||
import com.muyu.warning.service.IWarRulesService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName WarnRulesServiceImpl
|
||||
* @Description 描述
|
||||
* @Author Chen
|
||||
* @Date 2024/9/23 22:02
|
||||
*/
|
||||
@Service
|
||||
public class WarnRulesServiceImpl
|
||||
extends ServiceImpl <WarnRulesMapper, WarnRuleDTO>
|
||||
implements IWarRulesService {
|
||||
|
||||
@Autowired
|
||||
private WarnRulesMapper warnRulesMapper;
|
||||
|
||||
@Override
|
||||
public List<WarnRuleDTO> selectWarnRulesList() {
|
||||
MPJLambdaWrapper<WarnRuleDTO> wrapper = new MPJLambdaWrapper<WarnRuleDTO>()
|
||||
.selectAll(WarnRule.class)
|
||||
.selectAs(WarnStrategy::getStrategyName, WarnRuleDTO::getStrategyName)
|
||||
.leftJoin(WarnStrategy.class, WarnStrategy::getId, WarnRule::getStrategyId);
|
||||
return this.list(wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 双表查询
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<WarnRuleDTO> selectWarnRulesListAll() {
|
||||
List<WarnRuleDTO> list = warnRulesMapper.selectWarnRulesListAll();
|
||||
return list;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.muyu.warning.mapper.WarnRulesMapper">
|
||||
|
||||
|
||||
<select id="selectWarnRulesListAll" resultType="com.muyu.warning.domain.WarnRuleDTO"></select>
|
||||
</mapper>
|
Loading…
Reference in New Issue