张延森 3 年前
父节点
当前提交
b168800bfc

+ 55
- 23
src/main/java/com/yunzhi/training/controller/TaAttachmentController.java 查看文件

4
 import com.baomidou.mybatisplus.core.metadata.IPage;
4
 import com.baomidou.mybatisplus.core.metadata.IPage;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
 import com.yunzhi.training.common.BaseController;
6
 import com.yunzhi.training.common.BaseController;
7
+import com.yunzhi.training.common.Constants;
7
 import com.yunzhi.training.common.ResponseBean;
8
 import com.yunzhi.training.common.ResponseBean;
9
+import com.yunzhi.training.common.StringUtils;
8
 import io.swagger.annotations.Api;
10
 import io.swagger.annotations.Api;
9
 import io.swagger.annotations.ApiOperation;
11
 import io.swagger.annotations.ApiOperation;
10
 import io.swagger.annotations.ApiParam;
12
 import io.swagger.annotations.ApiParam;
46
      * @param pageSize
48
      * @param pageSize
47
      * @return
49
      * @return
48
      */
50
      */
49
-    @RequestMapping(value="/taAttachment",method= RequestMethod.GET)
51
+    @RequestMapping(value="/{client}/attachment",method= RequestMethod.GET)
50
     @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
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
      * @param taAttachment 实体对象
73
      * @param taAttachment 实体对象
65
      * @return
74
      * @return
66
      */
75
      */
67
-    @RequestMapping(value="/taAttachment",method= RequestMethod.POST)
76
+    @RequestMapping(value="/admin/attachment",method= RequestMethod.POST)
68
     @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
77
     @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
     public ResponseBean taAttachmentAdd(@ApiParam("保存内容") @RequestBody TaAttachment taAttachment) throws Exception{
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
         if (iTaAttachmentService.save(taAttachment)){
92
         if (iTaAttachmentService.save(taAttachment)){
72
             return ResponseBean.success(taAttachment);
93
             return ResponseBean.success(taAttachment);
73
         }else {
94
         }else {
79
      * 根据id删除对象
100
      * 根据id删除对象
80
      * @param id  实体ID
101
      * @param id  实体ID
81
      */
102
      */
82
-    @RequestMapping(value="/taAttachment/{id}", method= RequestMethod.DELETE)
103
+    @RequestMapping(value="/admin/attachment/{id}", method= RequestMethod.DELETE)
83
     @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
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
             return ResponseBean.success("success");
107
             return ResponseBean.success("success");
87
         }else {
108
         }else {
88
             return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
109
             return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
95
      * @param taAttachment 实体对象
116
      * @param taAttachment 实体对象
96
      * @return
117
      * @return
97
      */
118
      */
98
-    @RequestMapping(value="/taAttachment/{id}",method= RequestMethod.PUT)
119
+    @RequestMapping(value="/admin/attachment/{id}",method= RequestMethod.PUT)
99
     @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
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
                                         @ApiParam("更新内容") @RequestBody TaAttachment taAttachment) throws Exception{
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
         if (iTaAttachmentService.updateById(taAttachment)){
135
         if (iTaAttachmentService.updateById(taAttachment)){
104
             return ResponseBean.success(iTaAttachmentService.getById(id));
136
             return ResponseBean.success(iTaAttachmentService.getById(id));
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 查看文件

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 查看文件

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

+ 43
- 0
src/main/java/com/yunzhi/training/entity/TaAttchPack.java 查看文件

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 查看文件

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 查看文件

1
 package com.yunzhi.training.service;
1
 package com.yunzhi.training.service;
2
 
2
 
3
 import com.yunzhi.training.entity.TaAttachment;
3
 import com.yunzhi.training.entity.TaAttachment;
4
-import com.baomidou.mybatisplus.extension.service.IService;
5
 
4
 
6
 /**
5
 /**
7
  * <p>
6
  * <p>
11
  * @author yansen
10
  * @author yansen
12
  * @since 2022-02-21
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 查看文件

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 查看文件

3
 import com.yunzhi.training.entity.TaAttachment;
3
 import com.yunzhi.training.entity.TaAttachment;
4
 import com.yunzhi.training.mapper.TaAttachmentMapper;
4
 import com.yunzhi.training.mapper.TaAttachmentMapper;
5
 import com.yunzhi.training.service.ITaAttachmentService;
5
 import com.yunzhi.training.service.ITaAttachmentService;
6
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
 import org.springframework.stereotype.Service;
6
 import org.springframework.stereotype.Service;
8
 
7
 
9
 /**
8
 /**
15
  * @since 2022-02-21
14
  * @since 2022-02-21
16
  */
15
  */
17
 @Service
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 查看文件

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 查看文件

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>