From d60d905750e86e7dbcbf932ee2aa7bb835f879bc Mon Sep 17 00:00:00 2001
From: zepengdev <lzpsmith@outlook.com>
Date: Wed, 04 Jun 2025 08:24:32 +0800
Subject: [PATCH] 1、PlatformCategory继承BaseEntity 2、调整PlatformCategoryView字段 3、完成queryPlatformCategory接口开发

---
 /dev/null                                                                                              |   33 -----------
 oying-system/src/main/java/com/oying/modules/pc/category/view/PlatformCategoryAdminView.java           |   29 +++++++++
 oying-system/src/main/java/com/oying/modules/pc/category/converter/PlatformCategoryViewAssembler.java  |    6 +-
 oying-system/src/main/java/com/oying/modules/pc/category/rest/PlatformCategoryAdminController.java     |   12 ++--
 oying-system/src/main/java/com/oying/modules/pc/category/domain/PlatformCategory.java                  |   37 ++++-------
 oying-system/src/main/java/com/oying/modules/pc/category/service/impl/PlatformCategoryServiceImpl.java |    2 
 oying-system/src/main/resources/mapper/pc/category/PlatformCategoryMapper.xml                          |   10 +++
 oying-system/src/main/java/com/oying/modules/pc/category/domain/dto/PlatformCategoryQueryCriteria.java |   31 ++++++++--
 8 files changed, 87 insertions(+), 73 deletions(-)

diff --git a/oying-system/src/main/java/com/oying/modules/pc/category/converter/PlatformCategoryViewAssembler.java b/oying-system/src/main/java/com/oying/modules/pc/category/converter/PlatformCategoryViewAssembler.java
index 8b70f78..6f2552a 100644
--- a/oying-system/src/main/java/com/oying/modules/pc/category/converter/PlatformCategoryViewAssembler.java
+++ b/oying-system/src/main/java/com/oying/modules/pc/category/converter/PlatformCategoryViewAssembler.java
@@ -3,14 +3,14 @@
 import cn.hutool.core.bean.BeanUtil;
 import com.oying.modules.pc.category.domain.PlatformCategory;
 import com.oying.modules.pc.category.view.PlatformCategoryCustomerView;
-import com.oying.modules.pc.category.view.PlatformCategoryView;
+import com.oying.modules.pc.category.view.PlatformCategoryAdminView;
 import org.springframework.stereotype.Component;
 
 @Component
 public class PlatformCategoryViewAssembler {
 
-    public PlatformCategoryView toPlatformCategoryResponse(PlatformCategory category) {
-        PlatformCategoryView categoryView = new PlatformCategoryView();
+    public PlatformCategoryAdminView toPlatformCategoryResponse(PlatformCategory category) {
+        PlatformCategoryAdminView categoryView = new PlatformCategoryAdminView();
         BeanUtil.copyProperties(category, categoryView);
         categoryView.setIconUrl("");
         return categoryView;
diff --git a/oying-system/src/main/java/com/oying/modules/pc/category/domain/PlatformCategory.java b/oying-system/src/main/java/com/oying/modules/pc/category/domain/PlatformCategory.java
index 258cc2b..0eebb8c 100644
--- a/oying-system/src/main/java/com/oying/modules/pc/category/domain/PlatformCategory.java
+++ b/oying-system/src/main/java/com/oying/modules/pc/category/domain/PlatformCategory.java
@@ -1,25 +1,27 @@
 package com.oying.modules.pc.category.domain;
 
-import lombok.Data;
 import cn.hutool.core.bean.BeanUtil;
-import io.swagger.annotations.ApiModelProperty;
 import cn.hutool.core.bean.copier.CopyOptions;
-import java.sql.Timestamp;
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.NotNull;
-import java.io.Serializable;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.oying.base.BaseEntity;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
 
 /**
-* @description /
 * @author lzp
 * @date 2025-04-28
 **/
-@Data
+@Getter
+@Setter
 @TableName("pc_platform_category")
-public class PlatformCategory implements Serializable {
+public class PlatformCategory extends BaseEntity implements Serializable {
 
     @TableId(value = "category_id", type = IdType.AUTO)
     @ApiModelProperty(value = "类目ID")
@@ -44,6 +46,9 @@
     @ApiModelProperty(value = "类目图标ID")
     private Long iconId;
 
+    @ApiModelProperty(value = "类目图标Url")
+    private String iconUrl;
+
     @NotNull
     @ApiModelProperty(value = "状态")
     private Integer status;
@@ -51,20 +56,6 @@
     @NotNull
     @ApiModelProperty(value = "是否启用(0-否 1-是)")
     private Integer active;
-
-    @ApiModelProperty(value = "创建人")
-    private Long createBy;
-
-    @NotNull
-    @ApiModelProperty(value = "创建时间")
-    private Timestamp createTime;
-
-    @ApiModelProperty(value = "修改人")
-    private Long updateBy;
-
-    @NotNull
-    @ApiModelProperty(value = "更新时间")
-    private Timestamp updateTime;
 
     public void copy(PlatformCategory source){
         BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
diff --git a/oying-system/src/main/java/com/oying/modules/pc/category/domain/dto/PlatformCategoryQueryCriteria.java b/oying-system/src/main/java/com/oying/modules/pc/category/domain/dto/PlatformCategoryQueryCriteria.java
index 3ed3ef2..ee3126f 100644
--- a/oying-system/src/main/java/com/oying/modules/pc/category/domain/dto/PlatformCategoryQueryCriteria.java
+++ b/oying-system/src/main/java/com/oying/modules/pc/category/domain/dto/PlatformCategoryQueryCriteria.java
@@ -1,17 +1,32 @@
 package com.oying.modules.pc.category.domain.dto;
 
-import lombok.Data;
+import com.oying.utils.DateUtil;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.time.LocalDateTime;
 
 /**
-* @author lzp
-* @date 2025-04-30
-**/
+ * @author lzp
+ * @date 2025-04-30
+ **/
 @Data
-public class PlatformCategoryQueryCriteria{
+public class PlatformCategoryQueryCriteria {
+
+    @ApiModelProperty(value = "模糊查询")
+    private String blurry;
 
     @ApiModelProperty(value = "是否启用", example = "1")
-    private Integer active = 1;
+    private Integer active;
+
+    @ApiModelProperty(value = "开始时间", example = "2025-06-03 00:00:00")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime createStart;
+
+    @ApiModelProperty(value = "结束时间", example = "2025-06-03 23:59:59")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime createEnd;
 
     @ApiModelProperty(value = "页码", example = "1")
     private Integer page = 1;
@@ -19,4 +34,8 @@
     @ApiModelProperty(value = "每页数据量", example = "10")
     private Integer size = 10;
 
+    public static void main(String[] args) {
+        System.out.println(DateUtil.getTimeStamp(DateUtil.parseLocalDateTimeFormat("2025-04-30 18:21:22", "yyyy-MM-dd HH:mm:ss")));
+    }
+
 }
diff --git a/oying-system/src/main/java/com/oying/modules/pc/category/rest/PlatformCategoryAdminController.java b/oying-system/src/main/java/com/oying/modules/pc/category/rest/PlatformCategoryAdminController.java
index fd2668e..3dba34a 100644
--- a/oying-system/src/main/java/com/oying/modules/pc/category/rest/PlatformCategoryAdminController.java
+++ b/oying-system/src/main/java/com/oying/modules/pc/category/rest/PlatformCategoryAdminController.java
@@ -9,7 +9,7 @@
 import com.oying.modules.pc.category.domain.dto.PlatformCategoryUpdateDto;
 import com.oying.modules.pc.category.domain.dto.PlatformCategoryUpdateRequest;
 import com.oying.modules.pc.category.service.PlatformCategoryService;
-import com.oying.modules.pc.category.view.PlatformCategoryView;
+import com.oying.modules.pc.category.view.PlatformCategoryAdminView;
 import com.oying.utils.R;
 import com.oying.utils.PageResult;
 import io.swagger.annotations.Api;
@@ -41,14 +41,14 @@
     private final PlatformCategoryService categoryService;
     private final PlatformCategoryViewAssembler assembler;
 
-    @GetMapping
+    @GetMapping(value = "/list")
     @ApiOperation("查询平台类目(支持分页)")
-    @PreAuthorize("@el.check('admin:platformCategory:list')")
+    //@PreAuthorize("@el.check('admin:platformCategory:list')")
     public ResponseEntity<?> queryPlatformCategory(PlatformCategoryQueryCriteria criteria) {
         Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
         PageResult<PlatformCategory> pageResult = categoryService.queryAll(criteria, page);
-        List<PlatformCategoryView> responseList = Optional.ofNullable(pageResult.getContent()).orElse(new ArrayList<>()).stream().map(assembler::toPlatformCategoryResponse).collect(Collectors.toList());
-        PageResult<PlatformCategoryView> responsePageResult = new PageResult<>(responseList, pageResult.getTotalElements());
+        List<PlatformCategoryAdminView> responseList = Optional.ofNullable(pageResult.getContent()).orElse(new ArrayList<>()).stream().map(assembler::toPlatformCategoryResponse).collect(Collectors.toList());
+        PageResult<PlatformCategoryAdminView> responsePageResult = new PageResult<>(responseList, pageResult.getTotalElements());
         return ResponseEntity.ok(R.success(responsePageResult));
     }
 
@@ -60,7 +60,7 @@
         return ResponseEntity.status(HttpStatus.CREATED).build();
     }
 
-    @PutMapping("/{categoryId}")
+    @PutMapping(value = "/{categoryId}")
     @ApiOperation("修改平台类目")
     //@PreAuthorize("@el.check('admin:platformCategory:updateById')")
     public ResponseEntity<?> updateById(@PathVariable Long categoryId,
diff --git a/oying-system/src/main/java/com/oying/modules/pc/category/service/impl/PlatformCategoryServiceImpl.java b/oying-system/src/main/java/com/oying/modules/pc/category/service/impl/PlatformCategoryServiceImpl.java
index 5b220a6..7e74136 100644
--- a/oying-system/src/main/java/com/oying/modules/pc/category/service/impl/PlatformCategoryServiceImpl.java
+++ b/oying-system/src/main/java/com/oying/modules/pc/category/service/impl/PlatformCategoryServiceImpl.java
@@ -53,7 +53,6 @@
         platformCategoryCreate.setSortWeight(request.getSortWeight());
         platformCategoryCreate.setIconId(request.getIconUploadFileId());
         platformCategoryCreate.setActive(request.getActive());
-        platformCategoryCreate.setCreateBy(SecurityUtils.getCurrentUserId());
 
         // 使用处理图标文件
         platformCategoryMapper.insert(platformCategoryCreate);
@@ -76,7 +75,6 @@
         platformCategoryUpdate.setIconId(updateDto.getIconUploadFileId());
         platformCategoryUpdate.setActive(updateDto.getActive());
         existingPlatformCategory.copy(platformCategoryUpdate);
-        existingPlatformCategory.setUpdateBy(SecurityUtils.getCurrentUserId());
         platformCategoryMapper.updateById(existingPlatformCategory);
 
         // 使用处理图标文件
diff --git a/oying-system/src/main/java/com/oying/modules/pc/category/view/PlatformCategoryAdminView.java b/oying-system/src/main/java/com/oying/modules/pc/category/view/PlatformCategoryAdminView.java
new file mode 100644
index 0000000..be1d942
--- /dev/null
+++ b/oying-system/src/main/java/com/oying/modules/pc/category/view/PlatformCategoryAdminView.java
@@ -0,0 +1,29 @@
+package com.oying.modules.pc.category.view;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+@Data
+public class PlatformCategoryAdminView implements Serializable {
+
+    private Long categoryId;
+
+    private String name;
+
+    private Integer sortWeight;
+
+    private String iconUrl;
+
+    private Integer active;
+
+    private String createBy;
+
+    private LocalDateTime createTime;
+
+    private String updateBy;
+
+    private LocalDateTime updateTime;
+
+}
diff --git a/oying-system/src/main/java/com/oying/modules/pc/category/view/PlatformCategoryView.java b/oying-system/src/main/java/com/oying/modules/pc/category/view/PlatformCategoryView.java
deleted file mode 100644
index 3fa48a8..0000000
--- a/oying-system/src/main/java/com/oying/modules/pc/category/view/PlatformCategoryView.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.oying.modules.pc.category.view;
-
-import lombok.Data;
-
-import java.io.Serializable;
-import java.sql.Timestamp;
-
-@Data
-public class PlatformCategoryView implements Serializable {
-
-    private Long categoryId;
-
-    private String name;
-
-    private Integer sort;
-
-    private String icon;
-
-    private String iconUrl;
-
-    private Integer status;
-
-    private Integer visible;
-
-    private Long createBy;
-
-    private Timestamp createTime;
-
-    private Long updateBy;
-
-    private Timestamp updateTime;
-
-}
diff --git a/oying-system/src/main/resources/mapper/pc/category/PlatformCategoryMapper.xml b/oying-system/src/main/resources/mapper/pc/category/PlatformCategoryMapper.xml
index be265d3..86b2d88 100644
--- a/oying-system/src/main/resources/mapper/pc/category/PlatformCategoryMapper.xml
+++ b/oying-system/src/main/resources/mapper/pc/category/PlatformCategoryMapper.xml
@@ -8,6 +8,7 @@
         <result column="level" property="level"/>
         <result column="sort_weight" property="sortWeight"/>
         <result column="icon_id" property="iconId"/>
+        <result column="icon_url" property="iconId"/>
         <result column="status" property="status"/>
         <result column="active" property="active"/>
         <result column="create_by" property="createBy"/>
@@ -25,9 +26,18 @@
         <include refid="Base_Column_List"/>
         from pc_platform_category
         <where>
+            <if test="criteria.blurry != null and criteria.blurry != ''">
+                and name like concat('%',#{criteria.blurry},'%')
+            </if>
             <if test="criteria.active != null">
                 and active = #{criteria.active}
             </if>
+            <if test="criteria.createStart != null">
+                and create_time &gt;= #{criteria.createStart}
+            </if>
+            <if test="criteria.createEnd != null">
+                and create_time &lt;= #{criteria.createEnd}
+            </if>
         </where>
         order by category_id desc
     </select>

--
Gitblit v1.9.3