提交 | 用户 | age
|
56608e
|
1 |
package com.hx.other.service.controller.admin; |
G |
2 |
|
|
3 |
import com.github.pagehelper.PageHelper; |
|
4 |
import com.github.pagehelper.PageInfo; |
|
5 |
import com.hx.common.BaseController; |
|
6 |
import com.hx.mybatisTool.SqlSentence; |
|
7 |
import com.hx.other.service.model.BaseEntity; |
|
8 |
import com.hx.other.service.model.SqlQueryTemp; |
|
9 |
import com.hx.other.service.service.SqlQueryTempService; |
|
10 |
import com.hx.other.service.vo.BaseVo; |
|
11 |
import com.hx.other.service.vo.ai.QueryRecordVo; |
|
12 |
import com.hx.resultTool.Result; |
|
13 |
import com.hx.util.StringUtils; |
|
14 |
import lombok.extern.slf4j.Slf4j; |
|
15 |
import org.springframework.web.bind.annotation.PostMapping; |
|
16 |
import org.springframework.web.bind.annotation.RequestBody; |
|
17 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
18 |
import org.springframework.web.bind.annotation.RestController; |
|
19 |
|
|
20 |
import javax.annotation.Resource; |
|
21 |
import java.util.HashMap; |
|
22 |
import java.util.List; |
|
23 |
import java.util.Map; |
|
24 |
|
|
25 |
/** |
|
26 |
* @Author: cmg |
|
27 |
* @Date: 2023/5/5 14:37 |
|
28 |
*/ |
|
29 |
@Slf4j |
|
30 |
@RestController |
|
31 |
@RequestMapping("/ai/query/temp") |
|
32 |
public class AdminQueryTempController extends BaseController { |
|
33 |
|
|
34 |
@Resource |
|
35 |
private SqlQueryTempService sqlQueryTempService; |
|
36 |
|
|
37 |
@PostMapping("/list") |
|
38 |
public Result list(@RequestBody(required = false) QueryRecordVo baseVo) |
|
39 |
{ |
|
40 |
if(baseVo == null) |
|
41 |
{ |
|
42 |
baseVo = new QueryRecordVo(); |
|
43 |
} |
|
44 |
|
|
45 |
if(baseVo.getPageNum() == null || baseVo.getPageNum() <= 0) |
|
46 |
{ |
|
47 |
baseVo.setPageNum(1); |
|
48 |
} |
|
49 |
|
720120
|
50 |
if(baseVo.getPageSize() == null || baseVo.getPageSize() <= 0 || baseVo.getPageSize() > 100) |
56608e
|
51 |
{ |
G |
52 |
baseVo.setPageSize(20); |
|
53 |
} |
|
54 |
|
|
55 |
SqlSentence sqlSentence = new SqlSentence(); |
|
56 |
Map<String, Object> map = new HashMap<>(); |
|
57 |
sqlSentence.setM(map); |
|
58 |
map.put("isDel", BaseEntity.NO); |
|
59 |
|
|
60 |
StringBuilder stringBuilder = new StringBuilder(); |
|
61 |
stringBuilder.append("select * from sql_query_temp where isDel = #{m.isDel}"); |
|
62 |
|
|
63 |
if(!StringUtils.isEmpty(baseVo.getKeyWord())) |
|
64 |
{ |
|
65 |
stringBuilder.append(" and content like #{m.content} "); |
|
66 |
map.put("content", "%" + baseVo.getKeyWord() + "%"); |
|
67 |
} |
|
68 |
|
|
69 |
PageHelper.startPage(baseVo.getPageNum(), baseVo.getPageSize(), " createTime desc "); |
|
70 |
sqlSentence.setSqlSentence(stringBuilder.toString()); |
|
71 |
List<SqlQueryTemp> list = sqlQueryTempService.selectList(sqlSentence); |
|
72 |
PageInfo<SqlQueryTemp> pageInfo = new PageInfo<>(list); |
|
73 |
|
|
74 |
return Result.success(pageInfo); |
|
75 |
} |
|
76 |
|
|
77 |
@PostMapping("/delete") |
|
78 |
public Result delete(@RequestBody(required = false) BaseVo baseVo) |
|
79 |
{ |
|
80 |
if(baseVo == null || StringUtils.isEmpty(baseVo.getId())) |
|
81 |
{ |
|
82 |
throwParamException("请选择记录"); |
|
83 |
} |
|
84 |
|
|
85 |
sqlQueryTempService.deleteOne(baseVo.getId()); |
|
86 |
|
|
87 |
return Result.success(); |
|
88 |
} |
|
89 |
} |