From 83c427c1bbf5e8e9a07bdea946479b005da0297e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90li?=
<15040126243@163.com>
Date: Fri, 14 Feb 2020 13:36:52 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E4=BB=A3=E7=A0=81?=
=?UTF-8?q?=E7=94=9F=E6=88=90=E4=B8=8EMybatisPlus=E6=B5=8B=E8=AF=95?=
=?UTF-8?q?=E6=A1=88=E4=BE=8B=20cstest?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ruoyi-ui/src/api/cstest/cstest.js | 53 ++++
ruoyi-ui/src/views/cstest/cstest/index.vue | 299 ++++++++++++++++++
ruoyi/sql/test.sql | 57 ++++
.../cstest/controller/CsTestController.java | 114 +++++++
.../ruoyi/project/cstest/domain/CsTest.java | 62 ++++
.../project/cstest/mapper/CsTestMapper.java | 14 +
.../cstest/service/ICsTestService.java | 14 +
.../service/impl/CsTestServiceImpl.java | 18 ++
.../resources/mybatis/cstest/CsTestMapper.xml | 17 +
9 files changed, 648 insertions(+)
create mode 100644 ruoyi-ui/src/api/cstest/cstest.js
create mode 100644 ruoyi-ui/src/views/cstest/cstest/index.vue
create mode 100644 ruoyi/sql/test.sql
create mode 100644 ruoyi/src/main/java/com/ruoyi/project/cstest/controller/CsTestController.java
create mode 100644 ruoyi/src/main/java/com/ruoyi/project/cstest/domain/CsTest.java
create mode 100644 ruoyi/src/main/java/com/ruoyi/project/cstest/mapper/CsTestMapper.java
create mode 100644 ruoyi/src/main/java/com/ruoyi/project/cstest/service/ICsTestService.java
create mode 100644 ruoyi/src/main/java/com/ruoyi/project/cstest/service/impl/CsTestServiceImpl.java
create mode 100644 ruoyi/src/main/resources/mybatis/cstest/CsTestMapper.xml
diff --git a/ruoyi-ui/src/api/cstest/cstest.js b/ruoyi-ui/src/api/cstest/cstest.js
new file mode 100644
index 00000000..221fe36f
--- /dev/null
+++ b/ruoyi-ui/src/api/cstest/cstest.js
@@ -0,0 +1,53 @@
+import request from '@/utils/request'
+
+// 查询测试列表
+export function listCstest(query) {
+ return request({
+ url: '/cstest/cstest/list',
+ method: 'get',
+ params: query
+ })
+}
+
+// 查询测试详细
+export function getCstest(id) {
+ return request({
+ url: '/cstest/cstest/' + id,
+ method: 'get'
+ })
+}
+
+// 新增测试
+export function addCstest(data) {
+ return request({
+ url: '/cstest/cstest',
+ method: 'post',
+ data: data
+ })
+}
+
+// 修改测试
+export function updateCstest(data) {
+ return request({
+ url: '/cstest/cstest',
+ method: 'put',
+ data: data
+ })
+}
+
+// 删除测试
+export function delCstest(id) {
+ return request({
+ url: '/cstest/cstest/' + id,
+ method: 'delete'
+ })
+}
+
+// 导出测试
+export function exportCstest(query) {
+ return request({
+ url: '/cstest/cstest/export',
+ method: 'get',
+ params: query
+ })
+}
\ No newline at end of file
diff --git a/ruoyi-ui/src/views/cstest/cstest/index.vue b/ruoyi-ui/src/views/cstest/cstest/index.vue
new file mode 100644
index 00000000..60a0b8cd
--- /dev/null
+++ b/ruoyi-ui/src/views/cstest/cstest/index.vue
@@ -0,0 +1,299 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 搜索
+ 重置
+
+
+
+
+
+ 新增
+
+
+ 修改
+
+
+ 删除
+
+
+ 导出
+
+
+
+
+
+
+
+
+
+
+ {{ parseTime(scope.row.createTime) }}
+
+
+
+
+ 修改
+ 删除
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ruoyi/sql/test.sql b/ruoyi/sql/test.sql
new file mode 100644
index 00000000..487800c3
--- /dev/null
+++ b/ruoyi/sql/test.sql
@@ -0,0 +1,57 @@
+/*
+ Navicat Premium Data Transfer
+
+ Source Server : 192.168.0.222
+ Source Server Type : MySQL
+ Source Server Version : 80019
+ Source Host : 192.168.0.222:3306
+ Source Schema : ry-vue
+
+ Target Server Type : MySQL
+ Target Server Version : 80019
+ File Encoding : 65001
+
+ Date: 14/02/2020 13:29:11
+*/
+
+SET NAMES utf8mb4;
+SET FOREIGN_KEY_CHECKS = 0;
+
+-- ----------------------------
+-- Table structure for chkj_test
+-- ----------------------------
+DROP TABLE IF EXISTS `chkj_test`;
+CREATE TABLE `chkj_test` (
+ `id` int(0) NOT NULL AUTO_INCREMENT COMMENT '主键',
+ `test_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT 'key键',
+ `value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '' COMMENT '值',
+ `version` int(0) NULL DEFAULT 0 COMMENT '版本',
+ `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
+ `deleted` tinyint(0) NULL DEFAULT 0 COMMENT '删除状态',
+ PRIMARY KEY (`id`) USING BTREE
+) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '测试表' ROW_FORMAT = Dynamic;
+
+-- ----------------------------
+-- Records of gen_table
+-- ----------------------------
+INSERT INTO `gen_table` VALUES (1, 'chkj_test', '测试表', 'CsTest', 'crud', 'com.ruoyi.project.cstest', 'cstest', 'cstest', '测试', 'Lion Li', '{}', 'admin', '2020-02-12 03:39:31', '', '2020-02-14 04:55:27', '测试代码生成器');
+
+-- ----------------------------
+-- Records of gen_table_column
+-- ----------------------------
+INSERT INTO `gen_table_column` VALUES (1, '1', 'id', '主键', 'int', 'Integer', 'id', '1', '1', NULL, '1', NULL, NULL, NULL, 'EQ', 'input', '', 1, 'admin', '2020-02-12 03:39:31', '', '2020-02-14 04:55:27');
+INSERT INTO `gen_table_column` VALUES (2, '1', 'test_key', 'key键', 'varchar(255)', 'String', 'testKey', '0', '0', '1', '1', '1', '1', '1', 'LIKE', 'input', '', 2, 'admin', '2020-02-12 03:39:31', '', '2020-02-14 04:55:27');
+INSERT INTO `gen_table_column` VALUES (3, '1', 'value', '值', 'varchar(255)', 'String', 'value', '0', '0', '1', '1', '1', '1', '1', 'LIKE', 'input', '', 3, 'admin', '2020-02-12 03:39:31', '', '2020-02-14 04:55:27');
+INSERT INTO `gen_table_column` VALUES (4, '1', 'version', '版本', 'int', 'Integer', 'version', '0', '0', '1', NULL, NULL, NULL, NULL, 'EQ', 'input', '', 4, 'admin', '2020-02-12 03:39:31', '', '2020-02-14 04:55:27');
+INSERT INTO `gen_table_column` VALUES (5, '1', 'create_time', '创建时间', 'datetime', 'Date', 'createTime', '0', '0', '1', NULL, NULL, '1', '1', 'EQ', 'datetime', '', 5, 'admin', '2020-02-12 03:39:31', '', '2020-02-14 04:55:27');
+INSERT INTO `gen_table_column` VALUES (6, '1', 'deleted', '删除状态', 'tinyint', 'Integer', 'deleted', '0', '0', '1', NULL, NULL, NULL, NULL, 'EQ', 'input', '', 6, 'admin', '2020-02-12 03:39:31', '', '2020-02-14 04:55:27');
+
+INSERT INTO `sys_menu`(`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `is_frame`, `menu_type`, `visible`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2000, '测试用例', 0, 5, '', NULL, 1, 'M', '0', NULL, 'bug', 'admin', '2020-02-12 03:57:28', '', NULL, '');
+INSERT INTO `sys_menu`(`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `is_frame`, `menu_type`, `visible`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2007, '测试', 2000, 1, 'cstest', 'cstest/cstest/index', 1, 'C', '0', 'cstest:cstest:list', '#', 'admin', '2018-03-01 00:00:00', 'ry', '2018-03-01 00:00:00', '测试菜单');
+INSERT INTO `sys_menu`(`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `is_frame`, `menu_type`, `visible`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2008, '测试查询', 2007, 1, '#', '', 1, 'F', '0', 'cstest:cstest:query', '#', 'admin', '2018-03-01 00:00:00', 'ry', '2018-03-01 00:00:00', '');
+INSERT INTO `sys_menu`(`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `is_frame`, `menu_type`, `visible`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2009, '测试新增', 2007, 2, '#', '', 1, 'F', '0', 'cstest:cstest:add', '#', 'admin', '2018-03-01 00:00:00', 'ry', '2018-03-01 00:00:00', '');
+INSERT INTO `sys_menu`(`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `is_frame`, `menu_type`, `visible`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2010, '测试修改', 2007, 3, '#', '', 1, 'F', '0', 'cstest:cstest:edit', '#', 'admin', '2018-03-01 00:00:00', 'ry', '2018-03-01 00:00:00', '');
+INSERT INTO `sys_menu`(`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `is_frame`, `menu_type`, `visible`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2011, '测试删除', 2007, 4, '#', '', 1, 'F', '0', 'cstest:cstest:remove', '#', 'admin', '2018-03-01 00:00:00', 'ry', '2018-03-01 00:00:00', '');
+INSERT INTO `sys_menu`(`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `is_frame`, `menu_type`, `visible`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`) VALUES (2012, '测试导出', 2007, 5, '#', '', 1, 'F', '0', 'cstest:cstest:export', '#', 'admin', '2018-03-01 00:00:00', 'ry', '2018-03-01 00:00:00', '');
+
+SET FOREIGN_KEY_CHECKS = 1;
\ No newline at end of file
diff --git a/ruoyi/src/main/java/com/ruoyi/project/cstest/controller/CsTestController.java b/ruoyi/src/main/java/com/ruoyi/project/cstest/controller/CsTestController.java
new file mode 100644
index 00000000..2c4edc28
--- /dev/null
+++ b/ruoyi/src/main/java/com/ruoyi/project/cstest/controller/CsTestController.java
@@ -0,0 +1,114 @@
+package com.ruoyi.project.cstest.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+
+import java.util.List;
+import java.util.Arrays;
+
+import com.ruoyi.common.utils.StringUtils;
+import lombok.AllArgsConstructor;
+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.ruoyi.framework.aspectj.lang.annotation.Log;
+import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
+import com.ruoyi.project.cstest.domain.CsTest;
+import com.ruoyi.project.cstest.service.ICsTestService;
+import com.ruoyi.framework.web.controller.BaseController;
+import com.ruoyi.framework.web.domain.AjaxResult;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.framework.web.page.TableDataInfo;
+
+/**
+ * 测试Controller
+ *
+ * @author Lion Li
+ * @date 2020-02-14
+ */
+@AllArgsConstructor
+@RestController
+@RequestMapping("/cstest/cstest" )
+public class CsTestController extends BaseController {
+
+ private final ICsTestService iCsTestService;
+
+ /**
+ * 查询测试列表
+ */
+ @PreAuthorize("@ss.hasPermi('cstest:cstest:list')" )
+ @GetMapping("/list" )
+ public TableDataInfo list(CsTest csTest) {
+ startPage();
+ LambdaQueryWrapper lqw = new LambdaQueryWrapper();
+ if (StringUtils.isNotBlank(csTest.getTestKey())){
+ lqw.like(CsTest::getTestKey ,csTest.getTestKey());
+ }
+ if (StringUtils.isNotBlank(csTest.getValue())){
+ lqw.like(CsTest::getValue ,csTest.getValue());
+ }
+ if (csTest.getCreateTime() != null){
+ lqw.eq(CsTest::getCreateTime ,csTest.getCreateTime());
+ }
+ List list = iCsTestService.list(lqw);
+ return getDataTable(list);
+ }
+
+ /**
+ * 导出测试列表
+ */
+ @PreAuthorize("@ss.hasPermi('cstest:cstest:export')" )
+ @Log(title = "测试" , businessType = BusinessType.EXPORT)
+ @GetMapping("/export" )
+ public AjaxResult export(CsTest csTest) {
+ LambdaQueryWrapper lqw = new LambdaQueryWrapper(csTest);
+ List list = iCsTestService.list(lqw);
+ ExcelUtil util = new ExcelUtil(CsTest. class);
+ return util.exportExcel(list, "cstest" );
+ }
+
+ /**
+ * 获取测试详细信息
+ */
+ @PreAuthorize("@ss.hasPermi('cstest:cstest:query')" )
+ @GetMapping(value = "/{id}" )
+ public AjaxResult getInfo(@PathVariable("id" ) Integer id) {
+ return AjaxResult.success(iCsTestService.getById(id));
+ }
+
+ /**
+ * 新增测试
+ */
+ @PreAuthorize("@ss.hasPermi('cstest:cstest:add')" )
+ @Log(title = "测试" , businessType = BusinessType.INSERT)
+ @PostMapping
+ public AjaxResult add(@RequestBody CsTest csTest) {
+ return toAjax(iCsTestService.save(csTest) ? 1 : 0);
+ }
+
+ /**
+ * 修改测试
+ */
+ @PreAuthorize("@ss.hasPermi('cstest:cstest:edit')" )
+ @Log(title = "测试" , businessType = BusinessType.UPDATE)
+ @PutMapping
+ public AjaxResult edit(@RequestBody CsTest csTest) {
+ return toAjax(iCsTestService.updateById(csTest) ? 1 : 0);
+ }
+
+ /**
+ * 删除测试
+ */
+ @PreAuthorize("@ss.hasPermi('cstest:cstest:remove')" )
+ @Log(title = "测试" , businessType = BusinessType.DELETE)
+ @DeleteMapping("/{ids}" )
+ public AjaxResult remove(@PathVariable Integer[] ids) {
+ return toAjax(iCsTestService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
+ }
+}
diff --git a/ruoyi/src/main/java/com/ruoyi/project/cstest/domain/CsTest.java b/ruoyi/src/main/java/com/ruoyi/project/cstest/domain/CsTest.java
new file mode 100644
index 00000000..583c6885
--- /dev/null
+++ b/ruoyi/src/main/java/com/ruoyi/project/cstest/domain/CsTest.java
@@ -0,0 +1,62 @@
+package com.ruoyi.project.cstest.domain;
+
+import com.baomidou.mybatisplus.annotation.*;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import lombok.experimental.Accessors;
+import com.ruoyi.framework.aspectj.lang.annotation.Excel;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 测试对象 chkj_test
+ *
+ * @author Lion Li
+ * @date 2020-02-14
+ */
+@Data
+@ToString
+@EqualsAndHashCode
+@NoArgsConstructor
+@Accessors(chain = true)
+@TableName("chkj_test")
+public class CsTest implements Serializable {
+
+private static final long serialVersionUID=1L;
+
+
+ /** 主键 */
+ @TableId(value = "id", type = IdType.AUTO)
+ private Integer id;
+
+
+ /** key键 */
+ @Excel(name = "key键")
+ private String testKey;
+
+
+ /** 值 */
+ @Excel(name = "值")
+ private String value;
+
+
+ /** 版本 */
+ @Version
+ private Integer version;
+
+
+ /** 创建时间 */
+ @Excel(name = "创建时间" , width = 30, dateFormat = "yyyy-MM-dd")
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+ private Date createTime;
+
+
+ /** 删除状态 */
+ @TableLogic
+ private Integer deleted;
+
+}
diff --git a/ruoyi/src/main/java/com/ruoyi/project/cstest/mapper/CsTestMapper.java b/ruoyi/src/main/java/com/ruoyi/project/cstest/mapper/CsTestMapper.java
new file mode 100644
index 00000000..6034f3ba
--- /dev/null
+++ b/ruoyi/src/main/java/com/ruoyi/project/cstest/mapper/CsTestMapper.java
@@ -0,0 +1,14 @@
+package com.ruoyi.project.cstest.mapper;
+
+import com.ruoyi.project.cstest.domain.CsTest;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 测试Mapper接口
+ *
+ * @author Lion Li
+ * @date 2020-02-14
+ */
+public interface CsTestMapper extends BaseMapper {
+
+}
diff --git a/ruoyi/src/main/java/com/ruoyi/project/cstest/service/ICsTestService.java b/ruoyi/src/main/java/com/ruoyi/project/cstest/service/ICsTestService.java
new file mode 100644
index 00000000..d579d58a
--- /dev/null
+++ b/ruoyi/src/main/java/com/ruoyi/project/cstest/service/ICsTestService.java
@@ -0,0 +1,14 @@
+package com.ruoyi.project.cstest.service;
+
+import com.ruoyi.project.cstest.domain.CsTest;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 测试Service接口
+ *
+ * @author Lion Li
+ * @date 2020-02-14
+ */
+public interface ICsTestService extends IService {
+
+}
diff --git a/ruoyi/src/main/java/com/ruoyi/project/cstest/service/impl/CsTestServiceImpl.java b/ruoyi/src/main/java/com/ruoyi/project/cstest/service/impl/CsTestServiceImpl.java
new file mode 100644
index 00000000..9b00e9bb
--- /dev/null
+++ b/ruoyi/src/main/java/com/ruoyi/project/cstest/service/impl/CsTestServiceImpl.java
@@ -0,0 +1,18 @@
+package com.ruoyi.project.cstest.service.impl;
+
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.project.cstest.mapper.CsTestMapper;
+import com.ruoyi.project.cstest.domain.CsTest;
+import com.ruoyi.project.cstest.service.ICsTestService;
+
+/**
+ * 测试Service业务层处理
+ *
+ * @author Lion Li
+ * @date 2020-02-14
+ */
+@Service
+public class CsTestServiceImpl extends ServiceImpl implements ICsTestService {
+
+}
diff --git a/ruoyi/src/main/resources/mybatis/cstest/CsTestMapper.xml b/ruoyi/src/main/resources/mybatis/cstest/CsTestMapper.xml
new file mode 100644
index 00000000..a3cb78bd
--- /dev/null
+++ b/ruoyi/src/main/resources/mybatis/cstest/CsTestMapper.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file