新增节点管理相关接口

master
面包骑士 2024-08-23 09:35:32 +08:00
parent 738999100b
commit a23c32aab5
6 changed files with 248 additions and 76 deletions

View File

@ -6,13 +6,15 @@ import lombok.*;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
/**
* node_source
* node_source
*
* @author 2112A
* @date 2024-08-22
* @date 2024-08-23
*/
@Data
@ -21,10 +23,12 @@ import org.apache.commons.lang3.builder.ToStringStyle;
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("node_source")
public class Node extends BaseEntity{
private static final long serialVersionUID = 1L;
/** 自增主键 */
@TableId( type = IdType.AUTO)
private Long id;
/** 节点编码 */
@ -55,78 +59,7 @@ public class Node extends BaseEntity{
@Excel(name = "启用状态")
private String state;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setNodeCode(String nodeCode)
{
this.nodeCode = nodeCode;
}
public String getNodeCode()
{
return nodeCode;
}
public void setNodeName(String nodeName)
{
this.nodeName = nodeName;
}
public String getNodeName()
{
return nodeName;
}
public void setNodeReq(String nodeReq)
{
this.nodeReq = nodeReq;
}
public String getNodeReq()
{
return nodeReq;
}
public void setNodeResp(String nodeResp)
{
this.nodeResp = nodeResp;
}
public String getNodeResp()
{
return nodeResp;
}
public void setNodePreCode(String nodePreCode)
{
this.nodePreCode = nodePreCode;
}
public String getNodePreCode()
{
return nodePreCode;
}
public void setNodeNextCode(String nodeNextCode)
{
this.nodeNextCode = nodeNextCode;
}
public String getNodeNextCode()
{
return nodeNextCode;
}
public void setState(String state)
{
this.state = state;
}
public String getState()
{
return state;
}
@Override
public String toString() {

View File

@ -0,0 +1,113 @@
package com.muyu.quest.controller;
import java.util.Arrays;
import java.util.List;
import com.muyu.quest.domain.Node;
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;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.quest.service.INodeService;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.security.utils.SecurityUtils;
import org.springframework.validation.annotation.Validated;
import com.muyu.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author 2112A
* @date 2024-08-23
*/
@RestController
@RequestMapping("/Node")
public class NodeController extends BaseController
{
@Resource
private INodeService nodeService;
/**
*
*/
@RequiresPermissions("Node:Node:list")
@GetMapping("/list")
public Result<TableDataInfo<Node>> list(Node node)
{
startPage();
List<Node> list = nodeService.selectNodeList(node);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("Node:Node:export")
@PostMapping("/export")
public void export(HttpServletResponse response, Node node)
{
List<Node> list = nodeService.selectNodeList(node);
ExcelUtil<Node> util = new ExcelUtil<Node>(Node.class);
util.exportExcel(response, list, "节点管理数据");
}
/**
*
*/
@RequiresPermissions("Node:Node:query")
@GetMapping(value = "/{id}")
public Result<List<Node>> getInfo(@PathVariable("id") Long id)
{
return success(nodeService.selectNodeById(id));
}
/**
*
*/
@RequiresPermissions("Node:Node:add")
@PostMapping
public Result<Integer> add(
@Validated @RequestBody Node node)
{
if (nodeService.checkIdUnique(node)) {
return error("新增 节点管理 '" + node + "'失败,节点管理已存在");
}
node.setCreateBy(SecurityUtils.getUsername());
return toAjax(nodeService.save(node));
}
/**
*
*/
@RequiresPermissions("Node:Node:edit")
@PutMapping
public Result<Integer> edit(
@Validated @RequestBody Node node)
{
if (!nodeService.checkIdUnique(node)) {
return error("修改 节点管理 '" + node + "'失败,节点管理不存在");
}
node.setUpdateBy(SecurityUtils.getUsername());
return toAjax(nodeService.updateById(node));
}
/**
*
*/
@RequiresPermissions("Node:Node:remove")
@DeleteMapping("/{ids}")
public Result<Integer> remove(@PathVariable("ids") Long[] ids)
{
nodeService.removeBatchByIds(Arrays.asList(ids));
return success();
}
}

View File

@ -53,7 +53,7 @@ public class TaskController extends BaseController
*
*/
// @RequiresPermissions("quest:quest:query")
@GetMapping(value = "selectTaskByTaskCode/{taskCode}")
@GetMapping(value = "/selectTaskByTaskCode/{taskCode}")
public Result<List<Task>> getInfo(@PathVariable("taskCode") String taskCode) {
return success(taskService.selectTaskByTaskCode(taskCode));
}
@ -62,7 +62,7 @@ public class TaskController extends BaseController
*
*/
// @RequiresPermissions("quest:quest:query")
@GetMapping(value = "selectTaskById/{id}")
@GetMapping(value = "/selectTaskById/{id}")
public Result<List<Task>> getInfo(@PathVariable("id") Long id) {
return success(taskService.selectTaskById(id));
}

View File

@ -0,0 +1,16 @@
package com.muyu.quest.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.quest.domain.Node;
import org.apache.ibatis.annotations.Mapper;
/**
* Mapper
*
* @author 2112A
* @date 2024-08-23
*/
@Mapper
public interface NodeMapper extends BaseMapper<Node>{
}

View File

@ -0,0 +1,38 @@
package com.muyu.quest.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.quest.domain.Node;
/**
* Service
*
* @author 2112A
* @date 2024-08-23
*/
public interface INodeService extends IService<Node> {
/**
*
*
* @param id
* @return
*/
public Node selectNodeById(Long id);
/**
*
*
* @param node
* @return
*/
public List<Node> selectNodeList(Node node);
/**
* id
* @param node
* @return
*/
Boolean checkIdUnique(Node node);
}

View File

@ -0,0 +1,72 @@
package com.muyu.quest.service.impl;
import java.util.List;
import com.muyu.quest.domain.Node;
import org.springframework.stereotype.Service;
import com.muyu.quest.mapper.NodeMapper;
import com.muyu.quest.service.INodeService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.utils.StringUtils;
import org.springframework.util.Assert;
/**
* Service
*
* @author 2112A
* @date 2024-08-23
*/
@Service
public class NodeServiceImpl
extends ServiceImpl<NodeMapper, Node>
implements INodeService {
/**
*
*
* @param id
* @return
*/
@Override
public Node selectNodeById(Long id)
{
LambdaQueryWrapper<Node> queryWrapper = new LambdaQueryWrapper<>();
Assert.notNull(id, "id不可为空");
queryWrapper.eq(Node::getId, id);
return this.getOne(queryWrapper);
}
/**
*
*
* @param node
* @return
*/
@Override
public List<Node> selectNodeList(Node node)
{
LambdaQueryWrapper<Node> queryWrapper = new LambdaQueryWrapper<>();
if (StringUtils.isNotEmpty(node.getNodeName())){
queryWrapper.like(Node::getNodeName, node.getNodeName());
}
if (StringUtils.isNotEmpty(node.getState())){
queryWrapper.eq(Node::getState, node.getState());
}
return this.list(queryWrapper);
}
/**
*
* @param node
* @return
*/
@Override
public Boolean checkIdUnique(Node node) {
LambdaQueryWrapper<Node> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Node::getId, node.getId());
return this.count(queryWrapper) > 0;
}
}