张延森 4 年前
父节点
当前提交
2e788defaf

+ 13
- 8
src/main/java/com/yunzhi/demo/common/JWTUtils.java 查看文件

@@ -42,14 +42,6 @@ public class JWTUtils {
42 42
         Date iat = datePair[0];
43 43
         Date exp = datePair[1];
44 44
 
45
-        if (null != claims.get("exp")) {
46
-            Integer milliSecond = (Integer) claims.get("exp");
47
-            int oneMinute = 1 * 60 * 1000;
48
-            if (milliSecond - exp.getTime() > oneMinute) {
49
-                exp.setTime(milliSecond);
50
-            }
51
-        }
52
-
53 45
         return Jwts.builder().setIssuer(claims.get("userId").toString()).setIssuedAt(iat).setExpiration(exp).addClaims(claims).signWith(SECRET_KEY).compact();
54 46
     }
55 47
 
@@ -60,6 +52,19 @@ public class JWTUtils {
60 52
     public static String refresh(String token) {
61 53
         try {
62 54
             Claims claims = parse(token);
55
+
56
+            Integer iat = (Integer) claims.get("iat");
57
+            if (null != iat) {
58
+                long currentTime = System.currentTimeMillis() / 1000;
59
+                int oneMinute = 60;
60
+                if (currentTime - iat < oneMinute) {
61
+                    return token;
62
+                }
63
+            }
64
+
65
+            claims.remove("iat");
66
+            claims.remove("exp");
67
+
63 68
             return encode(claims);
64 69
         } catch (Exception e) {
65 70
             log.error("解析 JWT Token 失败: {}", e.getMessage());

+ 0
- 3
src/main/java/com/yunzhi/demo/controller/LoginController.java 查看文件

@@ -17,9 +17,6 @@ import org.springframework.web.bind.annotation.*;
17 17
 import java.util.HashMap;
18 18
 import java.util.Map;
19 19
 
20
-//import java.util.HashMap;
21
-
22
-
23 20
 @Api(tags = "登入/登出")
24 21
 @RestController
25 22
 public class LoginController extends BaseController {

+ 4
- 7
src/main/java/com/yunzhi/demo/controller/StatisticController.java 查看文件

@@ -5,10 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5 5
 import com.yunzhi.demo.common.BaseController;
6 6
 import com.yunzhi.demo.common.ResponseBean;
7 7
 import com.yunzhi.demo.entity.TaPost;
8
-import com.yunzhi.demo.service.ITaPersonService;
9
-import com.yunzhi.demo.service.ITaPostDataService;
10
-import com.yunzhi.demo.service.ITaPostService;
11
-import com.yunzhi.demo.service.ITaReadLogService;
8
+import com.yunzhi.demo.service.*;
12 9
 import com.yunzhi.demo.vo.StatisPerson;
13 10
 import com.yunzhi.demo.vo.StatisPost;
14 11
 import io.swagger.annotations.Api;
@@ -31,7 +28,7 @@ public class StatisticController extends BaseController {
31 28
     ITaPostDataService iTaPostDataService;
32 29
 
33 30
     @Autowired
34
-    ITaPersonService iTaPersonService;
31
+    ITaStudentService iTaStudentService;
35 32
 
36 33
     @Autowired
37 34
     ITaReadLogService iTaReadLogService;
@@ -46,7 +43,7 @@ public class StatisticController extends BaseController {
46 43
         // 获取总科普数, 以及 浏览量
47 44
         Map<String, Object> result = iTaPostDataService.getIndexBasicData();
48 45
         // 获取总学生人员
49
-        int totalStudents = iTaPersonService.countStudent();
46
+        int totalStudents = iTaStudentService.countStudent();
50 47
         result.put("student", totalStudents);
51 48
 
52 49
         return ResponseBean.success(result);
@@ -107,7 +104,7 @@ public class StatisticController extends BaseController {
107 104
                                       @ApiParam("降序") @RequestParam(value = "desc", required = false) String desc) {
108 105
         IPage<StatisPerson> pg = new Page<>(pageNum, pageSize);
109 106
 
110
-        IPage<StatisPerson> personList = iTaPersonService.getStudentStatis(pg, name, schoolId, specialtyId, asc, desc);
107
+        IPage<StatisPerson> personList = iTaStudentService.getStudentStatis(pg, name, schoolId, specialtyId, asc, desc);
111 108
 
112 109
         return ResponseBean.success(personList);
113 110
     }

+ 21
- 1
src/main/java/com/yunzhi/demo/controller/SysBannerController.java 查看文件

@@ -7,7 +7,7 @@ import com.yunzhi.demo.common.BaseController;
7 7
 import com.yunzhi.demo.common.Constants;
8 8
 import com.yunzhi.demo.common.ResponseBean;
9 9
 import com.yunzhi.demo.common.StringUtils;
10
-import com.yunzhi.demo.entity.TaPost;
10
+import com.yunzhi.demo.vo.SortParams;
11 11
 import io.swagger.annotations.Api;
12 12
 import io.swagger.annotations.ApiOperation;
13 13
 import io.swagger.annotations.ApiParam;
@@ -74,6 +74,14 @@ public class SysBannerController extends BaseController {
74 74
     @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
75 75
     public ResponseBean bannerAdd(@ApiParam("保存内容") @RequestBody SysBanner sysBanner) throws Exception{
76 76
 
77
+        QueryWrapper<SysBanner> queryWrapper = new QueryWrapper<SysBanner>()
78
+                .orderByDesc("sort_no")
79
+                .last("limit 1");
80
+
81
+        SysBanner max = iSysBannerService.getOne(queryWrapper);
82
+        int sortNo = max == null ? 0 : max.getSortNo() + 1;
83
+        sysBanner.setSortNo(sortNo);
84
+
77 85
         if (iSysBannerService.save(sysBanner)){
78 86
             return ResponseBean.success(sysBanner);
79 87
         }else {
@@ -132,4 +140,16 @@ public class SysBannerController extends BaseController {
132 140
 
133 141
         return ResponseBean.success(sysBanner);
134 142
     }
143
+
144
+
145
+    @RequestMapping(value="/admin/sort/banner",method= RequestMethod.PUT)
146
+    @ApiOperation(value="排序", notes = "排序", httpMethod = "PUT", response = ResponseBean.class)
147
+    public ResponseBean bannerSort(@ApiParam("排序") @RequestBody SortParams sortParams) throws Exception {
148
+        if (StringUtils.isEmpty(sortParams.getFrom()) || StringUtils.isEmpty(sortParams.getTo())) {
149
+            return ResponseBean.success("success");
150
+        }
151
+
152
+        iSysBannerService.reSort(sortParams);
153
+        return ResponseBean.success("success");
154
+    }
135 155
 }

+ 0
- 144
src/main/java/com/yunzhi/demo/controller/TaPersonController.java 查看文件

@@ -1,28 +1,12 @@
1 1
 package com.yunzhi.demo.controller;
2 2
 
3
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
-import com.baomidou.mybatisplus.core.metadata.IPage;
5
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 3
 import com.yunzhi.demo.common.BaseController;
7
-import com.yunzhi.demo.common.Constants;
8
-import com.yunzhi.demo.common.ResponseBean;
9
-import com.yunzhi.demo.common.StringUtils;
10
-import com.yunzhi.demo.entity.TaPersonData;
11
-import com.yunzhi.demo.entity.TdSchool;
12
-import com.yunzhi.demo.entity.TdSpecialty;
13 4
 import com.yunzhi.demo.service.*;
14 5
 import io.swagger.annotations.Api;
15
-import io.swagger.annotations.ApiOperation;
16
-import io.swagger.annotations.ApiParam;
17 6
 import org.slf4j.Logger;
18 7
 import org.slf4j.LoggerFactory;
19 8
 import org.springframework.beans.factory.annotation.Autowired;
20 9
 import org.springframework.web.bind.annotation.*;
21
-import com.yunzhi.demo.entity.TaPerson;
22
-
23
-import java.time.LocalDateTime;
24
-import java.util.HashMap;
25
-import java.util.Map;
26 10
 
27 11
 /**
28 12
  * <p>
@@ -43,132 +27,4 @@ public class TaPersonController extends BaseController {
43 27
     @Autowired
44 28
     ITaPersonService iTaPersonService;
45 29
 
46
-    @Autowired
47
-    ITaPersonDataService iTaPersonDataService;
48
-
49
-    @Autowired
50
-    ITdSchoolService iTdSchoolService;
51
-
52
-    @Autowired
53
-    ITdSpecialtyService iTdSpecialtyService;
54
-
55
-    /**
56
-     * 分页查询列表
57
-     * @param pageNum
58
-     * @param pageSize
59
-     * @return
60
-     */
61
-    @RequestMapping(value="/admin/person",method= RequestMethod.GET)
62
-    @ApiOperation(value="查询学生列表", notes = "查询学生列表", httpMethod = "GET", response = ResponseBean.class)
63
-    public ResponseBean taPersonList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
64
-									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
65
-                                     @ApiParam("名称") @RequestParam(value ="name", required = false) String name,
66
-                                     @ApiParam("学校ID") @RequestParam(value ="schoolId", required = false) String schoolId,
67
-                                     @ApiParam("专业ID") @RequestParam(value ="specialtyId", required = false) String specialtyId,
68
-                                     @ApiParam("手机") @RequestParam(value ="phone", required = false) String phone,
69
-                                     @ApiParam("学号") @RequestParam(value ="studentId", required = false) String studentId) throws Exception{
70
-
71
-		    IPage<TaPerson> pg = new Page<>(pageNum, pageSize);
72
-            IPage<TaPerson> result = iTaPersonService.getStudentInfoPagedBy(pg, name, schoolId, specialtyId, phone, studentId);
73
-            return ResponseBean.success(result);
74
-    }
75
-
76
-    /**
77
-     * 小程序完善信息
78
-     * @param taPerson 实体对象
79
-     * @return
80
-     */
81
-    @RequestMapping(value="/ma/person",method= RequestMethod.PUT)
82
-    @ApiOperation(value="小程序完善信息", notes = "更新当前人自己的信息", httpMethod = "PUT", response = TaPerson.class)
83
-    public ResponseBean taPersonUpdate(@ApiParam("更新内容") @RequestBody TaPerson taPerson) throws Exception{
84
-        TaPerson currentPerson = getCurrentPerson();
85
-        if (null == currentPerson || null == taPerson || !currentPerson.getPersonId().equals(taPerson.getPersonId())) {
86
-            throw new Exception("校验人员信息失败");
87
-        }
88
-
89
-        if (!StringUtils.isEmpty(taPerson.getStudentId())) {
90
-            TaPerson stu = iTaPersonService.getByStudentId(taPerson.getStudentId());
91
-            if (null != stu && stu.getPersonId().equals(taPerson.getPersonId())) {
92
-                throw new Exception("学号信息重复");
93
-            }
94
-        }
95
-
96
-        taPerson.setUpdateDate(LocalDateTime.now());
97
-
98
-        if (iTaPersonService.updateById(taPerson)){
99
-
100
-            taPerson = iTaPersonService.getById(taPerson.getPersonId());
101
-            fillInfo(taPerson);
102
-
103
-            return ResponseBean.success(taPerson);
104
-        }else {
105
-            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
106
-        }
107
-    }
108
-
109
-    /**
110
-     * 根据id查询对象
111
-     * @param id  实体ID
112
-     */
113
-    @RequestMapping(value="/admin/person/{id}",method= RequestMethod.GET)
114
-    @ApiOperation(value="学生详情", notes = "查询人员详细信息", httpMethod = "GET", response = TaPerson.class)
115
-    public ResponseBean taPersonGet(@ApiParam("学生ID") @PathVariable String id) throws Exception{
116
-        TaPerson taPerson = iTaPersonService.getById(id);
117
-        if (null == taPerson || Constants.STATUS_DELETED.equals(taPerson.getStatus())) {
118
-            throw new Exception("验证人员信息失败, 请退出重试");
119
-        }
120
-
121
-        fillInfo(taPerson);
122
-
123
-        return ResponseBean.success(taPerson);
124
-    }
125
-
126
-    /**
127
-     * 根据id查询对象
128
-     * @param id  学号
129
-     */
130
-    @RequestMapping(value="/admin/student/{id}",method= RequestMethod.GET)
131
-    @ApiOperation(value="学生详情", notes = "查询人员详细信息", httpMethod = "GET", response = TaPerson.class)
132
-    public ResponseBean studentGet(@ApiParam("学生学号") @PathVariable String id) throws Exception{
133
-        TaPerson taPerson = iTaPersonService.getByStudentId(id);
134
-        if (null == taPerson || Constants.STATUS_DELETED.equals(taPerson.getStatus())) {
135
-            throw new Exception("验证人员信息失败, 请退出重试");
136
-        }
137
-
138
-        fillInfo(taPerson);
139
-
140
-        return ResponseBean.success(taPerson);
141
-    }
142
-
143
-    @GetMapping("/ma/currentPerson")
144
-    @ApiOperation(value="小程序当前人员", notes = "获取当前人员信息", httpMethod = "GET", response = TaPerson.class)
145
-    public ResponseBean getCurrent() throws Exception {
146
-        TaPerson taPerson = getCurrentPerson();
147
-        if (null == taPerson) {
148
-            throw new Exception("验证人员信息失败, 请退出重试");
149
-        }
150
-
151
-        fillInfo(taPerson);
152
-
153
-        return ResponseBean.success(taPerson);
154
-    }
155
-
156
-    private void fillInfo(TaPerson taPerson) {
157
-        // 冗余学校名称, 专业名称
158
-        if (null != taPerson.getSchoolId()) {
159
-            TdSchool tdSchool = iTdSchoolService.getById(taPerson.getSchoolId());
160
-            if (null != tdSchool) {
161
-                taPerson.setSchoolName(tdSchool.getName());
162
-            }
163
-
164
-            TdSpecialty tdSpecialty = iTdSpecialtyService.getById(taPerson.getSpecialtyId());
165
-            if (null != tdSpecialty) {
166
-                taPerson.setSpecialtyName(tdSpecialty.getName());
167
-            }
168
-        }
169
-
170
-        // 获取统计数据
171
-        TaPersonData taPersonData = iTaPersonDataService.getById(taPerson.getPersonId());
172
-        taPerson.setPersonData(taPersonData);
173
-    }
174 30
 }

+ 194
- 0
src/main/java/com/yunzhi/demo/controller/TaStudentController.java 查看文件

@@ -0,0 +1,194 @@
1
+package com.yunzhi.demo.controller;
2
+
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
5
+import com.yunzhi.demo.common.BaseController;
6
+import com.yunzhi.demo.common.Constants;
7
+import com.yunzhi.demo.common.ResponseBean;
8
+import com.yunzhi.demo.common.StringUtils;
9
+import com.yunzhi.demo.entity.*;
10
+import com.yunzhi.demo.service.ITaPersonDataService;
11
+import com.yunzhi.demo.service.ITaStudentService;
12
+import com.yunzhi.demo.service.ITdSchoolService;
13
+import com.yunzhi.demo.service.ITdSpecialtyService;
14
+import io.swagger.annotations.Api;
15
+import io.swagger.annotations.ApiOperation;
16
+import io.swagger.annotations.ApiParam;
17
+import lombok.extern.slf4j.Slf4j;
18
+import org.springframework.beans.factory.annotation.Autowired;
19
+import org.springframework.web.bind.annotation.*;
20
+
21
+import java.time.LocalDateTime;
22
+
23
+@Slf4j
24
+@Api(tags = "学生")
25
+@RestController
26
+@RequestMapping("/")
27
+public class TaStudentController extends BaseController {
28
+
29
+    @Autowired
30
+    ITaStudentService iTaStudentService;
31
+
32
+    @Autowired
33
+    ITaPersonDataService iTaPersonDataService;
34
+
35
+    @Autowired
36
+    ITdSchoolService iTdSchoolService;
37
+
38
+    @Autowired
39
+    ITdSpecialtyService iTdSpecialtyService;
40
+
41
+    /**
42
+     * 分页查询列表
43
+     * @param pageNum
44
+     * @param pageSize
45
+     * @return
46
+     */
47
+    @RequestMapping(value="/admin/student",method= RequestMethod.GET)
48
+    @ApiOperation(value="查询学生列表", notes = "查询学生列表", httpMethod = "GET", response = ResponseBean.class)
49
+    public ResponseBean taStudentList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
50
+                                     @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
51
+                                     @ApiParam("名称") @RequestParam(value ="name", required = false) String name,
52
+                                     @ApiParam("学校ID") @RequestParam(value ="schoolId", required = false) String schoolId,
53
+                                     @ApiParam("专业ID") @RequestParam(value ="specialtyId", required = false) String specialtyId,
54
+                                     @ApiParam("手机") @RequestParam(value ="phone", required = false) String phone,
55
+                                     @ApiParam("学号") @RequestParam(value ="studentNo", required = false) String studentNo) throws Exception {
56
+
57
+        IPage<TaStudent> pg = new Page<>(pageNum, pageSize);
58
+        IPage<TaStudent> result = iTaStudentService.getStudentInfoPagedBy(pg, name, schoolId, specialtyId, phone, studentNo);
59
+        return ResponseBean.success(result);
60
+    }
61
+
62
+    /**
63
+     * 小程序完善信息
64
+     * @param taStudent 实体对象
65
+     * @return
66
+     */
67
+    @RequestMapping(value="/ma/student",method= RequestMethod.PUT)
68
+    @ApiOperation(value="小程序完善信息", notes = "更新当前人自己的信息", httpMethod = "PUT", response = TaStudent.class)
69
+    public ResponseBean taPersonUpdate(@ApiParam("更新内容") @RequestBody TaStudent taStudent) throws Exception{
70
+        TaPerson currentPerson = getCurrentPerson();
71
+        if (null == currentPerson || null == taStudent) {
72
+            throw new Exception("校验人员信息失败");
73
+        }
74
+
75
+        // 解决人员跟学生映射问题
76
+        if (!StringUtils.isEmpty(taStudent.getStudentId())) {
77
+            TaStudent origin = iTaStudentService.getByPersonId(currentPerson.getPersonId());
78
+            if (null != origin) {
79
+                taStudent.setStudentId(origin.getStudentId());
80
+            } else {
81
+                origin = iTaStudentService.getByPhone(currentPerson.getPhone());
82
+                if (null != origin) {
83
+                    taStudent.setStudentId(origin.getStudentId());
84
+                }
85
+            }
86
+        }
87
+
88
+        if (!StringUtils.isEmpty(taStudent.getStudentNo())) {
89
+            TaStudent stu = iTaStudentService.getByStudentNo(taStudent.getStudentNo());
90
+            if (null != stu && !StringUtils.isEmpty(taStudent.getStudentId()) && stu.getStudentId().equals(taStudent.getStudentId())) {
91
+                throw new Exception("学号信息重复");
92
+            }
93
+        }
94
+
95
+        taStudent.setUpdateDate(LocalDateTime.now());
96
+        taStudent.setPersonId(currentPerson.getPersonId());
97
+
98
+        if (StringUtils.isEmpty(taStudent.getStudentId())) {
99
+            iTaStudentService.save(taStudent);
100
+        } else {
101
+            iTaStudentService.updateById(taStudent);
102
+        }
103
+
104
+        fillInfo(taStudent);
105
+        return ResponseBean.success(taStudent);
106
+    }
107
+
108
+    /**
109
+     * 根据id查询对象
110
+     * @param id  实体ID
111
+     */
112
+    @RequestMapping(value="/admin/student/{id}",method= RequestMethod.GET)
113
+    @ApiOperation(value="学生详情", notes = "查询人员详细信息", httpMethod = "GET", response = TaPerson.class)
114
+    public ResponseBean taPersonGet(@ApiParam("学生ID") @PathVariable String id) throws Exception{
115
+        TaStudent taStudent = iTaStudentService.getById(id);
116
+        if (null == taStudent || Constants.STATUS_DELETED.equals(taStudent.getStatus())) {
117
+            throw new Exception("验证人员信息失败, 请退出重试");
118
+        }
119
+
120
+        fillInfo(taStudent);
121
+
122
+        return ResponseBean.success(taStudent);
123
+    }
124
+
125
+    /**
126
+     * 根据id查询对象
127
+     * @param id  学号
128
+     */
129
+    @RequestMapping(value="/admin/student-no/{id}",method= RequestMethod.GET)
130
+    @ApiOperation(value="学生详情", notes = "查询人员详细信息", httpMethod = "GET", response = TaPerson.class)
131
+    public ResponseBean studentGet(@ApiParam("学生学号") @PathVariable String id) throws Exception{
132
+        TaStudent taStudent = iTaStudentService.getByStudentNo(id);
133
+        if (null == taStudent || Constants.STATUS_DELETED.equals(taStudent.getStatus())) {
134
+            throw new Exception("验证人员信息失败, 请退出重试");
135
+        }
136
+
137
+        fillInfo(taStudent);
138
+
139
+        return ResponseBean.success(taStudent);
140
+    }
141
+
142
+    @GetMapping("/ma/currentPerson")
143
+    @ApiOperation(value="小程序当前人员", notes = "获取当前人员信息", httpMethod = "GET", response = TaPerson.class)
144
+    public ResponseBean getCurrent() throws Exception {
145
+        TaPerson taPerson = getCurrentPerson();
146
+        if (null == taPerson) {
147
+            throw new Exception("验证人员信息失败, 请退出重试");
148
+        }
149
+
150
+        // 先找映射ID的
151
+        TaStudent taStudent = iTaStudentService.getByPersonId(taPerson.getPersonId());
152
+        if (null == taStudent) {
153
+            // 如果没有再找相同手机号的
154
+            if (!StringUtils.isEmpty(taPerson.getPhone())) {
155
+                taStudent = iTaStudentService.getByPhone(taPerson.getPhone());
156
+                if (null != taStudent) {
157
+                    if (!StringUtils.isEmpty(taStudent.getPersonId())) {
158
+                        log.error("学生[{}]与人员[{}]映射异常", taStudent.getStudentId(), taPerson.getPersonId());
159
+                    } else {
160
+                        taStudent.setPersonId(taPerson.getPersonId());
161
+                        iTaStudentService.updateById(taStudent);
162
+                    }
163
+                }
164
+            }
165
+        }
166
+
167
+        if (null != taStudent) {
168
+            fillInfo(taStudent);
169
+        }
170
+
171
+        taPerson.setStudent(taStudent);
172
+
173
+        return ResponseBean.success(taPerson);
174
+    }
175
+
176
+    private void fillInfo(TaStudent taStudent) {
177
+        // 冗余学校名称, 专业名称
178
+        if (null != taStudent.getSchoolId()) {
179
+            TdSchool tdSchool = iTdSchoolService.getById(taStudent.getSchoolId());
180
+            if (null != tdSchool) {
181
+                taStudent.setSchoolName(tdSchool.getName());
182
+            }
183
+
184
+            TdSpecialty tdSpecialty = iTdSpecialtyService.getById(taStudent.getSpecialtyId());
185
+            if (null != tdSpecialty) {
186
+                taStudent.setSpecialtyName(tdSpecialty.getName());
187
+            }
188
+        }
189
+
190
+        // 获取统计数据
191
+        TaPersonData taPersonData = iTaPersonDataService.getById(taStudent.getPersonId());
192
+        taStudent.setPersonData(taPersonData);
193
+    }
194
+}

+ 3
- 4
src/main/java/com/yunzhi/demo/entity/TaMedicalLog.java 查看文件

@@ -31,8 +31,8 @@ public class TaMedicalLog implements Serializable {
31 31
     @TableId(value = "serial_no", type = IdType.AUTO)
32 32
     private Integer serialNo;
33 33
 
34
-    @ApiModelProperty(value = "人员ID")
35
-    private String personId;
34
+    @ApiModelProperty(value = "学生ID")
35
+    private String studentId;
36 36
 
37 37
     @ApiModelProperty(value = "就诊时间 YYYY-MM-DD格式")
38 38
     private String recordDate;
@@ -82,7 +82,6 @@ public class TaMedicalLog implements Serializable {
82 82
 
83 83
     @ApiModelProperty(value = "学号")
84 84
     @TableField(exist = false)
85
-    private String studentId;
86
-
85
+    private String studentNo;
87 86
 
88 87
 }

+ 4
- 26
src/main/java/com/yunzhi/demo/entity/TaPerson.java 查看文件

@@ -35,9 +35,6 @@ public class TaPerson implements Serializable {
35 35
     @ApiModelProperty(value = "openid")
36 36
     private String openid;
37 37
 
38
-    @ApiModelProperty(value = "姓名")
39
-    private String name;
40
-
41 38
     @ApiModelProperty(value = "性别")
42 39
     private Integer sex;
43 40
 
@@ -50,29 +47,6 @@ public class TaPerson implements Serializable {
50 47
     @ApiModelProperty(value = "手机")
51 48
     private String phone;
52 49
 
53
-    @ApiModelProperty(value = "邮箱")
54
-    private String eMail;
55
-
56
-    @ApiModelProperty(value = "学校ID")
57
-    private String schoolId;
58
-
59
-    @ApiModelProperty(value = "学校名称")
60
-    @TableField(exist = false)
61
-    private String schoolName;
62
-
63
-    @ApiModelProperty(value = "学界")
64
-    private String schoolBatch;
65
-
66
-    @ApiModelProperty(value = "专业ID")
67
-    private String specialtyId;
68
-
69
-    @ApiModelProperty(value = "专业名称")
70
-    @TableField(exist = false)
71
-    private String specialtyName;
72
-
73
-    @ApiModelProperty(value = "学号")
74
-    private String studentId;
75
-
76 50
     @ApiModelProperty(value = "状态")
77 51
     private Integer status;
78 52
 
@@ -82,6 +56,10 @@ public class TaPerson implements Serializable {
82 56
     @ApiModelProperty(value = "更新时间")
83 57
     private LocalDateTime updateDate;
84 58
 
59
+    @ApiModelProperty(value = "学生信息")
60
+    @TableField(exist = false)
61
+    private TaStudent student;
62
+
85 63
     @ApiModelProperty(value = "统计数据")
86 64
     @TableField(exist = false)
87 65
     private TaPersonData personData;

+ 82
- 0
src/main/java/com/yunzhi/demo/entity/TaStudent.java 查看文件

@@ -0,0 +1,82 @@
1
+package com.yunzhi.demo.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
5
+import com.baomidou.mybatisplus.annotation.TableId;
6
+import io.swagger.annotations.ApiModel;
7
+import io.swagger.annotations.ApiModelProperty;
8
+import lombok.Data;
9
+import lombok.EqualsAndHashCode;
10
+import lombok.experimental.Accessors;
11
+
12
+import java.io.Serializable;
13
+import java.time.LocalDateTime;
14
+
15
+/**
16
+ * <p>
17
+ * 人员
18
+ * </p>
19
+ *
20
+ * @author yansen
21
+ * @since 2021-04-15
22
+ */
23
+@Data
24
+@EqualsAndHashCode(callSuper = false)
25
+@Accessors(chain = true)
26
+@ApiModel(value="TaStudent对象", description="学生")
27
+public class TaStudent implements Serializable {
28
+
29
+    private static final long serialVersionUID = 1L;
30
+
31
+    @ApiModelProperty(value = "学生ID")
32
+    @TableId(value = "student_id", type = IdType.UUID)
33
+    private String studentId;
34
+
35
+    @ApiModelProperty(value = "映射人员ID")
36
+    private String personId;
37
+
38
+    @ApiModelProperty(value = "姓名")
39
+    private String name;
40
+
41
+    @ApiModelProperty(value = "性别")
42
+    private Integer sex;
43
+
44
+    @ApiModelProperty(value = "手机")
45
+    private String phone;
46
+
47
+    @ApiModelProperty(value = "邮箱")
48
+    private String eMail;
49
+
50
+    @ApiModelProperty(value = "学校ID")
51
+    private String schoolId;
52
+
53
+    @ApiModelProperty(value = "学校名称")
54
+    @TableField(exist = false)
55
+    private String schoolName;
56
+
57
+    @ApiModelProperty(value = "学界")
58
+    private String schoolBatch;
59
+
60
+    @ApiModelProperty(value = "专业ID")
61
+    private String specialtyId;
62
+
63
+    @ApiModelProperty(value = "专业名称")
64
+    @TableField(exist = false)
65
+    private String specialtyName;
66
+
67
+    @ApiModelProperty(value = "学号")
68
+    private String studentNo;
69
+
70
+    @ApiModelProperty(value = "状态")
71
+    private Integer status;
72
+
73
+    @ApiModelProperty(value = "创建时间")
74
+    private LocalDateTime createDate;
75
+
76
+    @ApiModelProperty(value = "更新时间")
77
+    private LocalDateTime updateDate;
78
+
79
+    @ApiModelProperty(value = "统计信息")
80
+    @TableField(exist = false)
81
+    private TaPersonData personData;
82
+}

+ 2
- 2
src/main/java/com/yunzhi/demo/entity/TaTestLog.java 查看文件

@@ -30,8 +30,8 @@ public class TaTestLog implements Serializable {
30 30
     @TableId(value = "serial_no", type = IdType.AUTO)
31 31
     private Integer serialNo;
32 32
 
33
-    @ApiModelProperty(value = "人员ID")
34
-    private String personId;
33
+    @ApiModelProperty(value = "学生ID")
34
+    private String studentId;
35 35
 
36 36
     @ApiModelProperty(value = "报告名称")
37 37
     private String name;

+ 3
- 0
src/main/java/com/yunzhi/demo/mapper/SysBannerMapper.java 查看文件

@@ -15,4 +15,7 @@ import org.apache.ibatis.annotations.Mapper;
15 15
 @Mapper
16 16
 public interface SysBannerMapper extends BaseMapper<SysBanner> {
17 17
 
18
+    int bannerSortAdd(Integer max, Integer min);
19
+
20
+    int bannerSortSub(Integer max, Integer min);
18 21
 }

+ 34
- 0
src/main/java/com/yunzhi/demo/mapper/TaStudentMapper.java 查看文件

@@ -0,0 +1,34 @@
1
+package com.yunzhi.demo.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.yunzhi.demo.entity.TaStudent;
6
+import com.yunzhi.demo.vo.StatisPerson;
7
+import org.apache.ibatis.annotations.Mapper;
8
+import org.apache.ibatis.annotations.Param;
9
+
10
+/**
11
+ * <p>
12
+ * 人员 Mapper 接口
13
+ * </p>
14
+ *
15
+ * @author yansen
16
+ * @since 2021-04-15
17
+ */
18
+@Mapper
19
+public interface TaStudentMapper extends BaseMapper<TaStudent> {
20
+
21
+    IPage<StatisPerson> getStudentStatis(IPage<StatisPerson> pg,
22
+                                        @Param("name") String name,
23
+                                        @Param("schoolId") String schoolId,
24
+                                        @Param("specialtyId") String specialtyId,
25
+                                        @Param("asc") String asc,
26
+                                        @Param("desc") String desc);
27
+
28
+    IPage<TaStudent> getStudentInfoPagedBy(IPage<TaStudent> pg,
29
+                                          @Param("name") String name,
30
+                                          @Param("schoolId") String schoolId,
31
+                                          @Param("specialtyId") String specialtyId,
32
+                                          @Param("phone") String phone,
33
+                                          @Param("studentNo") String studentNo);
34
+}

+ 3
- 0
src/main/java/com/yunzhi/demo/service/ISysBannerService.java 查看文件

@@ -2,6 +2,7 @@ package com.yunzhi.demo.service;
2 2
 
3 3
 import com.yunzhi.demo.entity.SysBanner;
4 4
 import com.baomidou.mybatisplus.extension.service.IService;
5
+import com.yunzhi.demo.vo.SortParams;
5 6
 
6 7
 import java.util.List;
7 8
 
@@ -16,4 +17,6 @@ import java.util.List;
16 17
 public interface ISysBannerService extends IService<SysBanner> {
17 18
 
18 19
     List<SysBanner> getIndexList();
20
+
21
+    void reSort(SortParams sortParams);
19 22
 }

+ 28
- 0
src/main/java/com/yunzhi/demo/service/ITaStudentService.java 查看文件

@@ -0,0 +1,28 @@
1
+package com.yunzhi.demo.service;
2
+
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+import com.yunzhi.demo.entity.TaStudent;
6
+import com.yunzhi.demo.vo.StatisPerson;
7
+
8
+/**
9
+ * <p>
10
+ * 人员 服务类
11
+ * </p>
12
+ *
13
+ * @author yansen
14
+ * @since 2021-04-15
15
+ */
16
+public interface ITaStudentService extends IService<TaStudent> {
17
+    int countStudent();
18
+
19
+    IPage<StatisPerson> getStudentStatis(IPage<StatisPerson> pg, String name, String schoolId, String specialtyId, String asc, String desc);
20
+
21
+    IPage<TaStudent> getStudentInfoPagedBy(IPage<TaStudent> pg, String name, String schoolId, String specialtyId, String phone, String studentNo);
22
+
23
+    TaStudent getByStudentNo(String studentNo);
24
+
25
+    TaStudent getByPersonId(String personId);
26
+
27
+    TaStudent getByPhone(String phone);
28
+}

+ 31
- 0
src/main/java/com/yunzhi/demo/service/impl/SysBannerServiceImpl.java 查看文件

@@ -1,11 +1,15 @@
1 1
 package com.yunzhi.demo.service.impl;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
4 5
 import com.yunzhi.demo.common.Constants;
5 6
 import com.yunzhi.demo.entity.SysBanner;
7
+import com.yunzhi.demo.entity.TaTopic;
6 8
 import com.yunzhi.demo.mapper.SysBannerMapper;
7 9
 import com.yunzhi.demo.service.ISysBannerService;
8 10
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
11
+import com.yunzhi.demo.vo.SortParams;
12
+import org.springframework.beans.factory.annotation.Autowired;
9 13
 import org.springframework.stereotype.Service;
10 14
 
11 15
 import java.util.List;
@@ -21,6 +25,9 @@ import java.util.List;
21 25
 @Service
22 26
 public class SysBannerServiceImpl extends ServiceImpl<SysBannerMapper, SysBanner> implements ISysBannerService {
23 27
 
28
+    @Autowired
29
+    SysBannerMapper sysBannerMapper;
30
+
24 31
     @Override
25 32
     public List<SysBanner> getIndexList() {
26 33
         QueryWrapper<SysBanner> queryWrapper = new QueryWrapper<SysBanner>()
@@ -28,4 +35,28 @@ public class SysBannerServiceImpl extends ServiceImpl<SysBannerMapper, SysBanner
28 35
                 .orderByAsc("sort_no");
29 36
         return list(queryWrapper);
30 37
     }
38
+
39
+    @Override
40
+    public void reSort(SortParams sortParams) {
41
+        if (sortParams.getFrom().equals(sortParams.getTo())) {
42
+            return;
43
+        }
44
+
45
+        SysBanner from = getById(sortParams.getFrom());
46
+        SysBanner to = getById(sortParams.getTo());
47
+
48
+        Integer source = from.getSortNo();
49
+        Integer target = to.getSortNo();
50
+
51
+        if (source > target) {
52
+            sysBannerMapper.bannerSortAdd(source, target);
53
+        } else {
54
+            sysBannerMapper.bannerSortSub(source, target);
55
+        }
56
+
57
+        UpdateWrapper<SysBanner> updateWrapper = new UpdateWrapper<SysBanner>()
58
+                .set("sort_no", target)
59
+                .eq("serial_no", sortParams.getFrom());
60
+        update(updateWrapper);
61
+    }
31 62
 }

+ 1
- 1
src/main/java/com/yunzhi/demo/service/impl/TaPointsLogServiceImpl.java 查看文件

@@ -75,7 +75,7 @@ public class TaPointsLogServiceImpl extends ServiceImpl<TaPointsLogMapper, TaPoi
75 75
             e.printStackTrace();
76 76
 
77 77
             log.error(String.format("奖励[%s-%s] 阅读[%s-%s] 积分 %d 失败: %s",
78
-                    StringUtils.ifNull(taPerson.getName(), taPerson.getNickName()),
78
+                    taPerson.getNickName(),
79 79
                     taPerson.getPersonId(),
80 80
                     taPost.getName(),
81 81
                     taPost.getPostId(),

+ 89
- 0
src/main/java/com/yunzhi/demo/service/impl/TaStudentServiceImpl.java 查看文件

@@ -0,0 +1,89 @@
1
+package com.yunzhi.demo.service.impl;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
6
+import com.yunzhi.demo.common.Constants;
7
+import com.yunzhi.demo.common.StringUtils;
8
+import com.yunzhi.demo.entity.TaStudent;
9
+import com.yunzhi.demo.mapper.TaStudentMapper;
10
+import com.yunzhi.demo.service.ITaStudentService;
11
+import com.yunzhi.demo.vo.StatisPerson;
12
+import org.springframework.beans.factory.annotation.Autowired;
13
+import org.springframework.stereotype.Service;
14
+
15
+/**
16
+ * <p>
17
+ * 人员 服务实现类
18
+ * </p>
19
+ *
20
+ * @author yansen
21
+ * @since 2021-04-15
22
+ */
23
+@Service
24
+public class TaStudentServiceImpl extends ServiceImpl<TaStudentMapper, TaStudent> implements ITaStudentService {
25
+
26
+    @Autowired
27
+    TaStudentMapper taStudentMapper;
28
+
29
+    @Override
30
+    public int countStudent() {
31
+        QueryWrapper<TaStudent> queryWrapper = new QueryWrapper<TaStudent>()
32
+                .gt("status", Constants.STATUS_DELETED);
33
+        return count(queryWrapper);
34
+    }
35
+
36
+    @Override
37
+    public IPage<StatisPerson> getStudentStatis(IPage<StatisPerson> pg, String name, String schoolId, String specialtyId, String asc, String desc) {
38
+        if (StringUtils.isEmpty(asc) && StringUtils.isEmpty(desc)) {
39
+            desc = "readedNum";
40
+        }
41
+        return taStudentMapper.getStudentStatis(pg, name, schoolId, specialtyId, getDBFieldBy(asc), getDBFieldBy(desc));
42
+    }
43
+
44
+    @Override
45
+    public IPage<TaStudent> getStudentInfoPagedBy(IPage<TaStudent> pg, String name, String schoolId, String specialtyId, String phone, String studentNo) {
46
+        return taStudentMapper.getStudentInfoPagedBy(pg, name, schoolId, specialtyId, phone, studentNo);
47
+    }
48
+
49
+    @Override
50
+    public TaStudent getByStudentNo(String studentNo) {
51
+        QueryWrapper<TaStudent> queryWrapper = new QueryWrapper<TaStudent>()
52
+                .eq("student_no", studentNo)
53
+                .gt("status", Constants.STATUS_DELETED);
54
+        return getOne(queryWrapper);
55
+    }
56
+
57
+    @Override
58
+    public TaStudent getByPersonId(String personId) {
59
+        QueryWrapper<TaStudent> queryWrapper = new QueryWrapper<TaStudent>()
60
+                .eq("person_id", personId)
61
+                .gt("status", Constants.STATUS_DELETED);
62
+        return getOne(queryWrapper);
63
+    }
64
+
65
+    @Override
66
+    public TaStudent getByPhone(String phone) {
67
+        QueryWrapper<TaStudent> queryWrapper = new QueryWrapper<TaStudent>()
68
+                .eq("phone", phone)
69
+                .gt("status", Constants.STATUS_DELETED);
70
+        return getOne(queryWrapper);
71
+    }
72
+
73
+    private String getDBFieldBy(String name) {
74
+        if (StringUtils.isEmpty(name)) {
75
+            return null;
76
+        }
77
+
78
+        switch (name.toLowerCase()) {
79
+            case "readedNum":
80
+                return "readed_num";
81
+            case "creditNum":
82
+                return "credit_num";
83
+            case "pointNum":
84
+                return "point_num";
85
+            default:
86
+                return "saved_num";
87
+        }
88
+    }
89
+}

+ 2
- 2
src/main/java/com/yunzhi/demo/vo/StatisPerson.java 查看文件

@@ -1,13 +1,13 @@
1 1
 package com.yunzhi.demo.vo;
2 2
 
3
-import com.yunzhi.demo.entity.TaPerson;
3
+import com.yunzhi.demo.entity.TaStudent;
4 4
 import io.swagger.annotations.ApiModel;
5 5
 import io.swagger.annotations.ApiModelProperty;
6 6
 import lombok.Data;
7 7
 
8 8
 @ApiModel(description = "学生统计")
9 9
 @Data
10
-public class StatisPerson extends TaPerson {
10
+public class StatisPerson extends TaStudent {
11 11
 
12 12
     @ApiModelProperty(value = "积分")
13 13
     private Integer pointNum;

+ 16
- 0
src/main/resources/mapper/SysBannerMapper.xml 查看文件

@@ -2,4 +2,20 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.yunzhi.demo.mapper.SysBannerMapper">
4 4
 
5
+    <update id="bannerSortAdd">
6
+        UPDATE sys_banner
7
+        SET sort_no = sort_no + 1
8
+        WHERE
9
+            `status` > - 1
10
+          AND sort_no &gt;= #{min}
11
+          AND sort_no &lt; #{max}
12
+    </update>
13
+    <update id="bannerSortSub">
14
+        UPDATE sys_banner
15
+        SET sort_no = sort_no - 1
16
+        WHERE
17
+            `status` > - 1
18
+          AND sort_no &gt; #{min}
19
+          AND sort_no &lt;= #{max}
20
+    </update>
5 21
 </mapper>

+ 63
- 0
src/main/resources/mapper/TaStudentMapper.xml 查看文件

@@ -0,0 +1,63 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.yunzhi.demo.mapper.TaStudentMapper">
4
+
5
+    <select id="getStudentStatis" resultType="com.yunzhi.demo.vo.StatisPerson">
6
+        SELECT
7
+            t.*,
8
+            s.credit_num,
9
+            s.point_num,
10
+            s.readed_num,
11
+            s.saved_num
12
+        FROM
13
+            ta_student t
14
+                INNER JOIN ta_person_data s ON t.person_id = s.person_id
15
+        WHERE t.`status` > - 1
16
+        <if test="name != null and name != ''">
17
+            AND t.`name` LIKE CONCAT('%', #{name}, '%')
18
+        </if>
19
+        <if test="schoolId != null and schoolId != ''">
20
+            AND t.school_id = #{schoolId}
21
+        </if>
22
+        <if test="specialtyId != null and specialtyId != ''">
23
+          AND t.specialty_id = #{specialtyId}
24
+        </if>
25
+        ORDER BY
26
+        <if test="asc != null and asc != ''">
27
+            ${asc} ASC
28
+        </if>
29
+        <if test="desc != null and desc != ''">
30
+            ${desc} DESC
31
+        </if>
32
+    </select>
33
+
34
+    <select id="getStudentInfoPagedBy" resultType="com.yunzhi.demo.entity.TaStudent">
35
+        SELECT
36
+            t.*,
37
+            s.`name` AS school_name,
38
+            m.`name` AS specialty_name
39
+        FROM
40
+            ta_student t
41
+                INNER JOIN td_school s ON t.school_id = s.school_id
42
+                INNER JOIN td_specialty m ON t.specialty_id = m.specialty_id
43
+        WHERE
44
+            t.`status` > - 1
45
+        <if test="name != null and name != ''">
46
+          AND t.`name` LIKE CONCAT( '%', #{name}, '%' )
47
+        </if>
48
+        <if test="phone != null and phone != ''">
49
+          AND t.phone LIKE CONCAT( '%', #{phone}, '%' )
50
+        </if>
51
+        <if test="studentNo != null and studentNo != ''">
52
+          AND t.student_no = LIKE CONCAT( '%', #{studentNo}, '%' )
53
+        </if>
54
+        <if test="schoolId != null and schoolId != ''">
55
+          AND t.school_id = #{schoolId}
56
+        </if>
57
+        <if test="specialtyId != null and specialtyId != ''">
58
+          AND t.specialty_id = #{specialtyId}
59
+        </if>
60
+        ORDER BY
61
+            t.create_date DESC
62
+    </select>
63
+</mapper>