From 2c8d458206839a595c63d06f5acc2371c4630b1a Mon Sep 17 00:00:00 2001 From: "20932067@zju.edu.cn" Date: Sat, 23 Jan 2021 17:46:35 +0800 Subject: [PATCH] 11 --- hchyun-ui/src/api/test/tree.js | 53 ++++ hchyun-ui/src/views/test/tree/index.vue | 227 ++++++++++++++++++ .../hchyun/web/core/config/SwaggerConfig.java | 2 +- .../test/controller/TestTreeController.java | 164 +++++++++++++ .../java/com/hchyun/test/dao/TestTreeDao.java | 61 +++++ .../java/com/hchyun/test/entity/TestTree.java | 64 +++++ .../hchyun/test/service/TestTreeService.java | 63 +++++ .../service/impl/TestTreeServiceImpl.java | 153 ++++++++++++ .../resources/mapper/test/TestTreeMapper.xml | 60 +++++ 9 files changed, 846 insertions(+), 1 deletion(-) create mode 100644 hchyun-ui/src/api/test/tree.js create mode 100644 hchyun-ui/src/views/test/tree/index.vue create mode 100644 hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/TestTreeController.java create mode 100644 hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/TestTreeDao.java create mode 100644 hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/TestTree.java create mode 100644 hchyun/hchyun-test/src/main/java/com/hchyun/test/service/TestTreeService.java create mode 100644 hchyun/hchyun-test/src/main/java/com/hchyun/test/service/impl/TestTreeServiceImpl.java create mode 100644 hchyun/hchyun-test/src/main/resources/mapper/test/TestTreeMapper.xml diff --git a/hchyun-ui/src/api/test/tree.js b/hchyun-ui/src/api/test/tree.js new file mode 100644 index 0000000..75f58a2 --- /dev/null +++ b/hchyun-ui/src/api/test/tree.js @@ -0,0 +1,53 @@ +import request from '@/utils/request' + +// 查询树测试列表 +export function listTree(query) { + return request({ + url: '/test/tree/list', + method: 'get', + params: query + }) +} + +// 查询树测试详细 +export function getTree(id) { + return request({ + url: '/test/tree/' + id, + method: 'get' + }) +} + +// 新增树测试 +export function addTree(data) { + return request({ + url: '/test/tree', + method: 'post', + data: data + }) +} + +// 修改树测试 +export function updateTree(data) { + return request({ + url: '/test/tree', + method: 'put', + data: data + }) +} + +// 删除树测试 +export function delTree(id) { + return request({ + url: '/test/tree/' + id, + method: 'delete' + }) +} + +// 导出树测试 +export function exportTree(query) { + return request({ + url: '/test/tree/export', + method: 'get', + params: query + }) +} \ No newline at end of file diff --git a/hchyun-ui/src/views/test/tree/index.vue b/hchyun-ui/src/views/test/tree/index.vue new file mode 100644 index 0000000..68c81f0 --- /dev/null +++ b/hchyun-ui/src/views/test/tree/index.vue @@ -0,0 +1,227 @@ + + + diff --git a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/core/config/SwaggerConfig.java b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/core/config/SwaggerConfig.java index ee9a12b..3573ecf 100644 --- a/hchyun/hchyun-admin/src/main/java/com/hchyun/web/core/config/SwaggerConfig.java +++ b/hchyun/hchyun-admin/src/main/java/com/hchyun/web/core/config/SwaggerConfig.java @@ -116,7 +116,7 @@ public class SwaggerConfig // 设置标题 .title("标题:宏驰云管理系统_接口文档") // 描述 - .description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...") + .description("描述:系统接口模块管理") // 作者信息 .contact(new Contact(hchYunConfig.getName(), null, null)) // 版本 diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/TestTreeController.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/TestTreeController.java new file mode 100644 index 0000000..7cad1b9 --- /dev/null +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/controller/TestTreeController.java @@ -0,0 +1,164 @@ +package com.hchyun.test.controller; + +import java.io.Serializable; +import java.util.List; +import java.util.regex.Pattern; + + +import com.hchyun.common.constant.ReturnConstants; +import com.hchyun.common.core.controller.HcyBaseController; +import com.hchyun.common.utils.ServerResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.security.access.prepost.PreAuthorize; +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.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.hchyun.common.annotation.Log; +import com.hchyun.common.core.entity.AjaxResult; +import com.hchyun.common.enums.BusinessType; +import com.hchyun.test.entity.TestTree; +import com.hchyun.test.service.TestTreeService; +import com.hchyun.common.utils.poi.ExcelUtil; + +/** + * 树测试Controller + * + * @author hchyun + * @date 2021-01-23 + */ +@RestController +@RequestMapping("/test/tree") +public class TestTreeController extends HcyBaseController { + protected final Logger logger = LoggerFactory.getLogger(TestTreeController.class); + + @Autowired + private TestTreeService testTreeService; + + /** + * 查询树测试列表 + */ + @PreAuthorize("@ss.hasPermi('test:tree:list')") + @GetMapping("/list") + public AjaxResult list(TestTree testTree) + { + ServerResult> serverResult = testTreeService.selectTestTreeList(testTree); + return AjaxResult.success(serverResult.getData()); + } + + /** + * 导出树测试列表 + */ + @PreAuthorize("@ss.hasPermi('test:tree:export')") + @Log(title = "树测试", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(TestTree testTree) { + try { + ServerResult> serverResult = testTreeService.selectTestTreeList(testTree); + ExcelUtil util = new ExcelUtil(TestTree. class); + if (serverResult.isStart()) { + return util.exportExcel(serverResult.getData(), "tree"); + } else { + return AjaxResult.error(serverResult.getMsg()); + } + } catch (RuntimeException e) { + logger.error(e.getMessage()); + return AjaxResult.error(ReturnConstants.SYS_ERROR); + } + } + + /** + * 获取树测试详细信息 + */ + @PreAuthorize("@ss.hasPermi('test:tree:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) { + try { + ServerResult serverResult = testTreeService.selectTestTreeById(id); + if (serverResult.isStart()) { + return AjaxResult.success(serverResult.getData()); + } else { + return AjaxResult.info(serverResult.getMsg()); + } + } catch (RuntimeException e) { + logger.error(e.getMessage()); + return AjaxResult.error(ReturnConstants.SYS_ERROR); + } + } + + /** + * 新增树测试 + */ + @PreAuthorize("@ss.hasPermi('test:tree:add')") + @Log(title = "树测试", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody TestTree testTree) { + if (testTree.getContent() == null || testTree.getContent().equals("")) { + return AjaxResult.error("内容不能为空!"); + } + try { + ServerResult serverResult = testTreeService.insertTestTree(testTree); + if (serverResult.isStart()) { + return AjaxResult.success(); + } else { + return AjaxResult.error(serverResult.getMsg()); + } + } catch (RuntimeException e) { + logger.error(e.getMessage()); + return AjaxResult.error(ReturnConstants.SYS_ERROR); + } + } + + /** + * 修改树测试 + */ + @PreAuthorize("@ss.hasPermi('test:tree:edit')") + @Log(title = "树测试", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody TestTree testTree) { + try { + + if (testTree.getContent() == null || testTree.getContent().equals("")) { + return AjaxResult.error("内容不能为空!"); + } + ServerResult serverResult = testTreeService.updateTestTree(testTree); + if (serverResult.isStart()) { + return AjaxResult.success(); + } else { + return AjaxResult.error(serverResult.getMsg()); + } + } catch (RuntimeException e) { + logger.error(e.getMessage()); + return AjaxResult.error(ReturnConstants.SYS_ERROR); + } + } + + /** + * 删除树测试 + */ + @PreAuthorize("@ss.hasPermi('test:tree:remove')") + @Log(title = "树测试", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { + try { + if (ids.length<0){ + return AjaxResult.error("id不能为空!"); + } + ServerResult serverResult = testTreeService.deleteTestTreeByIds(ids); + if (serverResult.isStart()) { + return AjaxResult.success(); + } else { + return AjaxResult.error(serverResult.getMsg()); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return AjaxResult.error(ReturnConstants.SYS_ERROR); + } + } +} diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/TestTreeDao.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/TestTreeDao.java new file mode 100644 index 0000000..72a312c --- /dev/null +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/dao/TestTreeDao.java @@ -0,0 +1,61 @@ +package com.hchyun.test.dao; + +import java.util.List; +import com.hchyun.test.entity.TestTree; + +/** + * 树测试Mapper接口 + * + * @author hchyun + * @date 2021-01-23 + */ +public interface TestTreeDao +{ + /** + * 查询树测试 + * + * @param id 树测试ID + * @return 树测试 + */ + TestTree selectTestTreeById(Long id); + + /** + * 查询树测试列表 + * + * @param testTree 树测试 + * @return 树测试集合 + */ + List selectTestTreeList(TestTree testTree); + + /** + * 新增树测试 + * + * @param testTree 树测试 + * @return 结果 + */ + int insertTestTree(TestTree testTree); + + /** + * 修改树测试 + * + * @param testTree 树测试 + * @return 结果 + */ + int updateTestTree(TestTree testTree); + + /** + * 删除树测试 + * + * @param id 树测试ID + * @return 结果 + */ + int deleteTestTreeById(Long id); + + /** + * 批量删除树测试 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteTestTreeByIds(Long[] ids); +} diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/TestTree.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/TestTree.java new file mode 100644 index 0000000..26ff3a4 --- /dev/null +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/entity/TestTree.java @@ -0,0 +1,64 @@ +package com.hchyun.test.entity; + +import com.hchyun.common.annotation.Excel; +import com.hchyun.common.core.entity.TreeEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 树测试对象 test_tree + * + * @author hchyun + * @date 2021-01-23 + */ +public class TestTree extends TreeEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键id */ + private Long id; + + /** 父id */ + private Long pId; + + /** 内容 */ + @Excel(name = "内容") + private String content; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setpId(Long pId) + { + this.pId = pId; + } + + public Long getpId() + { + return pId; + } + public void setContent(String content) + { + this.content = content; + } + + public String getContent() + { + return content; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("pId", getpId()) + .append("content", getContent()) + .toString(); + } +} diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/TestTreeService.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/TestTreeService.java new file mode 100644 index 0000000..df2b9e7 --- /dev/null +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/TestTreeService.java @@ -0,0 +1,63 @@ +package com.hchyun.test.service; + +import java.util.List; + +import com.hchyun.common.utils.ServerResult; +import com.hchyun.test.entity.TestTree; + +/** + * 树测试Service接口 + * + * @author hchyun + * @date 2021-01-23 + */ +public interface TestTreeService +{ + /** + * 查询树测试 + * + * @param id 树测试ID + * @return 树测试 + */ + ServerResult selectTestTreeById(Long id); + + /** + * 查询树测试列表 + * + * @param testTree 树测试 + * @return 树测试集合 + */ + ServerResult> selectTestTreeList(TestTree testTree); + + /** + * 新增树测试 + * + * @param testTree 树测试 + * @return 结果 + */ + ServerResult insertTestTree(TestTree testTree); + + /** + * 修改树测试 + * + * @param testTree 树测试 + * @return 结果 + */ + ServerResult updateTestTree(TestTree testTree); + + /** + * 批量删除树测试 + * + * @param ids 需要删除的树测试ID + * @return 结果 + */ + ServerResult deleteTestTreeByIds(Long[] ids); + + /** + * 删除树测试信息 + * + * @param id 树测试ID + * @return 结果 + */ + ServerResult deleteTestTreeById(Long id); +} diff --git a/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/impl/TestTreeServiceImpl.java b/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/impl/TestTreeServiceImpl.java new file mode 100644 index 0000000..0843633 --- /dev/null +++ b/hchyun/hchyun-test/src/main/java/com/hchyun/test/service/impl/TestTreeServiceImpl.java @@ -0,0 +1,153 @@ +package com.hchyun.test.service.impl; + +import java.util.List; + +import com.hchyun.common.constant.ReturnConstants; +import com.hchyun.common.utils.ServerResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.hchyun.test.dao.TestTreeDao; +import com.hchyun.test.entity.TestTree; +import com.hchyun.test.service.TestTreeService; + +/** + * 树测试Service业务层处理 + * + * @author hchyun + * @date 2021-01-23 + */ +@Service +public class TestTreeServiceImpl implements TestTreeService { + private Logger logger = LoggerFactory.getLogger(TestTreeServiceImpl.class); + + @Autowired + private TestTreeDao testTreeDao; + + /** + * 查询树测试 + * + * @param id 树测试ID + * @return 树测试 + */ + @Override + public ServerResult selectTestTreeById(Long id) { + try { + TestTree testTree = testTreeDao.selectTestTreeById(id); + if (testTree != null){ + return new ServerResult(true,testTree); + }else { + return new ServerResult(false, ReturnConstants.RESULT_EMPTY); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return new ServerResult(false,ReturnConstants.DB_EX); + } + } + + /** + * 查询树测试列表 + * + * @param testTree 树测试 + * @return 树测试 + */ + @Override + public ServerResult> selectTestTreeList(TestTree testTree) { + try { + List testTreeList = testTreeDao.selectTestTreeList(testTree); + if (testTreeList.size()>0){ + return new ServerResult>(true,testTreeList); + }else { + return new ServerResult>(false,ReturnConstants.RESULT_EMPTY); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return new ServerResult>(false,ReturnConstants.DB_EX); + } + } + + /** + * 新增树测试 + * + * @param testTree 树测试 + * @return 结果 + */ + @Override + public ServerResult insertTestTree(TestTree testTree) { + try { + Integer renewal = testTreeDao.insertTestTree(testTree); + if (renewal >0){ + return new ServerResult(true,renewal); + }else { + return new ServerResult(false,ReturnConstants.SYS_FAILL); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return new ServerResult(false,ReturnConstants.DB_EX); + } + } + + /** + * 修改树测试 + * + * @param testTree 树测试 + * @return 结果 + */ + @Override + public ServerResult updateTestTree(TestTree testTree) { + try { + Integer renewal = testTreeDao.updateTestTree(testTree); + if (renewal >0){ + return new ServerResult(true,renewal); + }else { + return new ServerResult(false,ReturnConstants.SYS_FAILL); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return new ServerResult(false,ReturnConstants.DB_EX); + } + } + + /** + * 批量删除树测试 + * + * @param ids 需要删除的树测试ID + * @return 结果 + */ + @Override + public ServerResult deleteTestTreeByIds(Long[] ids) { + try { + Integer renewal = testTreeDao.deleteTestTreeByIds(ids); + if (renewal >0){ + return new ServerResult(true,renewal); + }else { + return new ServerResult(false,ReturnConstants.SYS_FAILL); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return new ServerResult(false,ReturnConstants.DB_EX); + } + } + + /** + * 删除树测试信息 + * + * @param id 树测试ID + * @return 结果 + */ + @Override + public ServerResult deleteTestTreeById(Long id) { + try { + Integer renewal = testTreeDao.deleteTestTreeById(id); + if (renewal >0){ + return new ServerResult(true,renewal); + }else { + return new ServerResult(false,ReturnConstants.SYS_FAILL); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return new ServerResult(false,ReturnConstants.DB_EX); + } + } +} diff --git a/hchyun/hchyun-test/src/main/resources/mapper/test/TestTreeMapper.xml b/hchyun/hchyun-test/src/main/resources/mapper/test/TestTreeMapper.xml new file mode 100644 index 0000000..2d36ff8 --- /dev/null +++ b/hchyun/hchyun-test/src/main/resources/mapper/test/TestTreeMapper.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + select id, p_id, content from test_tree + + + + + + + + insert into test_tree + + p_id, + content, + + + #{pId}, + #{content}, + + + + + update test_tree + + p_id = #{pId}, + content = #{content}, + + where id = #{id} + + + + delete from test_tree where id = #{id} + + + + delete from test_tree where id in + + #{id} + + + \ No newline at end of file