|
@@ -5,6 +5,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
5
|
5
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
6
|
6
|
import com.yunzhi.training.common.BaseController;
|
7
|
7
|
import com.yunzhi.training.common.ResponseBean;
|
|
8
|
+import com.yunzhi.training.common.StringUtils;
|
|
9
|
+import com.yunzhi.training.entity.TaSignIn;
|
|
10
|
+import com.yunzhi.training.entity.TaStudent;
|
|
11
|
+import com.yunzhi.training.service.ITaSignInService;
|
8
|
12
|
import io.swagger.annotations.Api;
|
9
|
13
|
import io.swagger.annotations.ApiOperation;
|
10
|
14
|
import io.swagger.annotations.ApiParam;
|
|
@@ -20,6 +24,9 @@ import com.yunzhi.training.service.ITaSignPlainService;
|
20
|
24
|
import com.yunzhi.training.entity.TaSignPlain;
|
21
|
25
|
import org.springframework.web.bind.annotation.RestController;
|
22
|
26
|
|
|
27
|
+import java.util.ArrayList;
|
|
28
|
+import java.util.List;
|
|
29
|
+
|
23
|
30
|
/**
|
24
|
31
|
* <p>
|
25
|
32
|
* 预签到人员 前端控制器
|
|
@@ -39,6 +46,9 @@ public class TaSignPlainController extends BaseController {
|
39
|
46
|
@Autowired
|
40
|
47
|
public ITaSignPlainService iTaSignPlainService;
|
41
|
48
|
|
|
49
|
+ @Autowired
|
|
50
|
+ public ITaSignInService iTaSignInService;
|
|
51
|
+
|
42
|
52
|
|
43
|
53
|
/**
|
44
|
54
|
* 分页查询列表
|
|
@@ -46,17 +56,27 @@ public class TaSignPlainController extends BaseController {
|
46
|
56
|
* @param pageSize
|
47
|
57
|
* @return
|
48
|
58
|
*/
|
49
|
|
- @RequestMapping(value="/taSignPlain",method= RequestMethod.GET)
|
|
59
|
+ @RequestMapping(value="/admin/sign-plain",method= RequestMethod.GET)
|
50
|
60
|
@ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
|
51
|
61
|
public ResponseBean taSignPlainList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
52
|
|
- @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
|
|
62
|
+ @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
|
|
63
|
+ @ApiParam("签到") @RequestParam(value ="signId") String signId,
|
|
64
|
+ @ApiParam("学期") @RequestParam(value ="termId", required = false) String termId,
|
|
65
|
+ @ApiParam("班级") @RequestParam(value ="classId", required = false) String classId,
|
|
66
|
+ @ApiParam("姓名") @RequestParam(value ="name", required = false) String name,
|
|
67
|
+ @ApiParam("手机号") @RequestParam(value ="phone", required = false) String phone) throws Exception{
|
53
|
68
|
|
54
|
|
- IPage<TaSignPlain> pg = new Page<>(pageNum, pageSize);
|
55
|
|
- QueryWrapper<TaSignPlain> queryWrapper = new QueryWrapper<>();
|
56
|
|
- queryWrapper.orderByDesc("create_date");
|
|
69
|
+ IPage<TaSignPlain> pg = new Page<>(pageNum, pageSize);
|
|
70
|
+ QueryWrapper<TaSignPlain> queryWrapper = new QueryWrapper<>();
|
|
71
|
+ queryWrapper.eq("sign_id", signId);
|
|
72
|
+ queryWrapper.eq(!StringUtils.isEmpty(termId), "term_id", termId);
|
|
73
|
+ queryWrapper.eq(!StringUtils.isEmpty(classId), "class_id", classId);
|
|
74
|
+ queryWrapper.like(!StringUtils.isEmpty(name), "name", "%"+name+"%");
|
|
75
|
+ queryWrapper.like(!StringUtils.isEmpty(phone), "phone", "%"+phone+"%");
|
|
76
|
+ queryWrapper.orderByDesc("create_date");
|
57
|
77
|
|
58
|
|
- IPage<TaSignPlain> result = iTaSignPlainService.page(pg, queryWrapper);
|
59
|
|
- return ResponseBean.success(result);
|
|
78
|
+ IPage<TaSignPlain> result = iTaSignPlainService.page(pg, queryWrapper);
|
|
79
|
+ return ResponseBean.success(result);
|
60
|
80
|
}
|
61
|
81
|
|
62
|
82
|
/**
|
|
@@ -64,12 +84,36 @@ public class TaSignPlainController extends BaseController {
|
64
|
84
|
* @param taSignPlain 实体对象
|
65
|
85
|
* @return
|
66
|
86
|
*/
|
67
|
|
- @RequestMapping(value="/taSignPlain",method= RequestMethod.POST)
|
|
87
|
+ @RequestMapping(value="/admin/sign-plain/{signId}/with-students",method= RequestMethod.POST)
|
68
|
88
|
@ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
|
69
|
|
- public ResponseBean taSignPlainAdd(@ApiParam("保存内容") @RequestBody TaSignPlain taSignPlain) throws Exception{
|
|
89
|
+ public ResponseBean taSignPlainAdd(@ApiParam("签到ID") @PathVariable String signId,
|
|
90
|
+ @ApiParam("保存内容") @RequestBody List<TaStudent> studentList) throws Exception{
|
70
|
91
|
|
71
|
|
- if (iTaSignPlainService.save(taSignPlain)){
|
72
|
|
- return ResponseBean.success(taSignPlain);
|
|
92
|
+ TaSignIn taSignIn = iTaSignInService.getExistBy("sign_id", signId, false, true);
|
|
93
|
+ if (null == taSignIn) {
|
|
94
|
+ return ResponseBean.error("当前签到不存在", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
95
|
+ }
|
|
96
|
+
|
|
97
|
+ if (null == studentList || studentList.size() < 1) {
|
|
98
|
+ return ResponseBean.error("签到人员池为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
99
|
+ }
|
|
100
|
+
|
|
101
|
+ List<TaSignPlain> signPlains = new ArrayList<>();
|
|
102
|
+ for(TaStudent student : studentList) {
|
|
103
|
+ TaSignPlain signPlain = new TaSignPlain();
|
|
104
|
+ signPlain.setSignId(signId);
|
|
105
|
+ signPlain.setPersonId(student.getPersonId());
|
|
106
|
+ signPlain.setStudentId(student.getStudentId());
|
|
107
|
+ signPlain.setTermId(student.getTermId());
|
|
108
|
+ signPlain.setClassId(student.getClassId());
|
|
109
|
+ signPlain.setName(student.getName());
|
|
110
|
+ signPlain.setPhone(student.getPhone());
|
|
111
|
+ signPlains.add(signPlain);
|
|
112
|
+ }
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+ if (iTaSignPlainService.saveBatch(signPlains)){
|
|
116
|
+ return ResponseBean.success("success");
|
73
|
117
|
}else {
|
74
|
118
|
return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
75
|
119
|
}
|
|
@@ -77,43 +121,43 @@ public class TaSignPlainController extends BaseController {
|
77
|
121
|
|
78
|
122
|
/**
|
79
|
123
|
* 根据id删除对象
|
80
|
|
- * @param id 实体ID
|
|
124
|
+ * @param signId 实体ID
|
81
|
125
|
*/
|
82
|
|
- @RequestMapping(value="/taSignPlain/{id}", method= RequestMethod.DELETE)
|
|
126
|
+ @RequestMapping(value="/admin/sign-plain/{signId}", method= RequestMethod.DELETE)
|
83
|
127
|
@ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
|
84
|
|
- public ResponseBean taSignPlainDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
85
|
|
- if(iTaSignPlainService.removeById(id)){
|
|
128
|
+ public ResponseBean taSignPlainDelete(@ApiParam("签到ID") @PathVariable String signId) throws Exception{
|
|
129
|
+ if(iTaSignPlainService.removeBySignId(signId)){
|
86
|
130
|
return ResponseBean.success("success");
|
87
|
131
|
}else {
|
88
|
132
|
return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
89
|
133
|
}
|
90
|
134
|
}
|
91
|
135
|
|
92
|
|
- /**
|
93
|
|
- * 修改对象
|
94
|
|
- * @param id 实体ID
|
95
|
|
- * @param taSignPlain 实体对象
|
96
|
|
- * @return
|
97
|
|
- */
|
98
|
|
- @RequestMapping(value="/taSignPlain/{id}",method= RequestMethod.PUT)
|
99
|
|
- @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
|
100
|
|
- public ResponseBean taSignPlainUpdate(@ApiParam("对象ID") @PathVariable Integer id,
|
101
|
|
- @ApiParam("更新内容") @RequestBody TaSignPlain taSignPlain) throws Exception{
|
|
136
|
+// /**
|
|
137
|
+// * 修改对象
|
|
138
|
+// * @param id 实体ID
|
|
139
|
+// * @param taSignPlain 实体对象
|
|
140
|
+// * @return
|
|
141
|
+// */
|
|
142
|
+// @RequestMapping(value="/taSignPlain/{id}",method= RequestMethod.PUT)
|
|
143
|
+// @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
|
|
144
|
+// public ResponseBean taSignPlainUpdate(@ApiParam("对象ID") @PathVariable Integer id,
|
|
145
|
+// @ApiParam("更新内容") @RequestBody TaSignPlain taSignPlain) throws Exception{
|
|
146
|
+//
|
|
147
|
+// if (iTaSignPlainService.updateById(taSignPlain)){
|
|
148
|
+// return ResponseBean.success(iTaSignPlainService.getById(id));
|
|
149
|
+// }else {
|
|
150
|
+// return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
151
|
+// }
|
|
152
|
+// }
|
102
|
153
|
|
103
|
|
- if (iTaSignPlainService.updateById(taSignPlain)){
|
104
|
|
- return ResponseBean.success(iTaSignPlainService.getById(id));
|
105
|
|
- }else {
|
106
|
|
- return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
107
|
|
- }
|
108
|
|
- }
|
109
|
|
-
|
110
|
|
- /**
|
111
|
|
- * 根据id查询对象
|
112
|
|
- * @param id 实体ID
|
113
|
|
- */
|
114
|
|
- @RequestMapping(value="/taSignPlain/{id}",method= RequestMethod.GET)
|
115
|
|
- @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
|
116
|
|
- public ResponseBean taSignPlainGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
117
|
|
- return ResponseBean.success(iTaSignPlainService.getById(id));
|
118
|
|
- }
|
|
154
|
+// /**
|
|
155
|
+// * 根据id查询对象
|
|
156
|
+// * @param id 实体ID
|
|
157
|
+// */
|
|
158
|
+// @RequestMapping(value="/taSignPlain/{id}",method= RequestMethod.GET)
|
|
159
|
+// @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
|
|
160
|
+// public ResponseBean taSignPlainGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
|
|
161
|
+// return ResponseBean.success(iTaSignPlainService.getById(id));
|
|
162
|
+// }
|
119
|
163
|
}
|