Browse Source

add function

hlf 1 year atrás
parent
commit
cbef430a1b

+ 1 - 0
build.gradle.kts

@@ -34,6 +34,7 @@ dependencies {
     implementation("org.postgresql:postgresql:42.4.0")
     implementation("org.springframework.boot:spring-boot-starter-data-jpa")
     //implementation("cn.hutool:hutool-all:5.8.15")
+    implementation("com.github.pagehelper:pagehelper-spring-boot-starter:1.4.1")
 }
 
 tasks.withType<Test> {

+ 33 - 6
src/main/java/com/gyee/table/controller/ComponentInformationController.java

@@ -1,11 +1,15 @@
 package com.gyee.table.controller;
 
 import com.alibaba.fastjson2.JSONObject;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.gyee.table.entity.ComponentModificationRecord;
 import com.gyee.table.entity.Configurationinfo;
 import com.gyee.table.result.Result;
-import com.gyee.table.result.ResultCode;
+import com.gyee.table.service.IComponentModificationRecordService;
 import com.gyee.table.service.IConfigurationinfoService;
 import com.gyee.table.utils.SnowflakeIdUtils;
+import com.gyee.table.utils.TableDataInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.*;
 
@@ -25,15 +29,19 @@ public class ComponentInformationController {
     @Resource
     private IConfigurationinfoService configurationinfoService;
 
+    @Resource
+    private IComponentModificationRecordService componentModificationRecordService;
+
     /**
      * 查询组件信息列表
      *
      * @return
      */
     @GetMapping("/componentList")
-    public JSONObject componentList() {
-        List<Configurationinfo> list = configurationinfoService.list();
-        return Result.successData(ResultCode.SUCCESS, list);
+    public TableDataInfo componentList(@RequestBody Configurationinfo configurationinfo) {
+        PageHelper.startPage(configurationinfo.getPageNum(), configurationinfo.getPageSize(), true);
+        List<Configurationinfo> list = configurationinfoService.selectConfigurationinfoList(configurationinfo);
+        return getDataTable(list);
     }
 
     /**
@@ -58,6 +66,11 @@ public class ComponentInformationController {
     @PostMapping("/updateComponent")
     public JSONObject updateComponent(@RequestBody Configurationinfo configurationinfo) {
         configurationinfoService.updateById(configurationinfo);
+        ComponentModificationRecord componentModificationRecord = new ComponentModificationRecord();
+        componentModificationRecord.setId(configurationinfo.getId());
+        componentModificationRecord.setChangeUser(configurationinfo.getChangeUser());
+        componentModificationRecord.setUpdataDate(configurationinfo.getUpdataDate());
+        componentModificationRecordService.save(componentModificationRecord);
         return Result.success();
     }
 
@@ -67,9 +80,23 @@ public class ComponentInformationController {
      * @param id
      * @return
      */
-    @PostMapping("/deleteComponent")
-    public JSONObject deleteComponent(@RequestParam(value = "id") String id) {
+    @DeleteMapping("/deleteComponent/{id}")
+    public JSONObject deleteComponent(@PathVariable String id) {
         configurationinfoService.removeById(id);
         return Result.success();
     }
+
+    /**
+     * 响应请求分页数据
+     */
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+    protected TableDataInfo getDataTable(List<?> list)
+    {
+        TableDataInfo rspData = new TableDataInfo();
+        rspData.setCode(200);
+        rspData.setRows(list);
+        rspData.setTotal(new PageInfo(list).getTotal());
+        rspData.setMsg("成功");
+        return rspData;
+    }
 }

+ 17 - 0
src/main/java/com/gyee/table/entity/ComponentModificationRecord.java

@@ -0,0 +1,17 @@
+package com.gyee.table.entity;
+
+import lombok.Data;
+
+/**
+ * @author hlf
+ * @date 2023/3/28 9:30
+ * 文件说明:
+ */
+@Data
+public class ComponentModificationRecord {
+
+    private String id;
+    private String updataDate;
+    private String changeUser;
+
+}

+ 3 - 1
src/main/java/com/gyee/table/entity/Configurationinfo.java

@@ -21,10 +21,12 @@ public class Configurationinfo {
     private String otherNeed;
     private String stateDesc;
     private String svg;
-    private String tr_svg;
+    private String trSvg;
     private String type;
     private String uploadDate;
     private String user;
     private String updataDate;
     private String changeUser;
+    private Integer pageNum;
+    private Integer pageSize;
 }

+ 20 - 0
src/main/java/com/gyee/table/entity/User.java

@@ -0,0 +1,20 @@
+package com.gyee.table.entity;
+
+import lombok.Data;
+
+/**
+ * @author hlf
+ * @date 2023/3/28 9:28
+ * 文件说明:
+ */
+@Data
+public class User {
+
+    private String id;
+    private String loginName;
+    private String password;
+    private String userName;
+    private String userAuthority;
+    private String lastLoginTime;
+
+}

+ 14 - 0
src/main/java/com/gyee/table/mapper/ComponentModificationRecordMapper.java

@@ -0,0 +1,14 @@
+package com.gyee.table.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.table.entity.ComponentModificationRecord;
+
+/**
+ * @author hlf
+ * @date 2023/3/28 9:35
+ * 文件说明:
+ */
+public interface ComponentModificationRecordMapper extends BaseMapper<ComponentModificationRecord> {
+
+
+}

+ 3 - 1
src/main/java/com/gyee/table/mapper/ConfigurationinfoMapper.java

@@ -3,6 +3,8 @@ package com.gyee.table.mapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.gyee.table.entity.Configurationinfo;
 
+import java.util.List;
+
 /**
  * @author hlf
  * @date 2023/3/20 10:01
@@ -10,5 +12,5 @@ import com.gyee.table.entity.Configurationinfo;
  */
 public interface ConfigurationinfoMapper extends BaseMapper<Configurationinfo> {
 
-
+    List<Configurationinfo> selectConfigurationinfoList(Configurationinfo configurationinfo);
 }

+ 14 - 0
src/main/java/com/gyee/table/mapper/UserMapper.java

@@ -0,0 +1,14 @@
+package com.gyee.table.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.table.entity.User;
+
+/**
+ * @author hlf
+ * @date 2023/3/28 9:35
+ * 文件说明:
+ */
+public interface UserMapper extends BaseMapper<User> {
+
+
+}

+ 15 - 0
src/main/java/com/gyee/table/service/IComponentModificationRecordService.java

@@ -0,0 +1,15 @@
+package com.gyee.table.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.table.entity.ComponentModificationRecord;
+
+/**
+ * @author hlf
+ * @date 2023/3/28 9:31
+ * 文件说明:
+ */
+public interface IComponentModificationRecordService extends IService<ComponentModificationRecord> {
+
+
+
+}

+ 3 - 1
src/main/java/com/gyee/table/service/IConfigurationinfoService.java

@@ -3,6 +3,8 @@ package com.gyee.table.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.gyee.table.entity.Configurationinfo;
 
+import java.util.List;
+
 /**
  * @author hlf
  * @date 2023/3/20 10:00
@@ -10,5 +12,5 @@ import com.gyee.table.entity.Configurationinfo;
  */
 public interface IConfigurationinfoService extends IService<Configurationinfo> {
 
-
+    List<Configurationinfo> selectConfigurationinfoList(Configurationinfo configurationinfo);
 }

+ 15 - 0
src/main/java/com/gyee/table/service/IUserService.java

@@ -0,0 +1,15 @@
+package com.gyee.table.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.gyee.table.entity.User;
+
+/**
+ * @author hlf
+ * @date 2023/3/28 9:32
+ * 文件说明:
+ */
+public interface IUserService extends IService<User> {
+
+
+
+}

+ 19 - 0
src/main/java/com/gyee/table/service/impl/ComponentModificationRecordImpl.java

@@ -0,0 +1,19 @@
+package com.gyee.table.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.table.entity.ComponentModificationRecord;
+import com.gyee.table.mapper.ComponentModificationRecordMapper;
+import com.gyee.table.service.IComponentModificationRecordService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author hlf
+ * @date 2023/3/28 9:32
+ * 文件说明:
+ */
+@Service
+public class ComponentModificationRecordImpl extends ServiceImpl<ComponentModificationRecordMapper, ComponentModificationRecord> implements IComponentModificationRecordService {
+
+
+
+}

+ 9 - 0
src/main/java/com/gyee/table/service/impl/ConfigurationinfoServiceImpl.java

@@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gyee.table.entity.Configurationinfo;
 import com.gyee.table.mapper.ConfigurationinfoMapper;
 import com.gyee.table.service.IConfigurationinfoService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * @author hlf
  * @date 2023/3/20 10:00
@@ -14,5 +17,11 @@ import org.springframework.stereotype.Service;
 @Service
 public class ConfigurationinfoServiceImpl extends ServiceImpl<ConfigurationinfoMapper, Configurationinfo> implements IConfigurationinfoService {
 
+    @Autowired(required = false)
+    private ConfigurationinfoMapper configurationinfoMapper;
 
+    @Override
+    public List<Configurationinfo> selectConfigurationinfoList(Configurationinfo configurationinfo) {
+        return configurationinfoMapper.selectConfigurationinfoList(configurationinfo);
+    }
 }

+ 19 - 0
src/main/java/com/gyee/table/service/impl/UserServiceImpl.java

@@ -0,0 +1,19 @@
+package com.gyee.table.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.gyee.table.entity.User;
+import com.gyee.table.mapper.UserMapper;
+import com.gyee.table.service.IUserService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author hlf
+ * @date 2023/3/28 9:32
+ * 文件说明:
+ */
+@Service
+public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
+
+
+
+}

+ 85 - 0
src/main/java/com/gyee/table/utils/TableDataInfo.java

@@ -0,0 +1,85 @@
+package com.gyee.table.utils;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 表格分页数据对象
+ * 
+ * @author ruoyi
+ */
+public class TableDataInfo implements Serializable
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 总记录数 */
+    private long total;
+
+    /** 列表数据 */
+    private List<?> rows;
+
+    /** 消息状态码 */
+    private int code;
+
+    /** 消息内容 */
+    private String msg;
+
+    /**
+     * 表格数据对象
+     */
+    public TableDataInfo()
+    {
+    }
+
+    /**
+     * 分页
+     * 
+     * @param list 列表数据
+     * @param total 总记录数
+     */
+    public TableDataInfo(List<?> list, int total)
+    {
+        this.rows = list;
+        this.total = total;
+    }
+
+    public long getTotal()
+    {
+        return total;
+    }
+
+    public void setTotal(long total)
+    {
+        this.total = total;
+    }
+
+    public List<?> getRows()
+    {
+        return rows;
+    }
+
+    public void setRows(List<?> rows)
+    {
+        this.rows = rows;
+    }
+
+    public int getCode()
+    {
+        return code;
+    }
+
+    public void setCode(int code)
+    {
+        this.code = code;
+    }
+
+    public String getMsg()
+    {
+        return msg;
+    }
+
+    public void setMsg(String msg)
+    {
+        this.msg = msg;
+    }
+}

+ 5 - 0
src/main/resources/mappers/ComponentModificationRecordMapper.xml

@@ -0,0 +1,5 @@
+<?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.gyee.table.mapper.ComponentModificationRecordMapper">
+
+</mapper>

+ 29 - 0
src/main/resources/mappers/Configurationinfo.xml

@@ -2,4 +2,33 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.gyee.table.mapper.ConfigurationinfoMapper">
 
+    <resultMap type="Configurationinfo" id="ConfigurationinfoResult">
+        <id     property="id"             column="id"                  />
+        <result property="name"           column="name"                />
+        <result property="needBg"         column="need_bg"             />
+        <result property="needColor"      column="need_color"          />
+        <result property="needLw"         column="need_lw"             />
+        <result property="needMap"        column="need_map"            />
+        <result property="needMapDone"    column="need_map_done"       />
+        <result property="otherDesc"      column="other_desc"          />
+        <result property="otherNeed"      column="other_need"          />
+        <result property="stateDesc"      column="state_desc"          />
+        <result property="svg"            column="svg"                 />
+        <result property="trSvg"          column="tr_svg"              />
+        <result property="type"           column="type"                />
+        <result property="uploadDate"     column="upload_date"         />
+        <result property="user"           column="user"                />
+        <result property="updataDate"     column="updata_date"         />
+        <result property="changeUser"     column="change_user"         />
+    </resultMap>
+
+    <select id="selectConfigurationinfoList" parameterType="Configurationinfo" resultMap="ConfigurationinfoResult">
+        select * from configurationinfo
+        <where>
+            <if test="name != null and name != ''">and name = #{name}</if>
+            <if test="user != null and user != ''">and user = #{user}</if>
+            <if test="changeUser != null and changeUser != ''">and changeUser = #{changeUser}</if>
+            <if test="needMapDone != null">and needMapDone = #{needMapDone}</if>
+        </where>
+    </select>
 </mapper>

+ 5 - 0
src/main/resources/mappers/UserMapper.xml

@@ -0,0 +1,5 @@
+<?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.gyee.table.mapper.UserMapper">
+
+</mapper>