Yansen 2 jaren geleden
bovenliggende
commit
0ee7712e81

db/.back_文明创办/文明创办-backup-202317202536.pdma.json → db/.back_文明创办/文明创办-backup-202318194130.pdma.json Bestand weergeven

@@ -4,7 +4,7 @@
4 4
   "avatar": "",
5 5
   "version": "4.1.4",
6 6
   "createdTime": "2022-12-12 09:36:12",
7
-  "updatedTime": "2023-1-7 19:46:05",
7
+  "updatedTime": "2023-1-8 15:14:39",
8 8
   "dbConns": [],
9 9
   "profile": {
10 10
     "default": {
@@ -4748,6 +4748,40 @@
4748 4748
           "domain": "6BC8F04B-6CFA-4995-98D3-318F5CDD774E",
4749 4749
           "id": "0EF50BA7-C44F-4D9E-A28D-F94C3D15350F"
4750 4750
         },
4751
+        {
4752
+          "defKey": "loc_score",
4753
+          "defName": "实地测评得分",
4754
+          "comment": "",
4755
+          "type": "DECIMAL",
4756
+          "len": 6,
4757
+          "scale": 2,
4758
+          "primaryKey": false,
4759
+          "notNull": false,
4760
+          "autoIncrement": false,
4761
+          "defaultValue": "",
4762
+          "hideInGraph": false,
4763
+          "refDict": "",
4764
+          "extProps": {},
4765
+          "domain": "",
4766
+          "id": "D4F39D10-19B6-49F6-A398-D9278355E747"
4767
+        },
4768
+        {
4769
+          "defKey": "survey_score",
4770
+          "defName": "调查问卷得分",
4771
+          "comment": "",
4772
+          "type": "DECIMAL",
4773
+          "len": 6,
4774
+          "scale": 2,
4775
+          "primaryKey": false,
4776
+          "notNull": false,
4777
+          "autoIncrement": false,
4778
+          "defaultValue": "",
4779
+          "hideInGraph": false,
4780
+          "refDict": "",
4781
+          "extProps": {},
4782
+          "domain": "",
4783
+          "id": "F2E17D81-03A9-42C4-8DD7-732C8D40DC59"
4784
+        },
4751 4785
         {
4752 4786
           "defKey": "start_date",
4753 4787
           "defName": "开始日期",
@@ -5605,7 +5639,7 @@
5605 5639
       "env": {
5606 5640
         "base": {
5607 5641
           "nameSpace": "com.example.civilizedcity",
5608
-          "codeRoot": "TdQuestion"
5642
+          "codeRoot": "TdLocQuestion"
5609 5643
         },
5610 5644
         "template": {
5611 5645
           "JavaMybatisPlus": {
@@ -6449,6 +6483,23 @@
6449 6483
           "domain": "16120F75-6AA7-4483-868D-F07F511BB081",
6450 6484
           "id": "0B03C02D-84EC-4306-8CEA-2BAF04806409"
6451 6485
         },
6486
+        {
6487
+          "defKey": "answer_code",
6488
+          "defName": "答案选项",
6489
+          "comment": "",
6490
+          "type": "VARCHAR",
6491
+          "len": 10,
6492
+          "scale": "",
6493
+          "primaryKey": false,
6494
+          "notNull": false,
6495
+          "autoIncrement": false,
6496
+          "defaultValue": "",
6497
+          "hideInGraph": false,
6498
+          "refDict": "",
6499
+          "extProps": {},
6500
+          "domain": "",
6501
+          "id": "DD78B024-C9B8-4418-BD1B-8F033743F253"
6502
+        },
6452 6503
         {
6453 6504
           "defKey": "answer",
6454 6505
           "defName": "答案",

+ 2
- 2
db/文明创办.pdma.json Bestand weergeven

@@ -4,7 +4,7 @@
4 4
   "avatar": "",
5 5
   "version": "4.1.4",
6 6
   "createdTime": "2022-12-12 09:36:12",
7
-  "updatedTime": "2023-1-8 15:14:39",
7
+  "updatedTime": "2023-1-8 19:41:30",
8 8
   "dbConns": [],
9 9
   "profile": {
10 10
     "default": {
@@ -5639,7 +5639,7 @@
5639 5639
       "env": {
5640 5640
         "base": {
5641 5641
           "nameSpace": "com.example.civilizedcity",
5642
-          "codeRoot": "TdQuestion"
5642
+          "codeRoot": "TdLocQuestion"
5643 5643
         },
5644 5644
         "template": {
5645 5645
           "JavaMybatisPlus": {

+ 3
- 0
src/main/java/com/example/civilizedcity/common/StringUtils.java Bestand weergeven

@@ -13,6 +13,9 @@ public class StringUtils {
13 13
     public static boolean isEmpty(String str) {
14 14
         return null == str || "".equals(str.trim()) || "null".equals(str) || "undefined".equals(str);
15 15
     }
16
+    public static boolean isNotEmpty(String str) {
17
+        return !isEmpty(str);
18
+    }
16 19
 
17 20
     public static String trim(String src, String...st) {
18 21
         if (null == src) return src;

+ 42
- 25
src/main/java/com/example/civilizedcity/controller/TdQuestionController.java Bestand weergeven

@@ -1,10 +1,13 @@
1 1
 package com.example.civilizedcity.controller;
2 2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
3 4
 import com.baomidou.mybatisplus.core.metadata.IPage;
4 5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5 6
 import com.example.civilizedcity.common.BaseController;
7
+import com.example.civilizedcity.common.Constants;
6 8
 import com.example.civilizedcity.common.ResponseBean;
7 9
 import com.example.civilizedcity.common.StringUtils;
10
+import com.example.civilizedcity.entity.TdQuAnswer;
8 11
 import com.example.civilizedcity.service.TaCheckItemAnService;
9 12
 import com.example.civilizedcity.service.TdQuAnswerService;
10 13
 import io.swagger.annotations.Api;
@@ -15,8 +18,11 @@ import org.springframework.web.bind.annotation.*;
15 18
 import com.example.civilizedcity.entity.TdQuestion;
16 19
 import com.example.civilizedcity.service.TdQuestionService;
17 20
 
18
- /**
21
+import java.util.List;
22
+
23
+/**
19 24
  * 点位问题;(td_question)表控制层
25
+ *
20 26
  * @author : http://njyunzhi.com
21 27
  * @date : 2022-12-13
22 28
  */
@@ -24,15 +30,15 @@ import com.example.civilizedcity.service.TdQuestionService;
24 30
 @RestController
25 31
 @RequestMapping("/")
26 32
 public class TdQuestionController extends BaseController {
27
-    
33
+
28 34
     @Autowired
29 35
     private TdQuestionService tdQuestionService;
30 36
 
31
-     @Autowired
32
-     private TdQuAnswerService tdQuAnswerService;
33
-    
34
-    /** 
35
-     * 通过ID查询单条数据 
37
+    @Autowired
38
+    private TdQuAnswerService tdQuAnswerService;
39
+
40
+    /**
41
+     * 通过ID查询单条数据
36 42
      *
37 43
      * @param quId 主键
38 44
      * @return 实例对象
@@ -42,28 +48,39 @@ public class TdQuestionController extends BaseController {
42 48
     public ResponseBean queryById(@ApiParam("对象ID") @PathVariable String id) throws Exception {
43 49
         return ResponseBean.success(tdQuestionService.getById(id));
44 50
     }
45
-    
46
-    /** 
51
+
52
+    /**
47 53
      * 分页查询
48 54
      *
49
-     * @param pageNum 当前页码
55
+     * @param pageNum  当前页码
50 56
      * @param pageSize 每页条数
51 57
      * @return 查询结果
52 58
      */
53 59
     @ApiOperation("分页查询")
54 60
     @GetMapping("/tdQuestion")
55
-    public ResponseBean list(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
56
-                            @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception {
57
-        
61
+    public ResponseBean list(@ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
62
+                             @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
63
+                             @ApiParam("标题") @RequestParam(value = "title", required = false) String title) throws Exception {
64
+
58 65
         IPage<TdQuestion> pg = new Page<>(pageNum, pageSize);
59
-        // QueryWrapper<TdQuestion> queryWrapper = new QueryWrapper<>();
60
-        // queryWrapper.orderByDesc("create_date");
61
-        IPage<TdQuestion> result = tdQuestionService.page(pg);
62
-        
66
+        QueryWrapper<TdQuestion> queryWrapper = new QueryWrapper<>();
67
+        queryWrapper.like(!StringUtils.isEmpty(title), "title", title);
68
+        queryWrapper.gt("status", Constants.STATUS_DELETE);
69
+        queryWrapper.orderByDesc("create_date");
70
+        IPage<TdQuestion> result = tdQuestionService.page(pg, queryWrapper);
71
+
72
+        List<TdQuestion> records = result.getRecords();
73
+        if (null != records || records.size() > 0) {
74
+            for (TdQuestion tdQuestion : records) {
75
+                List<TdQuAnswer> answerList = tdQuAnswerService.getListByQuId(tdQuestion.getQuId());
76
+                tdQuestion.setQuAnswerList(answerList);
77
+            }
78
+        }
79
+
63 80
         return ResponseBean.success(result);
64 81
     }
65
-    
66
-    /** 
82
+
83
+    /**
67 84
      * 新增数据
68 85
      *
69 86
      * @param tdQuestion 实例对象
@@ -84,8 +101,8 @@ public class TdQuestionController extends BaseController {
84 101
         tdQuAnswerService.mergeData(tdQuestion.getQuId(), tdQuestion.getQuAnswerList());
85 102
         return ResponseBean.success(tdQuestion);
86 103
     }
87
-    
88
-    /** 
104
+
105
+    /**
89 106
      * 更新数据
90 107
      *
91 108
      * @param tdQuestion 实例对象
@@ -94,12 +111,12 @@ public class TdQuestionController extends BaseController {
94 111
     @ApiOperation("更新数据")
95 112
     @PutMapping("/tdQuestion/{id}")
96 113
     public ResponseBean edit(@ApiParam("对象实体") @RequestBody TdQuestion tdQuestion,
97
-                            @ApiParam("对象ID") @PathVariable String id ) throws Exception {
114
+                             @ApiParam("对象ID") @PathVariable String id) throws Exception {
98 115
         tdQuestionService.updateById(tdQuestion);
99 116
         return ResponseBean.success(tdQuestion);
100 117
     }
101
-    
102
-    /** 
118
+
119
+    /**
103 120
      * 通过主键删除数据
104 121
      *
105 122
      * @param quId 主键
@@ -107,7 +124,7 @@ public class TdQuestionController extends BaseController {
107 124
      */
108 125
     @ApiOperation("通过主键删除数据")
109 126
     @DeleteMapping("/tdQuestion/{id}")
110
-    public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id){
127
+    public ResponseBean deleteById(@ApiParam("对象ID") @PathVariable String id) {
111 128
         tdQuestionService.removeLogicById(id);
112 129
         return ResponseBean.success("success");
113 130
     }

+ 19
- 22
src/main/java/com/example/civilizedcity/entity/TdQuestion.java Bestand weergeven

@@ -25,28 +25,25 @@ import lombok.experimental.Accessors;
25 25
 @ApiModel(value = "点位问题",description = "")
26 26
 @TableName("td_question")
27 27
 public class TdQuestion implements Serializable,Cloneable{
28
-    /** 问题ID */
29
-    @ApiModelProperty(name = "问题ID",notes = "")
30
-    @TableId(value = "qu_id", type = IdType.ASSIGN_UUID)
31
-    private String quId ;
32
-    /** 点位ID */
33
-    @ApiModelProperty(name = "点位ID",notes = "")
34
-    private String locId ;
35
-    /** 问题类型;radio 单选, fill 填空题 */
36
-    @ApiModelProperty(name = "问题类型",notes = "radio 单选, fill 填空题")
37
-    private String quType ;
38
-    /** 问题描述 */
39
-    @ApiModelProperty(name = "问题描述",notes = "")
40
-    private String title ;
41
-    /** 正确答案 */
42
-    @ApiModelProperty(name = "正确答案",notes = "")
43
-    private String rightAnswers ;
44
-    /** 状态 */
45
-    @ApiModelProperty(name = "状态",notes = "")
46
-    private Integer status ;
47
-    /** 创建时间 */
48
-    @ApiModelProperty(name = "创建时间",notes = "")
49
-    private LocalDateTime createDate ;
28
+     /** 问题ID */
29
+     @ApiModelProperty(name = "问题ID",notes = "")
30
+     @TableId(value = "qu_id", type = IdType.ASSIGN_UUID)
31
+     private String quId ;
32
+     /** 问题类型;radio 单选, fill 填空题 */
33
+     @ApiModelProperty(name = "问题类型",notes = "radio 单选, fill 填空题")
34
+     private String quType ;
35
+     /** 问题描述 */
36
+     @ApiModelProperty(name = "问题描述",notes = "")
37
+     private String title ;
38
+     /** 正确答案 */
39
+     @ApiModelProperty(name = "正确答案",notes = "")
40
+     private String rightAnswers ;
41
+     /** 状态 */
42
+     @ApiModelProperty(name = "状态",notes = "")
43
+     private Integer status ;
44
+     /** 创建时间 */
45
+     @ApiModelProperty(name = "创建时间",notes = "")
46
+     private LocalDateTime createDate ;
50 47
 
51 48
      /**
52 49
       * 问题答案列表

+ 3
- 2
src/main/java/com/example/civilizedcity/service/TdQuAnswerService.java Bestand weergeven

@@ -7,11 +7,12 @@ import java.util.List;
7 7
 
8 8
 /**
9 9
  * 点位问题答案;(td_loc_qu_answer)表服务接口
10
+ *
10 11
  * @author : http://njyunzhi.com
11 12
  * @date : 2022-12-13
12 13
  */
13 14
 public interface TdQuAnswerService extends IBaseService<TdQuAnswer> {
14
- boolean mergeData(String quId, List<TdQuAnswer> quAnswerList);
15
+    boolean mergeData(String quId, List<TdQuAnswer> quAnswerList);
15 16
 
16
- List<TdQuAnswer> getListByQuId(String quId);
17
+    List<TdQuAnswer> getListByQuId(String quId);
17 18
 }

+ 35
- 32
src/main/java/com/example/civilizedcity/service/impl/TdQuAnswerServiceImpl.java Bestand weergeven

@@ -1,6 +1,7 @@
1 1
 package com.example.civilizedcity.service.impl;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.example.civilizedcity.common.Constants;
4 5
 import com.example.civilizedcity.common.StringUtils;
5 6
 import com.example.civilizedcity.entity.TaCheckItemAn;
6 7
 import org.springframework.stereotype.Service;
@@ -13,42 +14,44 @@ import java.util.List;
13 14
 
14 15
 /**
15 16
  * 点位问题答案;(td_loc_qu_answer)表服务实现类
17
+ *
16 18
  * @author : http://www.chiner.pro
17 19
  * @date : 2022-12-13
18 20
  */
19 21
 @Service
20 22
 public class TdQuAnswerServiceImpl extends BaseServiceImpl<TdQuAnswerMapper, TdQuAnswer> implements TdQuAnswerService {
21 23
 
22
- @Override
23
- public boolean mergeData(String quId, List<TdQuAnswer> quAnswerList) {
24
-  if (StringUtils.isEmpty(quId)) return false;
25
-
26
-  // 先删除所有
27
-  baseMapper.deleteByMap(new HashMap<String, Object>() {{
28
-   put("qu_id", quId);
29
-  }});
30
-
31
-  if (null == quAnswerList || quAnswerList.isEmpty()) {
32
-   return true;
33
-  }
34
-
35
-  for (int i = 0; i < quAnswerList.size(); i ++) {
36
-   TdQuAnswer item = quAnswerList.get(i);
37
-   item.setQuId(quId);
38
-   // 重新排序
39
-   item.setSortNo(i + 1);
40
-   save(item);
41
-  }
42
-
43
-  return true;
44
- }
45
-
46
- @Override
47
- public List<TdQuAnswer> getListByQuId(String quId) {
48
-  QueryWrapper<TdQuAnswer> queryWrapper = new QueryWrapper<>();
49
-  queryWrapper.eq("qu_id", quId);
50
-  queryWrapper.orderByAsc("sort_no");
51
-
52
-  return list(queryWrapper);
53
- }
24
+    @Override
25
+    public boolean mergeData(String quId, List<TdQuAnswer> quAnswerList) {
26
+        if (StringUtils.isEmpty(quId)) return false;
27
+
28
+        // 先删除所有
29
+        baseMapper.deleteByMap(new HashMap<String, Object>() {{
30
+            put("qu_id", quId);
31
+        }});
32
+
33
+        if (null == quAnswerList || quAnswerList.isEmpty()) {
34
+            return true;
35
+        }
36
+
37
+        for (int i = 0; i < quAnswerList.size(); i++) {
38
+            TdQuAnswer item = quAnswerList.get(i);
39
+            item.setQuId(quId);
40
+            // 重新排序
41
+            item.setSortNo(i + 1);
42
+            save(item);
43
+        }
44
+
45
+        return true;
46
+    }
47
+
48
+    @Override
49
+    public List<TdQuAnswer> getListByQuId(String quId) {
50
+        QueryWrapper<TdQuAnswer> queryWrapper = new QueryWrapper<>();
51
+        queryWrapper.eq("qu_id", quId);
52
+        queryWrapper.gt("status", Constants.STATUS_DELETE);
53
+        queryWrapper.orderByAsc("sort_no");
54
+
55
+        return list(queryWrapper);
56
+    }
54 57
 }