提交 | 用户 | 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 |
|
|
50 |
if(baseVo.getPageSize() == null || baseVo.getPageSize() <= 0 || baseVo.getPageSize() >= 100) |
|
51 |
{ |
|
52 |
baseVo.setPageSize(20); |
|
53 |
} |
|
54 |
|
|
55 |
log.info(baseVo.getPageNum() + " " + baseVo.getPageSize()); |
|
56 |
|
|
57 |
SqlSentence sqlSentence = new SqlSentence(); |
|
58 |
Map<String, Object> map = new HashMap<>(); |
|
59 |
sqlSentence.setM(map); |
|
60 |
map.put("isDel", BaseEntity.NO); |
|
61 |
|
|
62 |
StringBuilder stringBuilder = new StringBuilder(); |
|
63 |
stringBuilder.append("select * from sql_query_temp where isDel = #{m.isDel}"); |
|
64 |
|
|
65 |
if(!StringUtils.isEmpty(baseVo.getKeyWord())) |
|
66 |
{ |
|
67 |
stringBuilder.append(" and content like #{m.content} "); |
|
68 |
map.put("content", "%" + baseVo.getKeyWord() + "%"); |
|
69 |
} |
|
70 |
|
|
71 |
PageHelper.startPage(baseVo.getPageNum(), baseVo.getPageSize(), " createTime desc "); |
|
72 |
sqlSentence.setSqlSentence(stringBuilder.toString()); |
|
73 |
List<SqlQueryTemp> list = sqlQueryTempService.selectList(sqlSentence); |
|
74 |
PageInfo<SqlQueryTemp> pageInfo = new PageInfo<>(list); |
|
75 |
|
|
76 |
return Result.success(pageInfo); |
|
77 |
} |
|
78 |
|
|
79 |
@PostMapping("/delete") |
|
80 |
public Result delete(@RequestBody(required = false) BaseVo baseVo) |
|
81 |
{ |
|
82 |
if(baseVo == null || StringUtils.isEmpty(baseVo.getId())) |
|
83 |
{ |
|
84 |
throwParamException("请选择记录"); |
|
85 |
} |
|
86 |
|
|
87 |
sqlQueryTempService.deleteOne(baseVo.getId()); |
|
88 |
|
|
89 |
return Result.success(); |
|
90 |
} |
|
91 |
} |