广州市综治平台后端
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
package cn.huge.module.knowledge.controller.web;
 
import cn.huge.base.common.utils.ReturnFailUtils;
import cn.huge.base.common.utils.ReturnSucUtils;
import cn.huge.module.knowledge.domain.dto.LawInfoPageDTO;
import cn.huge.module.knowledge.domain.po.LawInfo;
import cn.huge.module.knowledge.service.LawInfoService;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
 
/**
 * @title: 法律表接口api-web端
 * @description: 法律表接口api-web端
 * @company: hugeinfo
 * @author: huangh
 * @time: 2024-12-05 16:15:00
 * @version: 1.0
 */
@Slf4j
@RestController
@RequestMapping("/api/web/lawInfo")
public class LawInfoWebController {
 
    @Autowired(required = false)
    private HttpServletRequest request;
 
    @Autowired
    private LawInfoService service;
 
    /**
     * 获取请求URL参数
     * @return Map<String, Object>
     */
    private Map<String, Object> getParameter() {
        Map<String, Object> terms = Maps.newHashMap();
        // 法律原始文本编号
        String lawOriginalInfoId = request.getParameter("lawOriginalInfoId");
        if (StringUtils.isNotBlank(lawOriginalInfoId)) {
            terms.put("lawOriginalInfoId", lawOriginalInfoId);
        }
        // 法律标题
        String title = request.getParameter("title");
        if (StringUtils.isNotBlank(title)) {
            terms.put("title", title);
        }
        // 法律制定机关代号
        String authority = request.getParameter("authority");
        if (StringUtils.isNotBlank(authority)) {
            terms.put("authority", authority);
        }
        // 法律制定机关
        String authorityName = request.getParameter("authorityName");
        if (StringUtils.isNotBlank(authorityName)) {
            terms.put("authorityName", authorityName);
        }
        // 法律性质代号
        String lawNature = request.getParameter("lawNature");
        if (StringUtils.isNotBlank(lawNature)) {
            terms.put("lawNature", lawNature);
        }
        // 法律性质
        String lawNatureName = request.getParameter("lawNatureName");
        if (StringUtils.isNotBlank(lawNatureName)) {
            terms.put("lawNatureName", lawNatureName);
        }
        // 法律时效性代号
        String validity = request.getParameter("validity");
        if (StringUtils.isNotBlank(validity)) {
            terms.put("validity", validity);
        }
        // 法律时效性
        String validityName = request.getParameter("validityName");
        if (StringUtils.isNotBlank(validityName)) {
            terms.put("validityName", validityName);
        }
        // 法律公布时间区间
        String publishStart = request.getParameter("publishStart");
        String publishEnd = request.getParameter("publishEnd");
        if (StringUtils.isNotBlank(publishStart) && StringUtils.isNotBlank(publishEnd)) {
            terms.put("publishStart", publishStart);
            terms.put("publishEnd", publishEnd);
        }
        // 法律施行时间区间
        String implementationStart = request.getParameter("implementationStart");
        String implementationEnd = request.getParameter("implementationEnd");
        if (StringUtils.isNotBlank(implementationStart) && StringUtils.isNotBlank(implementationEnd)) {
            terms.put("implementationStart", implementationStart);
            terms.put("implementationEnd", implementationEnd);
        }
        // 创建时间区间
        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);
        }
        // 关键词搜索
        String keyword = request.getParameter("keyword");
        if (StringUtils.isNotBlank(keyword)) {
            terms.put("keyword", keyword);
        }
        return terms;
    }
 
    /**
     * 条件查询多个
     * @url {ctx}/api/web/lawInfo/listQuery
     * @return Object
     */
    @GetMapping("/listQuery")
    public Object listQuery() {
        try {
            Map<String, Object> terms = getParameter();
            return ReturnSucUtils.getRepInfo(service.listTerms(terms));
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
     * 条件分页查询
     * @url {ctx}/api/web/lawInfo/pageQuery
     * @param page 页码
     * @param size 每页数量
     * @return Object
     */
    @GetMapping("/pageQuery")
    public Object pageQuery(@RequestParam(value = "page") int page, @RequestParam(value = "size") int size) {
        try {
            Map<String, Object> terms = getParameter();
            Sort sort = Sort.by(Sort.Direction.DESC, "publish_time","law_info_id");
            PageRequest pageRequest = PageRequest.of(page - 1, size, sort);
            log.debug("[LawInfoWebController.pageQuery]调用,参数:{}", terms);
            Page<LawInfoPageDTO> lawInfoPage = service.pageQuery(pageRequest, terms);
            return ReturnSucUtils.getRepInfo("处理成功", lawInfoPage);
        } catch (Exception e) {
            log.error("[LawInfoWebController.pageQuery]调用失败,异常信息:" + e, e);
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
     * 统计各类别
     * @url {ctx}/api/web/lawInfo/categoryCount
     * @return Object
     */
    @GetMapping("/categoryCount")
    public Object categoryCount() {
        try {
            Map<String, Object> terms = getParameter();
            // List<LawCategoryDTO> lawCategoryDTOList = service.categoryCount(terms);
            return ReturnSucUtils.getRepInfo("处理成功", service.categoryCount(terms));
        } catch (Exception e) {
            log.error("[LawInfoWebController.pageQuery]调用失败,异常信息:" + e, e);
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
     * 根据编号查询单个
     * @url {ctx}/api/web/lawInfo/getById
     * @param id 主键编号
     * @return Object
     */
    @GetMapping("/getById")
    public Object getById(@RequestParam(value = "id") String id) {
        try {
            return ReturnSucUtils.getRepInfo(service.getById(id));
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
     * 根据主键单个
     * @url {ctx}/api/web/lawInfo/deleteById
     * @param id 主键编号
     * @return Object
     */
    @GetMapping("/deleteById")
    public Object deleteById(@RequestParam(value = "id") String id) {
        try {
            service.removeById(id);
            return ReturnSucUtils.getRepInfo();
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
    /**
     * 新增或更新对象
     * @url {ctx}/api/web/lawInfo/saveLawInfo
     * @param lawInfo 实体对象
     * @return Object
     */
    @PostMapping("/saveLawInfo")
    public Object saveLawInfo(@RequestBody LawInfo lawInfo) {
        try {
            service.saveLawInfo(lawInfo);
            return ReturnSucUtils.getRepInfo();
        } catch (Exception e) {
            return ReturnFailUtils.getRepInfo();
        }
    }
 
}