Sfoglia il codice sorgente

Merge branch 'wq1' of SH-Arbitrate/Mediation-Backend into dev

wangqiong123 2 anni fa
parent
commit
527a1d8a64

+ 48
- 6
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java Vedi File

@@ -4,14 +4,16 @@ import java.util.ArrayList;
4 4
 import java.util.List;
5 5
 import javax.servlet.http.HttpServletRequest;
6 6
 import javax.servlet.http.HttpServletResponse;
7
+
8
+import com.ruoyi.common.utils.SecurityUtils;
9
+import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
10
+import com.ruoyi.wisdomarbitrate.domain.CaseAttach;
11
+import com.ruoyi.wisdomarbitrate.mapper.CaseAttachMapper;
7 12
 import org.slf4j.Logger;
8 13
 import org.slf4j.LoggerFactory;
9 14
 import org.springframework.beans.factory.annotation.Autowired;
10 15
 import org.springframework.http.MediaType;
11
-import org.springframework.web.bind.annotation.GetMapping;
12
-import org.springframework.web.bind.annotation.PostMapping;
13
-import org.springframework.web.bind.annotation.RequestMapping;
14
-import org.springframework.web.bind.annotation.RestController;
16
+import org.springframework.web.bind.annotation.*;
15 17
 import org.springframework.web.multipart.MultipartFile;
16 18
 import com.ruoyi.common.config.RuoYiConfig;
17 19
 import com.ruoyi.common.constant.Constants;
@@ -34,6 +36,8 @@ public class CommonController
34 36
 
35 37
     @Autowired
36 38
     private ServerConfig serverConfig;
39
+    @Autowired
40
+    private CaseAttachMapper caseAttachMapper;
37 41
 
38 42
     private static final String FILE_DELIMETER = ",";
39 43
 
@@ -73,7 +77,7 @@ public class CommonController
73 77
      * 通用上传请求(单个)
74 78
      */
75 79
     @PostMapping("/upload")
76
-    public AjaxResult uploadFile(MultipartFile file) throws Exception
80
+    public AjaxResult uploadFile(@RequestParam("file") MultipartFile file, @RequestParam("annexType") Integer annexType, @RequestParam("id") Long id) throws Exception
77 81
     {
78 82
         try
79 83
         {
@@ -82,6 +86,7 @@ public class CommonController
82 86
             // 上传并返回新文件名称
83 87
             String fileName = FileUploadUtils.upload(filePath, file);
84 88
             String url = serverConfig.getUrl() + fileName;
89
+            saveCaseAttach(id, annexType, fileName,file.getOriginalFilename());
85 90
             AjaxResult ajax = AjaxResult.success();
86 91
             ajax.put("url", url);
87 92
             ajax.put("fileName", fileName);
@@ -95,11 +100,47 @@ public class CommonController
95 100
         }
96 101
     }
97 102
 
103
+    /**
104
+     * 保存到案件附件表
105
+     * @param id
106
+     * @param annexType
107
+     * @param fileName
108
+     * @param originalFilename
109
+     */
110
+    private void saveCaseAttach(Long id, Integer annexType, String fileName, String originalFilename) {
111
+        CaseAttach caseAttach = CaseAttach.builder().caseAppliId(id)
112
+                .annexName(originalFilename)
113
+                .annexPath(fileName)
114
+                .annexType(annexType)
115
+                .userId(SecurityUtils.getUserId())
116
+                .userName(SecurityUtils.getUsername())
117
+                .build();
118
+        caseAttachMapper.save(caseAttach);
119
+    }
120
+    /**
121
+     * 根据案件id获取附件
122
+     * @param caseAppliId
123
+     * @param annexTypeList
124
+     * @param
125
+     * @return
126
+     */
127
+    @GetMapping("/fileList")
128
+    public AjaxResult fileList(@RequestParam("caseAppliId")Long caseAppliId, @RequestParam(value = "annexTypeList",required = false) List<Integer> annexTypeList){
129
+        if(caseAppliId==null){
130
+            return AjaxResult.error("案件id不能为空");
131
+        }
132
+        CaseApplication caseApplication = new CaseApplication();
133
+        caseApplication.setId(caseAppliId);
134
+        caseApplication.setAnnexTypeList(annexTypeList);
135
+        List<CaseAttach> caseAttachList = caseAttachMapper.queryCaseAttachList(caseApplication);
136
+        return AjaxResult.success(caseAttachList);
137
+    }
138
+
98 139
     /**
99 140
      * 通用上传请求(多个)
100 141
      */
101 142
     @PostMapping("/uploads")
102
-    public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception
143
+    public AjaxResult uploadFiles(@RequestParam("files") MultipartFile[] files, @RequestParam("annexType")Integer annexType, @RequestParam("id")Long id ) throws Exception
103 144
     {
104 145
         try
105 146
         {
@@ -118,6 +159,7 @@ public class CommonController
118 159
                 fileNames.add(fileName);
119 160
                 newFileNames.add(FileUtils.getName(fileName));
120 161
                 originalFilenames.add(file.getOriginalFilename());
162
+                saveCaseAttach(id, annexType, fileName,file.getOriginalFilename());
121 163
             }
122 164
             AjaxResult ajax = AjaxResult.success();
123 165
             ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER));

+ 0
- 59
ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/TemplateController.java Vedi File

@@ -1,59 +0,0 @@
1
-package com.ruoyi.web.controller.wisdomarbitrate;
2
-
3
-import com.ruoyi.common.core.controller.BaseController;
4
-import com.ruoyi.common.core.domain.AjaxResult;
5
-import com.ruoyi.common.core.page.TableDataInfo;
6
-import com.ruoyi.wisdomarbitrate.domain.DeptIdentify;
7
-import com.ruoyi.wisdomarbitrate.domain.TemplateManual;
8
-import com.ruoyi.wisdomarbitrate.service.ITemplateService;
9
-import org.springframework.beans.factory.annotation.Autowired;
10
-import org.springframework.web.bind.annotation.*;
11
-
12
-import java.util.List;
13
-
14
-@RestController
15
-@RequestMapping("/template")
16
-public class TemplateController extends BaseController {
17
-    @Autowired
18
-    private ITemplateService templateService;
19
-    /**
20
-     * 新增模板
21
-     * @param templateManual
22
-     * @return
23
-     */
24
-    @PostMapping("/insert")
25
-    public AjaxResult insertTemplate(@RequestBody TemplateManual templateManual){
26
-        return templateService.insertTemplate(templateManual);
27
-    }
28
-
29
-    /**
30
-     * 删除模板
31
-     * @param id
32
-     * @return
33
-     */
34
-    @DeleteMapping("/delete")
35
-    public AjaxResult deleteTemplate(Long id){
36
-        return templateService.deleteTemplate(id);
37
-    }
38
-
39
-    /**
40
-     * 修改模板
41
-     * @param templateManual
42
-     * @return
43
-     */
44
-    @PutMapping("/update")
45
-    public AjaxResult updateTemplate(@RequestBody TemplateManual templateManual){
46
-        return templateService.updateTemplate(templateManual);
47
-    }
48
-
49
-    /**
50
-     * 查询模板
51
-     */
52
-    @GetMapping("/list")
53
-    public TableDataInfo list( TemplateManual templateManual) {
54
-        startPage();
55
-        List<TemplateManual> list = templateService.selectTemplate(templateManual);
56
-        return getDataTable(list);
57
-    }
58
-
59
-}

+ 25
- 0
ruoyi-common/src/main/java/com/ruoyi/common/annotation/DictConvert.java Vedi File

@@ -0,0 +1,25 @@
1
+package com.ruoyi.common.annotation;
2
+
3
+import java.lang.annotation.*;
4
+/**
5
+ * 查询时字典转换注解 支持的返回类型:PageRes,List,VO类
6
+ * @Author wangqiong
7
+ * @Date 2023/01/5
8
+ * @Version V1.0
9
+ */
10
+// 标注这个类它可以标注的位置
11
+@Target({ElementType.FIELD, ElementType.ANNOTATION_TYPE})
12
+// 标注这个注解的注解保留时期
13
+@Retention(RetentionPolicy.RUNTIME)
14
+// 是否生成注解文档
15
+@Documented
16
+public @interface DictConvert {
17
+    //转换字典的目标字段,不填时默认为注解的字段本身
18
+    String targetField() default "";
19
+    //是否多选
20
+    boolean isMultiple() default false;
21
+    //分隔符 默认为逗号
22
+    String  separator() default ",";
23
+    // 字典类型
24
+    String dictType() default "";
25
+}

+ 24
- 0
ruoyi-common/src/main/java/com/ruoyi/common/annotation/EnumsConvert.java Vedi File

@@ -0,0 +1,24 @@
1
+package com.ruoyi.common.annotation;
2
+
3
+
4
+import com.ruoyi.common.interfaces.EnumsInterface;
5
+
6
+import java.lang.annotation.*;
7
+/**
8
+ * 枚举转义
9
+ * @Author wangqiong
10
+ * @Date 2023/01/5
11
+ * @Version V1.0
12
+ */
13
+// 标注这个类它可以标注的位置
14
+@Target({ElementType.FIELD, ElementType.ANNOTATION_TYPE})
15
+// 标注这个注解的注解保留时期
16
+@Retention(RetentionPolicy.RUNTIME)
17
+// 是否生成注解文档
18
+@Documented
19
+public @interface EnumsConvert {
20
+    Class<? extends EnumsInterface> getEnumsInterface();
21
+
22
+    //转换字典的目标字段,不填时默认为注解的字段本身
23
+    String targetField() default "";
24
+}

+ 12
- 0
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java Vedi File

@@ -3,6 +3,8 @@ package com.ruoyi.common.core.domain.entity;
3 3
 import java.util.Date;
4 4
 import java.util.List;
5 5
 import javax.validation.constraints.*;
6
+
7
+import com.ruoyi.common.annotation.DictConvert;
6 8
 import org.apache.commons.lang3.builder.ToStringBuilder;
7 9
 import org.apache.commons.lang3.builder.ToStringStyle;
8 10
 import com.ruoyi.common.annotation.Excel;
@@ -64,7 +66,9 @@ public class SysUser extends BaseEntity
64 66
 
65 67
     /** 用户性别 */
66 68
     @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
69
+    @DictConvert(targetField = "sexName",dictType = "sys_user_sex")
67 70
     private String sex;
71
+    private String sexName;
68 72
 
69 73
     /** 用户头像 */
70 74
     private String avatar;
@@ -141,6 +145,14 @@ public class SysUser extends BaseEntity
141 145
         return deptId;
142 146
     }
143 147
 
148
+    public String getSexName() {
149
+        return sexName;
150
+    }
151
+
152
+    public void setSexName(String sexName) {
153
+        this.sexName = sexName;
154
+    }
155
+
144 156
     public void setDeptId(Long deptId)
145 157
     {
146 158
         this.deptId = deptId;

+ 31
- 1
ruoyi-common/src/main/java/com/ruoyi/common/enums/YesOrNoEnum.java Vedi File

@@ -1,11 +1,13 @@
1 1
 package com.ruoyi.common.enums;
2 2
 
3
+import com.ruoyi.common.interfaces.EnumsInterface;
4
+
3 5
 /**
4 6
  * @author wangqiong
5 7
  * @description 是否枚举
6 8
  * @date 2023-11-17 14:05
7 9
  */
8
-public enum YesOrNoEnum
10
+public enum YesOrNoEnum implements EnumsInterface
9 11
 {
10 12
     NO(0, "否"),
11 13
     YES(1, "是"),
@@ -30,4 +32,32 @@ public enum YesOrNoEnum
30 32
     {
31 33
         return text;
32 34
     }
35
+
36
+    /**
37
+     * 根据code获取text
38
+     * @param codeNo
39
+     * @return
40
+     */
41
+    public static String getTextByCode(Integer codeNo){
42
+        for (YesOrNoEnum value : YesOrNoEnum.values()) {
43
+            if (value.getCode().equals(codeNo)){
44
+                return value.getText();
45
+            }
46
+        }
47
+        return codeNo.toString();
48
+    }
49
+
50
+    /**
51
+     * 根据text获取code
52
+     * @param textStr
53
+     * @return
54
+     */
55
+    public static String getCodeByText(String textStr){
56
+        for (YesOrNoEnum value : YesOrNoEnum.values()) {
57
+            if (value.getText().equals(textStr)){
58
+                return value.getText();
59
+            }
60
+        }
61
+        return textStr;
62
+    }
33 63
 }

+ 236
- 0
ruoyi-common/src/main/java/com/ruoyi/common/handler/ResponseBodyAdviceHandler.java Vedi File

@@ -0,0 +1,236 @@
1
+package com.ruoyi.common.handler;
2
+
3
+import cn.hutool.core.util.ObjectUtil;
4
+import cn.hutool.core.util.StrUtil;
5
+import com.fasterxml.jackson.core.JsonProcessingException;
6
+import com.fasterxml.jackson.databind.ObjectMapper;
7
+import com.ruoyi.common.annotation.DictConvert;
8
+import com.ruoyi.common.annotation.EnumsConvert;
9
+import com.ruoyi.common.core.domain.AjaxResult;
10
+import com.ruoyi.common.core.page.TableDataInfo;
11
+import com.ruoyi.common.interfaces.EnumsInterface;
12
+import com.ruoyi.common.utils.DictUtils;
13
+import lombok.extern.slf4j.Slf4j;
14
+import org.springframework.core.MethodParameter;
15
+import org.springframework.http.MediaType;
16
+import org.springframework.http.server.ServerHttpRequest;
17
+import org.springframework.http.server.ServerHttpResponse;
18
+import org.springframework.web.bind.annotation.RestControllerAdvice;
19
+import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
20
+import java.lang.reflect.Field;
21
+import java.util.ArrayList;
22
+import java.util.List;
23
+
24
+
25
+/**
26
+ * 响应数据统一处理
27
+ *
28
+ * @Author wangqiong
29
+ * @Date 2023/1/5
30
+ * @Version V1.0
31
+ */
32
+@Slf4j
33
+@RestControllerAdvice
34
+public class ResponseBodyAdviceHandler implements ResponseBodyAdvice {
35
+    @Override
36
+    public boolean supports(MethodParameter methodParameter, Class aClass) {
37
+        return true;
38
+    }
39
+
40
+    @Override
41
+    public Object beforeBodyWrite(Object body, MethodParameter methodParameter, MediaType mediaType, Class aClass, ServerHttpRequest request, ServerHttpResponse serverHttpResponse) {
42
+         if (body instanceof String) {
43
+            ObjectMapper om = new ObjectMapper();
44
+            try {
45
+                return om.writeValueAsString(AjaxResult.success(body));
46
+            } catch (JsonProcessingException e) {
47
+                log.error("JsonProcessingException e:{}", e);
48
+            }
49
+        }
50
+        //判断类型,然后转换字典
51
+        turnType(body);
52
+        AjaxResult result = AjaxResult.success(body);
53
+        return result;
54
+    }
55
+
56
+    /**
57
+     * 判断类型,然后转换字典
58
+     *
59
+     * @param body
60
+     */
61
+    private void turnType(Object body) {
62
+        if (body instanceof AjaxResult) {
63
+            AjaxResult result = (AjaxResult) body;
64
+            if(result.isSuccess()){
65
+                Object data = result.get("data");
66
+                if(data!=null){
67
+                    if(data instanceof List){
68
+                        List list = (List) data;
69
+                        convertList(list);
70
+                    }else if(data instanceof TableDataInfo){
71
+                        TableDataInfo pageRes = (TableDataInfo) data;
72
+                        List list = pageRes.getRows();
73
+                        convertList(list);
74
+                    }else{
75
+                        loopTurn(data);
76
+                    }
77
+                }
78
+            }
79
+        } else if (body instanceof TableDataInfo) {
80
+            TableDataInfo pageRes = (TableDataInfo) body;
81
+            List list = pageRes.getRows();
82
+            convertList(list);
83
+        } else if (body instanceof List) {
84
+            List list = (List) body;
85
+            convertList(list);
86
+        } else {
87
+            loopTurn(body);
88
+        }
89
+    }
90
+
91
+    /**
92
+     * 递归转换列表数据,将列表套列表数据都进行转换
93
+     *
94
+     * @param list 列表数据
95
+     */
96
+    private void convertList(List list) {
97
+        if (list != null && list.size() > 0) {
98
+            for (Object o : list) {
99
+                if (o instanceof List) {
100
+                    convertList((List) o);
101
+                } else {
102
+                    loopTurn(o);
103
+                }
104
+            }
105
+        }
106
+    }
107
+
108
+    /**
109
+     * 递归转换枚举、字典
110
+     *
111
+     * @param obj 属性
112
+     */
113
+    private void loopTurn(Object obj) {
114
+        if (obj != null) {
115
+            Class clazz = obj.getClass();
116
+            //获取类的所有字段
117
+            for (Field field : clazz.getDeclaredFields()) {
118
+                Object value = null;
119
+                try {
120
+                    field.setAccessible(true);
121
+                    //获取属性值
122
+                    value = field.get(obj);
123
+                } catch (IllegalAccessException e) {
124
+                    log.error("turnDict getField Value error!", e);
125
+                }
126
+                //List属性递归每个子集
127
+                if (value != null && value instanceof List) {
128
+                    for (Object child : (List) value) {
129
+                        loopTurn(child);
130
+                    }
131
+                    //非List进行显示转换
132
+                } else {
133
+                    turnEnum(obj, clazz, field, value);
134
+                    turnDict(obj, clazz, field, value);
135
+
136
+                }
137
+            }
138
+        }
139
+    }
140
+
141
+    /**
142
+     * 转换枚举类型
143
+     *
144
+     * @param obj 属性判断
145
+     */
146
+    private void turnEnum(Object obj, Class clazz, Field field, Object value) {
147
+        EnumsConvert enumsConvert = field.getAnnotation(EnumsConvert.class);
148
+        //判断是否有枚举转换的注解
149
+        if (enumsConvert != null) {
150
+            if (value != null && StrUtil.isNotEmpty(value.toString())) {
151
+                String key = value.toString();
152
+                String target = enumsConvert.targetField();
153
+
154
+                Field targetField = getTargetField(clazz, field, target);
155
+
156
+                try {
157
+                    if (targetField != null) {
158
+                        targetField.setAccessible(true);
159
+                        //给目标字段设置转换后的值
160
+                        targetField.set(obj, EnumsInterface.getText(enumsConvert.getEnumsInterface(), key));
161
+                    }
162
+                } catch (IllegalAccessException e) {
163
+                    log.error("turnEnum set value error!", e);
164
+                }
165
+            }
166
+        }
167
+    }
168
+
169
+    /**
170
+     * 字典转换
171
+     *
172
+     * @param obj 转换对象
173
+     */
174
+    private void turnDict(Object obj, Class clazz, Field field, Object value) {
175
+        DictConvert dictConvert = field.getAnnotation(DictConvert.class);
176
+        //判断是否有字典转换的注解
177
+        if (dictConvert != null) {
178
+            if (value != null && StrUtil.isNotEmpty(value.toString())) {
179
+                String key = value.toString();
180
+                String target = dictConvert.targetField();
181
+
182
+                Field targetField = getTargetField(clazz, field, target);
183
+
184
+                try {
185
+                    if (targetField != null) {
186
+                        targetField.setAccessible(true);
187
+                        String dictType = dictConvert.dictType();
188
+                        if(StrUtil.isEmpty(dictType)){
189
+                            return;
190
+                        }
191
+                        //单个字典时直接设置值
192
+                        if (!dictConvert.isMultiple()) {
193
+
194
+                            targetField.set(obj, ObjectUtil.isNotEmpty( DictUtils.getDictLabel(dictType,key)) ?  DictUtils.getDictLabel(dictType,key):null);
195
+                        } else {
196
+                            //多个字典时,用逗号拼接值
197
+                            List<String> textList = new ArrayList<>();
198
+                            String[] ids = key.split(dictConvert.separator());
199
+                            for (String id : ids) {
200
+                                if (ObjectUtil.isNotEmpty(DictUtils.getDictLabel(dictType,id))&&StrUtil.isNotEmpty(DictUtils.getDictLabel(dictType,id))) {
201
+                                    textList.add(DictUtils.getDictLabel(dictType,id));
202
+                                }
203
+                            }
204
+                            targetField.set(obj, StrUtil.join(dictConvert.separator(), textList));
205
+                        }
206
+                    }
207
+                } catch (IllegalAccessException e) {
208
+                    log.error("turnDict set value error!", e);
209
+                }
210
+            }
211
+        }
212
+    }
213
+    /**
214
+     * 获取目标属性
215
+     *
216
+     * @param clazz  取值对象
217
+     * @param field  属性
218
+     * @param target 属性名
219
+     * @return Field 目标属性
220
+     */
221
+    private Field getTargetField(Class clazz, Field field, String target) {
222
+        Field targetField = null;
223
+        //转换的目标字段为当前字段
224
+        if (StrUtil.isEmpty(target)) {
225
+            targetField = field;
226
+        } else {
227
+            try {
228
+                //目标字段为设置的字段
229
+                targetField = clazz.getDeclaredField(target);
230
+            } catch (NoSuchFieldException e) {
231
+                log.error("getTargetField getDeclaredField error!", e);
232
+            }
233
+        }
234
+        return targetField;
235
+    }
236
+}

+ 38
- 0
ruoyi-common/src/main/java/com/ruoyi/common/interfaces/EnumsInterface.java Vedi File

@@ -0,0 +1,38 @@
1
+package com.ruoyi.common.interfaces;
2
+
3
+import java.lang.reflect.Method;
4
+
5
+/**
6
+ * 枚举接口,反射出枚举code对应的文本 或 文本对应的code
7
+ *
8
+ * @Author wangqiong
9
+ * @Date 2023/01/5
10
+ * @Version V1.0
11
+ */
12
+public interface EnumsInterface {
13
+    static <T extends EnumsInterface>String getText(Class<T> clazz, String code){
14
+        try {
15
+            Method method = clazz.getMethod("getTextByCode", String.class);
16
+            if(method!=null){
17
+                return (String)method.invoke(null,code);
18
+            }
19
+        }catch (Exception e){
20
+            System.err.println("getTextByCode方法不存在");
21
+            e.printStackTrace();
22
+        }
23
+        return code;
24
+    }
25
+
26
+    static <T extends EnumsInterface>String getCode(Class<T> clazz,String text){
27
+        try {
28
+            Method method = clazz.getMethod("getCodeByText", String.class);
29
+            if(method!=null){
30
+                return (String)method.invoke(null,text);
31
+            }
32
+        }catch (Exception e){
33
+            System.err.println("getCodeByText方法不存在");
34
+            e.printStackTrace();
35
+        }
36
+        return text;
37
+    }
38
+}

+ 0
- 16
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ITemplateService.java Vedi File

@@ -1,16 +0,0 @@
1
-package com.ruoyi.wisdomarbitrate.service;
2
-
3
-import com.ruoyi.common.core.domain.AjaxResult;
4
-import com.ruoyi.wisdomarbitrate.domain.TemplateManual;
5
-
6
-import java.util.List;
7
-
8
-public interface ITemplateService {
9
-    AjaxResult insertTemplate(TemplateManual templateManual);
10
-
11
-    AjaxResult deleteTemplate(Long id);
12
-
13
-    AjaxResult updateTemplate(TemplateManual templateManual);
14
-
15
-    List<TemplateManual> selectTemplate(TemplateManual templateManual);
16
-}

+ 0
- 54
ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/TemplateServiceImpl.java Vedi File

@@ -1,54 +0,0 @@
1
-package com.ruoyi.wisdomarbitrate.service.impl;
2
-
3
-import com.ruoyi.common.core.domain.AjaxResult;
4
-import com.ruoyi.wisdomarbitrate.domain.DeptIdentify;
5
-import com.ruoyi.wisdomarbitrate.domain.TemplateManual;
6
-import com.ruoyi.wisdomarbitrate.mapper.TemplateManualMapper;
7
-import com.ruoyi.wisdomarbitrate.service.ITemplateService;
8
-import org.springframework.beans.factory.annotation.Autowired;
9
-import org.springframework.stereotype.Service;
10
-import org.springframework.transaction.annotation.Transactional;
11
-
12
-import java.util.List;
13
-@Service
14
-public class TemplateServiceImpl implements ITemplateService {
15
-    @Autowired
16
-    private TemplateManualMapper templateManualMapper;
17
-    @Override
18
-    @Transactional
19
-    public AjaxResult insertTemplate(TemplateManual templateManual) {
20
-       int i = templateManualMapper.insertTemplateManual(templateManual);
21
-       if (i>0){
22
-           return AjaxResult.success("新增成功");
23
-       }
24
-        return AjaxResult.error("新增失败");
25
-    }
26
-
27
-    @Override
28
-    @Transactional
29
-    public AjaxResult deleteTemplate(Long id) {
30
-        TemplateManual templateManual = new TemplateManual();
31
-        templateManual.setId(id);
32
-        templateManual.setDelFlag(2);
33
-        int i = templateManualMapper.updateTemplateManual(templateManual);
34
-        if (i > 0) {
35
-            return AjaxResult.success("删除成功");
36
-        }
37
-        return AjaxResult.error();
38
-    }
39
-
40
-    @Override
41
-    @Transactional
42
-    public AjaxResult updateTemplate(TemplateManual templateManual) {
43
-        int i = templateManualMapper.updateTemplateManual(templateManual);
44
-        if (i > 0) {
45
-            return AjaxResult.success("修改成功");
46
-        }
47
-        return AjaxResult.error();
48
-    }
49
-
50
-    @Override
51
-    public List<TemplateManual> selectTemplate(TemplateManual templateManual) {
52
-        return templateManualMapper.selectTemplateManual(templateManual);
53
-    }
54
-}