张延森 3 vuotta sitten
vanhempi
commit
b168800bfc

+ 55
- 23
src/main/java/com/yunzhi/training/controller/TaAttachmentController.java Näytä tiedosto

@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.yunzhi.training.common.BaseController;
7
+import com.yunzhi.training.common.Constants;
7 8
 import com.yunzhi.training.common.ResponseBean;
9
+import com.yunzhi.training.common.StringUtils;
8 10
 import io.swagger.annotations.Api;
9 11
 import io.swagger.annotations.ApiOperation;
10 12
 import io.swagger.annotations.ApiParam;
@@ -46,17 +48,24 @@ public class TaAttachmentController extends BaseController {
46 48
      * @param pageSize
47 49
      * @return
48 50
      */
49
-    @RequestMapping(value="/taAttachment",method= RequestMethod.GET)
51
+    @RequestMapping(value="/{client}/attachment",method= RequestMethod.GET)
50 52
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51
-    public ResponseBean taAttachmentList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
-									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
53
+    public ResponseBean taAttachmentList(@ApiParam(value = "客户端",allowableValues = "admin,wx") @PathVariable String client,
54
+                                         @ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
55
+                                         @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
56
+                                         @ApiParam("附件类型") @RequestParam(value ="attchType", defaultValue = "image") String attchType,
57
+                                         @ApiParam("所属包组") @RequestParam(value ="packId", required = false) String packId) throws Exception{
53 58
 
54
-		    IPage<TaAttachment> pg = new Page<>(pageNum, pageSize);
55
-            QueryWrapper<TaAttachment> queryWrapper = new QueryWrapper<>();
56
-            queryWrapper.orderByDesc("create_date");
59
+        IPage<TaAttachment> pg = new Page<>(pageNum, pageSize);
60
+        QueryWrapper<TaAttachment> queryWrapper = new QueryWrapper<>();
61
+        queryWrapper.eq(!StringUtils.isEmpty(attchType), "attch_type", attchType);
62
+        queryWrapper.eq(!StringUtils.isEmpty(packId), "pack_id", packId);
63
+        queryWrapper.gt("state", Constants.STATUS_DELETED);
64
+        queryWrapper.eq("wx".equals(client), "state", Constants.STATUS_NORMAL);
65
+        queryWrapper.orderByDesc("create_date");
57 66
 
58
-            IPage<TaAttachment> result = iTaAttachmentService.page(pg, queryWrapper);
59
-            return ResponseBean.success(result);
67
+        IPage<TaAttachment> result = iTaAttachmentService.page(pg, queryWrapper);
68
+        return ResponseBean.success(result);
60 69
     }
61 70
 
62 71
     /**
@@ -64,10 +73,22 @@ public class TaAttachmentController extends BaseController {
64 73
      * @param taAttachment 实体对象
65 74
      * @return
66 75
      */
67
-    @RequestMapping(value="/taAttachment",method= RequestMethod.POST)
76
+    @RequestMapping(value="/admin/attachment",method= RequestMethod.POST)
68 77
     @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69 78
     public ResponseBean taAttachmentAdd(@ApiParam("保存内容") @RequestBody TaAttachment taAttachment) throws Exception{
70 79
 
80
+        if (StringUtils.isEmpty(taAttachment.getUrl())) {
81
+            return ResponseBean.error("请设置附件地址", ResponseBean.ERROR_ILLEGAL_PARAMS);
82
+        }
83
+        if (StringUtils.isEmpty(taAttachment.getPackId())) {
84
+            return ResponseBean.error("请设置附件包组", ResponseBean.ERROR_ILLEGAL_PARAMS);
85
+        }
86
+        if (StringUtils.isEmpty(taAttachment.getAttchType())) {
87
+            taAttachment.setAttchType("image");
88
+        }
89
+
90
+        taAttachment.setAttchId(null);
91
+
71 92
         if (iTaAttachmentService.save(taAttachment)){
72 93
             return ResponseBean.success(taAttachment);
73 94
         }else {
@@ -79,10 +100,10 @@ public class TaAttachmentController extends BaseController {
79 100
      * 根据id删除对象
80 101
      * @param id  实体ID
81 102
      */
82
-    @RequestMapping(value="/taAttachment/{id}", method= RequestMethod.DELETE)
103
+    @RequestMapping(value="/admin/attachment/{id}", method= RequestMethod.DELETE)
83 104
     @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84
-    public ResponseBean taAttachmentDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
-        if(iTaAttachmentService.removeById(id)){
105
+    public ResponseBean taAttachmentDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
106
+        if(iTaAttachmentService.removeLogicById(id)){
86 107
             return ResponseBean.success("success");
87 108
         }else {
88 109
             return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
@@ -95,10 +116,21 @@ public class TaAttachmentController extends BaseController {
95 116
      * @param taAttachment 实体对象
96 117
      * @return
97 118
      */
98
-    @RequestMapping(value="/taAttachment/{id}",method= RequestMethod.PUT)
119
+    @RequestMapping(value="/admin/attachment/{id}",method= RequestMethod.PUT)
99 120
     @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100
-    public ResponseBean taAttachmentUpdate(@ApiParam("对象ID") @PathVariable Integer id,
121
+    public ResponseBean taAttachmentUpdate(@ApiParam("对象ID") @PathVariable String id,
101 122
                                         @ApiParam("更新内容") @RequestBody TaAttachment taAttachment) throws Exception{
123
+        if (StringUtils.isEmpty(taAttachment.getUrl())) {
124
+            return ResponseBean.error("请设置附件地址", ResponseBean.ERROR_ILLEGAL_PARAMS);
125
+        }
126
+        if (StringUtils.isEmpty(taAttachment.getPackId())) {
127
+            return ResponseBean.error("请设置附件包组", ResponseBean.ERROR_ILLEGAL_PARAMS);
128
+        }
129
+        if (StringUtils.isEmpty(taAttachment.getAttchType())) {
130
+            taAttachment.setAttchType("image");
131
+        }
132
+
133
+        taAttachment.setAttchId(id);
102 134
 
103 135
         if (iTaAttachmentService.updateById(taAttachment)){
104 136
             return ResponseBean.success(iTaAttachmentService.getById(id));
@@ -107,13 +139,13 @@ public class TaAttachmentController extends BaseController {
107 139
         }
108 140
     }
109 141
 
110
-    /**
111
-     * 根据id查询对象
112
-     * @param id  实体ID
113
-     */
114
-    @RequestMapping(value="/taAttachment/{id}",method= RequestMethod.GET)
115
-    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116
-    public ResponseBean taAttachmentGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
-        return ResponseBean.success(iTaAttachmentService.getById(id));
118
-    }
142
+//    /**
143
+//     * 根据id查询对象
144
+//     * @param id  实体ID
145
+//     */
146
+//    @RequestMapping(value="/taAttachment/{id}",method= RequestMethod.GET)
147
+//    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
148
+//    public ResponseBean taAttachmentGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
149
+//        return ResponseBean.success(iTaAttachmentService.getById(id));
150
+//    }
119 151
 }

+ 145
- 0
src/main/java/com/yunzhi/training/controller/TaAttchPackController.java Näytä tiedosto

@@ -0,0 +1,145 @@
1
+package com.yunzhi.training.controller;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.yunzhi.training.common.BaseController;
7
+import com.yunzhi.training.common.Constants;
8
+import com.yunzhi.training.common.ResponseBean;
9
+import com.yunzhi.training.common.StringUtils;
10
+import io.swagger.annotations.Api;
11
+import io.swagger.annotations.ApiOperation;
12
+import io.swagger.annotations.ApiParam;
13
+import org.slf4j.Logger;
14
+import org.slf4j.LoggerFactory;
15
+import org.springframework.beans.factory.annotation.Autowired;
16
+import org.springframework.web.bind.annotation.PathVariable;
17
+import org.springframework.web.bind.annotation.RequestBody;
18
+import org.springframework.web.bind.annotation.RequestMapping;
19
+import org.springframework.web.bind.annotation.RequestMethod;
20
+import org.springframework.web.bind.annotation.RequestParam;
21
+import com.yunzhi.training.service.ITaAttchPackService;
22
+import com.yunzhi.training.entity.TaAttchPack;
23
+import org.springframework.web.bind.annotation.RestController;
24
+
25
+/**
26
+ * <p>
27
+    * 附件包组 前端控制器
28
+    * </p>
29
+ *
30
+ * @author yansen
31
+ * @since 2022-02-21
32
+ */
33
+
34
+@Api(tags = "附件包组")
35
+@RestController
36
+@RequestMapping("/")
37
+public class TaAttchPackController extends BaseController {
38
+
39
+    private final Logger logger = LoggerFactory.getLogger(TaAttchPackController.class);
40
+
41
+    @Autowired
42
+    public ITaAttchPackService iTaAttchPackService;
43
+
44
+
45
+    /**
46
+     * 分页查询列表
47
+     * @param pageNum
48
+     * @param pageSize
49
+     * @return
50
+     */
51
+    @RequestMapping(value="/{client}/attchPack",method= RequestMethod.GET)
52
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
53
+    public ResponseBean taAttchPackList(@ApiParam(value = "客户端",allowableValues = "admin,wx") @PathVariable String client,
54
+                                        @ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
55
+									    @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
56
+
57
+        IPage<TaAttchPack> pg = new Page<>(pageNum, pageSize);
58
+        QueryWrapper<TaAttchPack> queryWrapper = new QueryWrapper<>();
59
+        queryWrapper.gt("state", Constants.STATUS_DELETED);
60
+        queryWrapper.eq("wx".equals(client), "state", Constants.STATUS_NORMAL);
61
+        queryWrapper.orderByDesc("create_date");
62
+
63
+        IPage<TaAttchPack> result = iTaAttchPackService.page(pg, queryWrapper);
64
+        return ResponseBean.success(result);
65
+    }
66
+
67
+    /**
68
+     * 保存对象
69
+     * @param taAttchPack 实体对象
70
+     * @return
71
+     */
72
+    @RequestMapping(value="/admin/attch-pack",method= RequestMethod.POST)
73
+    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
74
+    public ResponseBean taAttchPackAdd(@ApiParam("保存内容") @RequestBody TaAttchPack taAttchPack) throws Exception{
75
+
76
+        if (StringUtils.isEmpty(taAttchPack.getName())) {
77
+            return ResponseBean.error("请设置名称", ResponseBean.ERROR_ILLEGAL_PARAMS);
78
+        }
79
+
80
+        int cnt = iTaAttchPackService.countBy("name", taAttchPack.getName(), true);
81
+        if (cnt > 0) {
82
+            return ResponseBean.error("名称重复", ResponseBean.ERROR_ILLEGAL_PARAMS);
83
+        }
84
+
85
+        taAttchPack.setPackId(null);
86
+
87
+        if (iTaAttchPackService.save(taAttchPack)){
88
+            return ResponseBean.success(taAttchPack);
89
+        }else {
90
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
91
+        }
92
+    }
93
+
94
+    /**
95
+     * 根据id删除对象
96
+     * @param id  实体ID
97
+     */
98
+    @RequestMapping(value="/admin/attch-pack/{id}", method= RequestMethod.DELETE)
99
+    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
100
+    public ResponseBean taAttchPackDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
101
+        if(iTaAttchPackService.removeLogicById(id)){
102
+            return ResponseBean.success("success");
103
+        }else {
104
+            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
105
+        }
106
+    }
107
+
108
+    /**
109
+     * 修改对象
110
+     * @param id  实体ID
111
+     * @param taAttchPack 实体对象
112
+     * @return
113
+     */
114
+    @RequestMapping(value="/admin/attch-pack/{id}",method= RequestMethod.PUT)
115
+    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
116
+    public ResponseBean taAttchPackUpdate(@ApiParam("对象ID") @PathVariable String id,
117
+                                        @ApiParam("更新内容") @RequestBody TaAttchPack taAttchPack) throws Exception{
118
+        if (StringUtils.isEmpty(taAttchPack.getName())) {
119
+            return ResponseBean.error("请设置名称", ResponseBean.ERROR_ILLEGAL_PARAMS);
120
+        }
121
+
122
+        TaAttchPack exist = iTaAttchPackService.getByButNot("name", taAttchPack.getName(), "pack_id", id, true);
123
+        if (exist != null) {
124
+            return ResponseBean.error("名称重复", ResponseBean.ERROR_ILLEGAL_PARAMS);
125
+        }
126
+
127
+        taAttchPack.setPackId(id);
128
+
129
+        if (iTaAttchPackService.updateById(taAttchPack)){
130
+            return ResponseBean.success(iTaAttchPackService.getById(id));
131
+        }else {
132
+            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
133
+        }
134
+    }
135
+
136
+//    /**
137
+//     * 根据id查询对象
138
+//     * @param id  实体ID
139
+//     */
140
+//    @RequestMapping(value="/taAttchPack/{id}",method= RequestMethod.GET)
141
+//    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
142
+//    public ResponseBean taAttchPackGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
143
+//        return ResponseBean.success(iTaAttchPackService.getById(id));
144
+//    }
145
+}

+ 1
- 1
src/main/java/com/yunzhi/training/entity/TaAttachment.java Näytä tiedosto

@@ -27,7 +27,7 @@ public class TaAttachment implements Serializable {
27 27
     private static final long serialVersionUID = 1L;
28 28
 
29 29
     @ApiModelProperty(value = "附件ID")
30
-    @TableId(value = "attch_id", type = IdType.INPUT)
30
+    @TableId(value = "attch_id", type = IdType.UUID)
31 31
     private String attchId;
32 32
 
33 33
     @ApiModelProperty(value = "附件类型")

+ 43
- 0
src/main/java/com/yunzhi/training/entity/TaAttchPack.java Näytä tiedosto

@@ -0,0 +1,43 @@
1
+package com.yunzhi.training.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import java.time.LocalDateTime;
5
+import com.baomidou.mybatisplus.annotation.TableId;
6
+import java.io.Serializable;
7
+import io.swagger.annotations.ApiModel;
8
+import io.swagger.annotations.ApiModelProperty;
9
+import lombok.Data;
10
+import lombok.EqualsAndHashCode;
11
+import lombok.experimental.Accessors;
12
+
13
+/**
14
+ * <p>
15
+ * 附件包组
16
+ * </p>
17
+ *
18
+ * @author yansen
19
+ * @since 2022-02-21
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="TaAttchPack对象", description="附件包组")
25
+public class TaAttchPack implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "包组ID")
30
+    @TableId(value = "pack_id", type = IdType.UUID)
31
+    private String packId;
32
+
33
+    @ApiModelProperty(value = "名称")
34
+    private String name;
35
+
36
+    @ApiModelProperty(value = "状态")
37
+    private Integer state;
38
+
39
+    @ApiModelProperty(value = "创建时间")
40
+    private LocalDateTime createDate;
41
+
42
+
43
+}

+ 18
- 0
src/main/java/com/yunzhi/training/mapper/TaAttchPackMapper.java Näytä tiedosto

@@ -0,0 +1,18 @@
1
+package com.yunzhi.training.mapper;
2
+
3
+import com.yunzhi.training.entity.TaAttchPack;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+ * <p>
9
+ * 附件包组 Mapper 接口
10
+ * </p>
11
+ *
12
+ * @author yansen
13
+ * @since 2022-02-21
14
+ */
15
+@Mapper
16
+public interface TaAttchPackMapper extends BaseMapper<TaAttchPack> {
17
+
18
+}

+ 1
- 2
src/main/java/com/yunzhi/training/service/ITaAttachmentService.java Näytä tiedosto

@@ -1,7 +1,6 @@
1 1
 package com.yunzhi.training.service;
2 2
 
3 3
 import com.yunzhi.training.entity.TaAttachment;
4
-import com.baomidou.mybatisplus.extension.service.IService;
5 4
 
6 5
 /**
7 6
  * <p>
@@ -11,6 +10,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
11 10
  * @author yansen
12 11
  * @since 2022-02-21
13 12
  */
14
-public interface ITaAttachmentService extends IService<TaAttachment> {
13
+public interface ITaAttachmentService extends IBaseService<TaAttachment> {
15 14
 
16 15
 }

+ 15
- 0
src/main/java/com/yunzhi/training/service/ITaAttchPackService.java Näytä tiedosto

@@ -0,0 +1,15 @@
1
+package com.yunzhi.training.service;
2
+
3
+import com.yunzhi.training.entity.TaAttchPack;
4
+
5
+/**
6
+ * <p>
7
+ * 附件包组 服务类
8
+ * </p>
9
+ *
10
+ * @author yansen
11
+ * @since 2022-02-21
12
+ */
13
+public interface ITaAttchPackService extends IBaseService<TaAttchPack> {
14
+
15
+}

+ 1
- 2
src/main/java/com/yunzhi/training/service/impl/TaAttachmentServiceImpl.java Näytä tiedosto

@@ -3,7 +3,6 @@ package com.yunzhi.training.service.impl;
3 3
 import com.yunzhi.training.entity.TaAttachment;
4 4
 import com.yunzhi.training.mapper.TaAttachmentMapper;
5 5
 import com.yunzhi.training.service.ITaAttachmentService;
6
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 6
 import org.springframework.stereotype.Service;
8 7
 
9 8
 /**
@@ -15,6 +14,6 @@ import org.springframework.stereotype.Service;
15 14
  * @since 2022-02-21
16 15
  */
17 16
 @Service
18
-public class TaAttachmentServiceImpl extends ServiceImpl<TaAttachmentMapper, TaAttachment> implements ITaAttachmentService {
17
+public class TaAttachmentServiceImpl extends BaseServiceImpl<TaAttachmentMapper, TaAttachment> implements ITaAttachmentService {
19 18
 
20 19
 }

+ 19
- 0
src/main/java/com/yunzhi/training/service/impl/TaAttchPackServiceImpl.java Näytä tiedosto

@@ -0,0 +1,19 @@
1
+package com.yunzhi.training.service.impl;
2
+
3
+import com.yunzhi.training.entity.TaAttchPack;
4
+import com.yunzhi.training.mapper.TaAttchPackMapper;
5
+import com.yunzhi.training.service.ITaAttchPackService;
6
+import org.springframework.stereotype.Service;
7
+
8
+/**
9
+ * <p>
10
+ * 附件包组 服务实现类
11
+ * </p>
12
+ *
13
+ * @author yansen
14
+ * @since 2022-02-21
15
+ */
16
+@Service
17
+public class TaAttchPackServiceImpl extends BaseServiceImpl<TaAttchPackMapper, TaAttchPack> implements ITaAttchPackService {
18
+
19
+}

+ 5
- 0
src/main/resources/mapper/TaAttchPackMapper.xml Näytä tiedosto

@@ -0,0 +1,5 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.yunzhi.training.mapper.TaAttchPackMapper">
4
+
5
+</mapper>