广州市综治平台后端
xusd
2025-06-07 36306491396230522fa20585c2621a7fc899849a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
package cn.huge.module.file.controller.client;
 
import cn.huge.base.common.bo.R;
import cn.huge.base.common.utils.ReturnFailUtils;
import cn.huge.base.common.utils.ReturnSucUtils;
import cn.huge.module.file.domain.po.FileRelate;
import cn.huge.module.file.service.FileInfoService;
import cn.huge.module.file.service.FileRelateService;
import cn.huge.module.sys.dto.FileTypeTermsDTO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
 
/**
 * @title: 附件关系表接口api-web端
 * @description: 附件关系表接口api-web端
 * @company: hugeinfo
 * @author: liyj
 * @time: 2024-08-28 20:06:19
 * @version: 1.0.0
 */
@Slf4j
@RestController
@RequestMapping("/api/client/fileRelate")
public class FileRelateClientController {
 
    @Autowired(required = false)
    private HttpServletRequest request;
 
    @Autowired
    private FileRelateService service;
    @Autowired
    private FileInfoService fileInfoService;
 
    /**
    * 获取请求URL参数
    * @return Map<String, Object>
    */
    private Map<String, Object> getParameter(){
        Map<String, Object> terms = Maps.newHashMap();
        // 附件关系编号
        String id = request.getParameter("id");
        if (StringUtils.isNotBlank(id)){
            terms.put("id", id);
        }
        // 附件编号
        String fileId = request.getParameter("fileId");
        if (StringUtils.isNotBlank(fileId)){
            terms.put("fileId", fileId);
        }
        // 所属业务编号
        String ownerId = request.getParameter("ownerId");
        if (StringUtils.isNotBlank(ownerId)){
            terms.put("ownerId", ownerId);
        }
        // 所属业务大类
        String ownerCat = request.getParameter("ownerCat");
        if (StringUtils.isNotBlank(ownerCat)){
            terms.put("ownerCat", ownerCat);
        }
        // 所属业务类型
        String ownerType = request.getParameter("ownerType");
        if (StringUtils.isNotBlank(ownerType)){
            terms.put("ownerType", ownerType);
        }
        // 上传人编号
        String uploaderId = request.getParameter("uploaderId");
        if (StringUtils.isNotBlank(uploaderId)){
            terms.put("uploaderId", uploaderId);
        }
        // 上传人姓名
        String uploaderName = request.getParameter("uploaderName");
        if (StringUtils.isNotBlank(uploaderName)){
            terms.put("uploaderName", uploaderName);
        }
        // 上传人类型,1:工作人员,2:申请方,3:被申请方
        String uploaderType = request.getParameter("uploaderType");
        if (StringUtils.isNotBlank(uploaderType)){
            terms.put("uploaderType", uploaderType);
        }
        // 顾客编号
        String custId = request.getParameter("custId");
        if (StringUtils.isNotBlank(custId)){
            terms.put("custId", custId);
        }
        // 创建时间区间
        String createStart = request.getParameter("createStart");
        String createEnd = request.getParameter("createEnd");
        if(StringUtils.isNotBlank(createStart) && StringUtils.isNotBlank(createEnd)) {
            terms.put("createStart", createStart);
            terms.put("createEnd", createEnd);
        }
        // 更新时间区间
        String updateStart = request.getParameter("updateStart");
        String updateEnd = request.getParameter("updateEnd");
        if(StringUtils.isNotBlank(updateStart) && StringUtils.isNotBlank(updateEnd)) {
            terms.put("updateStart", updateStart);
            terms.put("updateEnd", updateEnd);
        }
        return terms;
    }
 
    /**
     * 根据条件删除附件关系
     * @url {ctx}/api/v1/fileRelate/removeFileRelate
     * @param fileTypeTermsDTO 条件
     * @return Object
     */
    @PostMapping("/removeFileRelate")
    public Object removeFileRelate(@RequestBody FileTypeTermsDTO fileTypeTermsDTO) {
        try {
            service.removeOne(fileTypeTermsDTO);
            service.removeAll(fileTypeTermsDTO);
            return ReturnSucUtils.getRepInfo();
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
     * 根据关系编号查询附件关系信息
     * @url {ctx}/api/client/fileRelate/listFileRelateByOwnerId
     * @return Object
     */
    @GetMapping("/listFileRelateByOwnerId")
    public Object listFileRelateByOwnerId(@RequestParam(value = "ownerId") String ownerId) {
        try {
            QueryWrapper<FileRelate> fileRelateQueryWrapper = new QueryWrapper<>();
            fileRelateQueryWrapper.eq("owner_id", ownerId);
            List<FileRelate> fileRelateList = service.list(fileRelateQueryWrapper);
            return ReturnSucUtils.getRepInfo(fileRelateList);
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
     * 插入多条附件关系记录
     * @url {ctx}/api/client/fileRelate/saveFileRelateList
     * @return Object
     */
    @PostMapping("/saveFileRelateList")
    public Object saveFileRelateList(@RequestBody List<FileRelate> fileRelateList) {
        try {
            if(CollectionUtils.isNotEmpty(fileRelateList)){
                service.saveBatch(fileRelateList);
            }
            return ReturnSucUtils.getRepInfo();
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    @GetMapping("/deleteFileById")
    public Object deleteFileById(@RequestParam(value = "id") String id) {
        try {
            fileInfoService.deleteFileById(id);
            return ReturnSucUtils.getRepInfo();
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    @GetMapping("/getFileRelateByFileId")
    public Object getFileRelateByFileId(@RequestParam(value = "fileIld") String fileId) {
        try {
            QueryWrapper<FileRelate> fileRelateQueryWrapper = new QueryWrapper<>();
            fileRelateQueryWrapper.eq("file_id", fileId);
            FileRelate fileRelate = service.getOne(fileRelateQueryWrapper);
            return ReturnSucUtils.getRepInfo(fileRelate);
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
}