Browse Source

自定义配置类

guarantee-lsq 7 months ago
parent
commit
b431151de9

+ 95 - 0
platform-dao/src/main/java/com/platform/dao/dto/custom/CustomClassNameDTO.java

@@ -0,0 +1,95 @@
+package com.platform.dao.dto.custom;
+
+import com.platform.common.bean.BaseDTO;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * @Description 自定义配置类DTO
+ * @Author lsq
+ * @Date 2024-08-01 16:41:47
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+public class CustomClassNameDTO extends BaseDTO implements Serializable {
+
+    /**
+     * ID
+     */
+    private String id;
+    /**
+     * 配置类型  table_name&class_name
+     */
+    private String code;
+    /**
+     * 名称
+     */
+    private String title;
+    /**
+     * 名称编码
+     */
+    private String titleCode;
+    /**
+     * 方法名称
+     */
+    private String methodName;
+    /**
+     * 名方法名称编码
+     */
+    private String methodCode;
+    /**
+     * 备注简介
+     */
+    private String remark;
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createdTime;
+    /**
+     * 创建时间开始
+     */
+    private LocalDateTime createdTimeStart;
+    /**
+     * 创建时间结束
+     */
+    private LocalDateTime createdTimeEnd;
+    /**
+     * 创建人ID
+     */
+    private String createdUserId;
+    /**
+     * 创建人
+     */
+    private String createdUserName;
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updateTime;
+    /**
+     * 更新时间开始
+     */
+    private LocalDateTime updateTimeStart;
+    /**
+     * 更新时间结束
+     */
+    private LocalDateTime updateTimeEnd;
+    /**
+     * 更新人ID
+     */
+    private String updateUserId;
+    /**
+     * 更新人
+     */
+    private String updateUserName;
+    /**
+     * 关键字
+     */
+    private String keyword;
+
+}

+ 84 - 0
platform-dao/src/main/java/com/platform/dao/entity/custom/CustomClassName.java

@@ -0,0 +1,84 @@
+package com.platform.dao.entity.custom;
+
+import com.platform.common.bean.DataScope;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * @Description 自定义配置类实体类
+ * @Author lsq
+ * @Date 2024-08-01 16:41:47
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@Data
+@Accessors(chain = true)
+@Table(name = "t_custom_class_name")
+public class CustomClassName implements Serializable {
+
+    /**
+     * ID
+     */
+    @Id
+    private String id;
+    /**
+     * 配置类型  table_name&class_name
+     */
+    private String code;
+    /**
+     * 名称
+     */
+    private String title;
+    /**
+     * 名称编码
+     */
+    private String titleCode;
+    /**
+     * 方法名称
+     */
+    private String methodName;
+    /**
+     * 名方法名称编码
+     */
+    private String methodCode;
+    /**
+     * 备注简介
+     */
+    private String remark;
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createdTime;
+    /**
+     * 创建人ID
+     */
+    private String createdUserId;
+    /**
+     * 创建人
+     */
+    private String createdUserName;
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updateTime;
+    /**
+     * 更新人ID
+     */
+    private String updateUserId;
+    /**
+     * 更新人
+     */
+    private String updateUserName;
+
+    /**
+     * 数据权限
+     */
+    @Transient
+    private DataScope dataScope;
+
+}

+ 26 - 0
platform-dao/src/main/java/com/platform/dao/mapper/custom/CustomClassNameMapper.java

@@ -0,0 +1,26 @@
+package com.platform.dao.mapper.custom;
+
+import com.platform.dao.dto.custom.CustomClassNameDTO;
+import com.platform.dao.config.MyMapper;
+import com.platform.dao.entity.custom.CustomClassName;
+import com.platform.dao.vo.query.custom.CustomClassNameVO;
+import org.springframework.stereotype.Component;
+import java.util.List;
+
+
+/**
+ * @Description 自定义配置类 mapper
+ * @Author lsq
+ * @Date 2024-08-01 16:41:47
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@Component
+public interface CustomClassNameMapper extends MyMapper<CustomClassName> {
+    /**
+     * 分页查询
+     * @param dto
+     * @return
+     */
+    List<CustomClassNameVO> selectList(CustomClassNameDTO dto);
+
+}

+ 99 - 0
platform-dao/src/main/java/com/platform/dao/vo/export/custom/ExportCustomClassNameVO.java

@@ -0,0 +1,99 @@
+package com.platform.dao.vo.export.custom;
+
+import com.platform.office.annotation.Excel;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.time.LocalDate;
+
+/**
+ * @Description 自定义配置类导出VO
+ * @Author lsq
+ * @Date 2024-08-01 16:41:47
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@Data
+@Accessors(chain = true)
+public class ExportCustomClassNameVO implements Serializable {
+
+    /**
+   * ID
+   */
+          @Excel(name = "ID", orderNum = "1")
+      private String id;
+    
+    /**
+   * 配置类型  table_name&class_name
+   */
+          @Excel(name = "配置类型  table_name&class_name", orderNum = "2")
+      private String code;
+    
+    /**
+   * 名称
+   */
+          @Excel(name = "名称", orderNum = "3")
+      private String title;
+    
+    /**
+   * 名称编码
+   */
+          @Excel(name = "名称编码", orderNum = "4")
+      private String titleCode;
+    
+    /**
+   * 方法名称
+   */
+          @Excel(name = "方法名称", orderNum = "5")
+      private String methodName;
+    
+    /**
+   * 名方法名称编码
+   */
+          @Excel(name = "名方法名称编码", orderNum = "6")
+      private String methodCode;
+    
+    /**
+   * 备注简介
+   */
+          @Excel(name = "备注简介", orderNum = "7")
+      private String remark;
+    
+    /**
+   * 创建时间
+   */
+          @Excel(name = "创建时间", orderNum = "8")
+      private LocalDateTime createdTime;
+    
+    /**
+   * 创建人ID
+   */
+          @Excel(name = "创建人ID", orderNum = "9")
+      private String createdUserId;
+    
+    /**
+   * 创建人
+   */
+          @Excel(name = "创建人", orderNum = "10")
+      private String createdUserName;
+    
+    /**
+   * 更新时间
+   */
+          @Excel(name = "更新时间", orderNum = "11")
+      private LocalDateTime updateTime;
+    
+    /**
+   * 更新人ID
+   */
+          @Excel(name = "更新人ID", orderNum = "12")
+      private String updateUserId;
+    
+    /**
+   * 更新人
+   */
+          @Excel(name = "更新人", orderNum = "13")
+      private String updateUserName;
+    
+  
+}

+ 76 - 0
platform-dao/src/main/java/com/platform/dao/vo/query/custom/CustomClassNameVO.java

@@ -0,0 +1,76 @@
+package com.platform.dao.vo.query.custom;
+
+import com.platform.common.bean.BaseVO;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * @Description 自定义配置类VO结果类
+ * @Author lsq
+ * @Date 2024-08-01 16:41:47
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@Data
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = true)
+public class CustomClassNameVO extends BaseVO implements Serializable {
+
+    /**
+     * ID
+     */
+    private String id;
+    /**
+     * 配置类型  table_name&class_name
+     */
+    private String code;
+    /**
+     * 名称
+     */
+    private String title;
+    /**
+     * 名称编码
+     */
+    private String titleCode;
+    /**
+     * 方法名称
+     */
+    private String methodName;
+    /**
+     * 名方法名称编码
+     */
+    private String methodCode;
+    /**
+     * 备注简介
+     */
+    private String remark;
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createdTime;
+    /**
+     * 创建人ID
+     */
+    private String createdUserId;
+    /**
+     * 创建人
+     */
+    private String createdUserName;
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updateTime;
+    /**
+     * 更新人ID
+     */
+    private String updateUserId;
+    /**
+     * 更新人
+     */
+    private String updateUserName;
+
+
+}

+ 67 - 0
platform-dao/src/main/resources/mapper/custom/CustomClassNameMapper.xml

@@ -0,0 +1,67 @@
+<?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.platform.dao.mapper.custom.CustomClassNameMapper">
+    <sql id="List_Condition">
+        <if test="id != null and id != ''">
+            and className.id = #{id}
+        </if>
+        <if test="code != null and code != ''">
+            and className.code = #{code}
+        </if>
+        <if test="title != null and title != ''">
+            and className.title = #{title}
+        </if>
+        <if test="titleCode != null and titleCode != ''">
+            and className.title_code = #{titleCode}
+        </if>
+        <if test="methodName != null and methodName != ''">
+            and className.method_name = #{methodName}
+        </if>
+        <if test="methodCode != null and methodCode != ''">
+            and className.method_code = #{methodCode}
+        </if>
+        <if test="remark != null and remark != ''">
+            and className.remark = #{remark}
+        </if>
+        <if test="createdTimeStart != null">
+            and className.created_time <![CDATA[>=]]>; #{createdTimeStart}
+        </if>
+        <if test="createdTimeEnd != null">
+            and className.created_time <![CDATA[<=]]> #{createdTimeEnd}
+        </if>
+        <if test="createdTime != null">
+            and className.created_time = #{createdTime}
+        </if>
+        <if test="createdUserId != null and createdUserId != ''">
+            and className.created_user_id = #{createdUserId}
+        </if>
+        <if test="createdUserName != null and createdUserName != ''">
+            and className.created_user_name = #{createdUserName}
+        </if>
+        <if test="updateTimeStart != null">
+            and className.update_time <![CDATA[>=]]>; #{updateTimeStart}
+        </if>
+        <if test="updateTimeEnd != null">
+            and className.update_time <![CDATA[<=]]> #{updateTimeEnd}
+        </if>
+        <if test="updateTime != null">
+            and className.update_time = #{updateTime}
+        </if>
+        <if test="updateUserId != null and updateUserId != ''">
+            and className.update_user_id = #{updateUserId}
+        </if>
+        <if test="updateUserName != null and updateUserName != ''">
+            and className.update_user_name = #{updateUserName}
+        </if>
+        <if test="keyword != null and keyword != ''">
+            and className.id like concat(concat('%',#{keyword}),'%')
+        </if>
+    </sql>
+    <select id="selectList" parameterType="com.platform.dao.dto.custom.CustomClassNameDTO" resultType="com.platform.dao.vo.query.custom.CustomClassNameVO">
+        select className.*
+        from t_custom_class_name as className
+        <where>
+            <include refid="List_Condition"/>
+        </where>
+    </select>
+</mapper>

+ 141 - 0
platform-rest/src/main/java/com/platform/rest/controller/custom/CustomClassNameController.java

@@ -0,0 +1,141 @@
+package com.platform.rest.controller.custom;
+
+import com.platform.common.util.R;
+import com.platform.dao.dto.custom.CustomClassNameDTO;
+import com.platform.dao.entity.custom.CustomClassName;
+import com.platform.service.custom.CustomClassNameService;
+import com.platform.dao.util.ExcelUtil;
+import com.platform.dao.vo.export.custom.ExportCustomClassNameVO;
+import com.platform.dao.vo.query.custom.CustomClassNameVO;
+import com.platform.common.util.BeanConverterUtil;
+import com.platform.common.validation.group.AddGroup;
+import com.platform.common.validation.group.UpdateGroup;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import lombok.AllArgsConstructor;
+import com.platform.common.bean.AbstractPageResultBean;
+import com.platform.rest.log.annotation.SysLog;
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @Description 自定义配置类 控制器
+ * @Author lsq
+ * @Date 2024-08-01 16:41:47
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/custom/className")
+public class CustomClassNameController {
+
+  private final  CustomClassNameService customClassNameService;
+
+  /**
+   * 通过id查询单条记录
+   *
+   * @param id 主键
+   * @return R
+   */
+  @GetMapping("/{id}")
+  public R<CustomClassName> getById(@PathVariable("id") String id){
+      return new R<>(customClassNameService.getModelById(id));
+  }
+
+  /**
+   * 新增记录
+   *
+   * @param customClassNameDTO 自定义配置类DTO
+   * @return R
+   */
+  @SysLog("新增自定义配置类")
+  @PostMapping
+  @PreAuthorize("@pms.hasPermission('custom-className-add')")
+  public R save(@Validated({AddGroup.class}) @RequestBody CustomClassNameDTO customClassNameDTO) {
+      return new R<>(customClassNameService.saveModelByDTO(customClassNameDTO));
+  }
+
+  /**
+   * 修改记录
+   *
+   * @param customClassNameDTO 自定义配置类DTO
+   * @return R
+   */
+  @SysLog("修改自定义配置类")
+  @PutMapping("/{id}")
+  @PreAuthorize("@pms.hasPermission('custom-className-edit')")
+  public R update(@PathVariable("id") String id, @Validated({UpdateGroup.class}) @RequestBody CustomClassNameDTO customClassNameDTO) {
+      customClassNameService.modModelByDTO(customClassNameDTO);
+      return new R<>();
+  }
+
+
+                                                                                
+  /**
+   * 通过id删除一条记录
+   *
+   * @param id 主键
+   * @return R
+   */
+  @SysLog("删除自定义配置类")
+  @DeleteMapping("/{id}")
+  @PreAuthorize("@pms.hasPermission('custom-className-del')")
+  public R removeById(@PathVariable String id){
+    customClassNameService.deleteByPrimaryKey(id);
+    return new R<>();
+  }
+
+    /**
+     * 批量记录
+     *
+     * @param ids 主键
+     * @return R
+     */
+    @SysLog("批量删除自定义配置类")
+    @DeleteMapping("")
+    @PreAuthorize("@pms.hasPermission('custom-className-del')")
+    public R removeIds(@RequestBody List<String> ids){
+        customClassNameService.batchDelete(ids);
+        return new R<>();
+    }
+
+  /**
+   * 获取分页
+   *
+   * @param pageNum 当前页码
+   * @param pageSize 每页条数
+   * @param customClassNameDTO 自定义配置类DTO
+   * @return R
+   */
+  @GetMapping("/page")
+  public R<AbstractPageResultBean<CustomClassNameVO>> query(CustomClassNameDTO customClassNameDTO, @RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "20") int pageSize) {
+      return new R<>(customClassNameService.selectPageList(customClassNameDTO, pageNum, pageSize));
+  }
+
+  /**
+   * 获取列表
+   *
+   * @param customClassNameDTO 自定义配置类DTO
+   * @return R
+   */
+  @GetMapping("")
+  public R query(CustomClassNameDTO customClassNameDTO) {
+      return new R<>(customClassNameService.getModelListByDTO(customClassNameDTO));
+  }
+
+  /**
+     * 自定义配置类导出
+     *
+     * @param customClassNameDTO 自定义配置类DTO
+     * @return R
+     */
+  @GetMapping("/export")
+  @SysLog("自定义配置类导出")
+  @PreAuthorize("@pms.hasPermission('custom-className-export')")
+  public void export(HttpServletResponse response, CustomClassNameDTO customClassNameDTO) {
+    List<CustomClassName> list = customClassNameService.getModelListByDTO(customClassNameDTO);
+    ExcelUtil.exportResponseDict(response, ExportCustomClassNameVO.class, BeanConverterUtil.copyListProperties(list, ExportCustomClassNameVO.class), "自定义配置类");
+  }
+
+}

+ 37 - 0
platform-service/src/main/java/com/platform/service/custom/CustomClassNameService.java

@@ -0,0 +1,37 @@
+package com.platform.service.custom;
+
+import com.platform.dao.vo.query.custom.CustomClassNameVO;
+import com.platform.dao.dto.custom.CustomClassNameDTO;
+import com.platform.dao.entity.custom.CustomClassName;
+import com.platform.common.bean.AbstractPageResultBean;
+import com.platform.service.base.IBaseService;
+
+import java.util.List;
+
+/**
+ * @Description 自定义配置类 service
+ * @Author lsq
+ * @Date 2024-08-01 16:41:47
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
+ */
+public interface CustomClassNameService extends IBaseService<CustomClassName, CustomClassNameDTO> {
+
+    /**
+     * 批量删除
+     *
+     * @param ids :
+     * @return :
+     */
+    int batchDelete(List<String> ids);
+
+    /**
+     * 分页查询
+     *
+     * @param record
+     * @param pageNum
+     * @param pageSize
+     * @return
+     */
+    AbstractPageResultBean<CustomClassNameVO> selectPageList(CustomClassNameDTO record, int pageNum, int pageSize);
+
+}

+ 51 - 0
platform-service/src/main/java/com/platform/service/custom/impl/CustomClassNameServiceImpl.java

@@ -0,0 +1,51 @@
+package com.platform.service.custom.impl;
+
+import com.platform.common.bean.AbstractPageResultBean;
+import com.platform.dao.bean.MyPage;
+import com.github.pagehelper.PageHelper;
+import com.platform.dao.vo.query.custom.CustomClassNameVO;
+import com.platform.dao.dto.custom.CustomClassNameDTO;
+import com.platform.dao.entity.custom.CustomClassName;
+import com.platform.dao.mapper.custom.CustomClassNameMapper;
+import com.platform.service.custom.CustomClassNameService;
+import org.springframework.stereotype.Service;
+import com.platform.service.base.impl.BaseServiceImpl;
+import org.springframework.transaction.annotation.Transactional;
+import tk.mybatis.mapper.weekend.Weekend;
+import tk.mybatis.mapper.weekend.WeekendCriteria;
+import lombok.AllArgsConstructor;
+
+import java.util.List;
+
+/**
+ * @Description 自定义配置类 service 实现类
+ * @Author lsq
+ * @Date 2024-08-01 16:41:47
+ * @Version Copyright (c) 2020,北京乾元坤和科技有限公司 All rights reserved.
+ */
+@AllArgsConstructor
+@Service("customClassNameService")
+public class CustomClassNameServiceImpl extends BaseServiceImpl<CustomClassNameMapper, CustomClassName, CustomClassNameDTO> implements CustomClassNameService {
+
+    @Override
+    public int batchDelete(List<String> ids) {
+        Weekend<CustomClassName> weekend = new Weekend<>(CustomClassName.class);
+        WeekendCriteria<CustomClassName, Object> weekendCriteria = weekend.weekendCriteria();
+        weekendCriteria.andIn(CustomClassName::getId, ids);
+        mapper.deleteByExample(weekend);
+        return 1;
+    }
+
+    @Override
+    public AbstractPageResultBean<CustomClassNameVO> selectPageList(CustomClassNameDTO record, int pageNum, int pageSize) {
+        PageHelper.startPage(pageNum, pageSize);
+        return new MyPage(mapper.selectList(record));
+    }
+
+    @Override
+    public AbstractPageResultBean<CustomClassName> selectPageInfo(CustomClassNameDTO record, int pageNum, int pageSize) {
+        PageHelper.startPage(pageNum, pageSize);
+        return new MyPage(mapper.selectList(record));
+    }
+
+}