|
@@ -0,0 +1,127 @@
|
|
|
+package com.ssj.api.controller;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.ssj.api.domain.vo.merchant.ServiceVo;
|
|
|
+import com.ssj.api.domain.vo.teacher.teacherAddReq;
|
|
|
+import com.ssj.api.domain.vo.teacher.teacherDelReq;
|
|
|
+import com.ssj.api.domain.vo.teacher.teacherReq;
|
|
|
+import com.ssj.api.security.annotation.IgnoreSecurity;
|
|
|
+import com.ssj.bean.sys.fx.domain.Merchant;
|
|
|
+import com.ssj.bean.sys.imlibuser.TbClassTeacherTemp;
|
|
|
+import com.ssj.bean.weixin.libmy.domain.TbLibManager;
|
|
|
+import com.ssj.framework.core.common.controller.BaseController;
|
|
|
+import com.ssj.framework.core.util.ResponseConstant;
|
|
|
+import com.ssj.framework.core.util.ResponseEntity;
|
|
|
+import com.ssj.service.sys.fx.service.MerchantService;
|
|
|
+import com.ssj.service.sys.homework.service.HomeworkPictureService;
|
|
|
+import com.ssj.service.sys.imlibuser.service.TbClassTeacherTempService;
|
|
|
+import com.ssj.service.weixin.library.service.IBookManagerService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.text.DateFormat;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+@Api(value = "平台批改老师相关", tags = "平台批改老师相关")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/teacher")
|
|
|
+public class ApiManagerTeacherController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IBookManagerService managerService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private HomeworkPictureService pictureService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TbClassTeacherTempService tbLibImTeacherTempService;
|
|
|
+
|
|
|
+
|
|
|
+ @RequestMapping(value = "/list", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "获取平台批改老师列表接口", notes = "获取平台批改老师列表接口")
|
|
|
+ public ResponseEntity list(@RequestParam(name = "accessToken") String accessToken,@RequestBody teacherReq req) {
|
|
|
+ ResponseEntity responseEntity = new ResponseEntity();
|
|
|
+ Map<String,Object> data=new HashMap<>(2);
|
|
|
+ Map<String,Object> params=new HashMap<>(2);
|
|
|
+ try {
|
|
|
+ params.put("type",30);
|
|
|
+ params.put("name",req.getName());
|
|
|
+ params.put("mobile",req.getMobile());
|
|
|
+ Page<Map<String,Object>> list = managerService.findTeacherManagerList(params,initPage(req.getPageNo(),req.getPageSize()));
|
|
|
+ data.put("list",list.getContent());
|
|
|
+ data.put("totalNums",list.getTotalElements());
|
|
|
+ responseEntity.success(data,"获取平台批改老师列表成功!");
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("获取平台批改老师列表接口", e);
|
|
|
+ responseEntity.failure(ResponseConstant.CODE_500, "系统繁忙,请稍后重试");
|
|
|
+ }
|
|
|
+ logger.info("第三方调用接口【/open/api/teacher/list】,返回结果:"+JSONObject.toJSONString(responseEntity));
|
|
|
+ return responseEntity;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @RequestMapping(value = "/delTeacher", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "注销平台批改老师接口", notes = "注销平台批改老师接口")
|
|
|
+ public ResponseEntity delTeacher(@RequestParam(name = "accessToken") String accessToken,@RequestBody teacherDelReq req) {
|
|
|
+ ResponseEntity responseEntity = new ResponseEntity();
|
|
|
+ try {
|
|
|
+ //查询老师是否有作业未批改
|
|
|
+ String userId = tokenManager.getUserId(accessToken);
|
|
|
+
|
|
|
+ TbLibManager manager = managerService.getById(req.getId());
|
|
|
+ if(Objects.isNull(manager)){
|
|
|
+ responseEntity.failure(ResponseConstant.CODE_000, "此老师数据不存在,请检查传参!");
|
|
|
+ return responseEntity;
|
|
|
+ }
|
|
|
+
|
|
|
+ long count = pictureService.countByTeacherIdAndIsFeedback(manager.getUserId(),0);
|
|
|
+ if(count >0){
|
|
|
+ responseEntity.failure(ResponseConstant.CODE_000, "此老师有作业未批改完不能注销!");
|
|
|
+ return responseEntity;
|
|
|
+ }
|
|
|
+
|
|
|
+ manager.setState(2);
|
|
|
+ managerService.save(manager);
|
|
|
+ //登录状态失效
|
|
|
+ tokenManager.delToken(manager.getUserId());
|
|
|
+ responseEntity.success("注销成功!");
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("获取平台批改老师列表接口", e);
|
|
|
+ responseEntity.failure(ResponseConstant.CODE_500, "系统繁忙,请稍后重试");
|
|
|
+ }
|
|
|
+ logger.info("第三方调用接口【/open/api/teacher/delTeacher】,返回结果:"+JSONObject.toJSONString(responseEntity));
|
|
|
+ return responseEntity;
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/addTeacher", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "添加平台批改老师接口", notes = "添加平台批改老师接口")
|
|
|
+ public ResponseEntity addTeacher(@RequestParam(name = "accessToken") String accessToken,@RequestBody teacherAddReq req) {
|
|
|
+ ResponseEntity responseEntity = new ResponseEntity();
|
|
|
+ try {
|
|
|
+ TbClassTeacherTemp tbLibImTeacherTemp=new TbClassTeacherTemp();
|
|
|
+ tbLibImTeacherTemp.setLeagueName("平台批改老师");
|
|
|
+ tbLibImTeacherTemp.setTeacherName(req.getName());
|
|
|
+ tbLibImTeacherTemp.setTeacherPhone(req.getMobile());
|
|
|
+ tbLibImTeacherTemp.setSubject(req.getCourseName());
|
|
|
+ tbLibImTeacherTemp.setIsCorrect(1);
|
|
|
+ List<TbClassTeacherTemp> list = new ArrayList<>();
|
|
|
+ list.add(tbLibImTeacherTemp);
|
|
|
+ int num = tbLibImTeacherTempService.insertBatchTbAllImTeacher(list);
|
|
|
+ if(num<1){
|
|
|
+ responseEntity.failure(ResponseConstant.CODE_000, list.get(0).getErrorReason());
|
|
|
+ return responseEntity;
|
|
|
+ }
|
|
|
+ responseEntity.success("添加成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("添加平台批改老师接口", e);
|
|
|
+ responseEntity.failure(ResponseConstant.CODE_500, "系统繁忙,请稍后重试");
|
|
|
+ }
|
|
|
+ logger.info("第三方调用接口【/open/api/teacher/addTeacher】,返回结果:"+JSONObject.toJSONString(responseEntity));
|
|
|
+ return responseEntity;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|