UserController.java 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. package com.ym.mec.collectfee.controller;
  2. import com.ym.mec.collectfee.common.web.BaseController;
  3. import com.ym.mec.collectfee.entity.ApplyInfo;
  4. import com.ym.mec.collectfee.entity.MusicTeamsPageInfo;
  5. import com.ym.mec.collectfee.entity.School;
  6. import com.ym.mec.collectfee.entity.StudentsQueryInfo;
  7. import com.ym.mec.collectfee.service.ApplyInfoService;
  8. import com.ym.mec.collectfee.service.CourseGroupInfoService;
  9. import com.ym.mec.collectfee.service.OrderService;
  10. import com.ym.mec.collectfee.service.SchoolService;
  11. import com.ym.mec.collectfee.utils.Constants;
  12. import org.apache.commons.lang3.StringUtils;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.dao.DuplicateKeyException;
  15. import org.springframework.web.bind.annotation.*;
  16. import java.util.Date;
  17. @RestController()
  18. @RequestMapping("user")
  19. //@Api("用户服务")
  20. public class UserController extends BaseController {
  21. @Autowired
  22. private ApplyInfoService applyInfoService;
  23. @Autowired
  24. private SchoolService schoolService;
  25. @Autowired
  26. private OrderService orderService;
  27. @Autowired
  28. private CourseGroupInfoService courseGroupInfoService;
  29. /**
  30. * 查询用户详情
  31. * @param phone
  32. * @param clazzId
  33. * @return
  34. */
  35. @GetMapping("/getUserDetailByPhone")
  36. // @ApiOperation(value = "根据乐团编号、用户手机,查询用户详情")
  37. // @ApiImplicitParams({ @ApiImplicitParam(name = "phone", value = "用户手机", required = true, dataType = "String"),
  38. // @ApiImplicitParam(name = "clazzId", value = "乐团编号", required = true, dataType = "Integer")})
  39. public Object getUserDetailByPhone(String phone,Integer clazzId){
  40. if(StringUtils.isEmpty(phone) || clazzId == null){
  41. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  42. }
  43. if(applyInfoService.mecUserIsExist(phone)){
  44. return failed(Constants.PARAM_EXIST_ERROR_MSG);
  45. }
  46. ApplyInfo userByPhone = applyInfoService.findUserByPhone(phone, null);
  47. if(userByPhone != null && !userByPhone.getClassId().equals(clazzId)){//如果改用户存在其他团中
  48. return failed(Constants.PARAM_EXIST_ERROR_MSG);
  49. }
  50. School school = schoolService.get(clazzId);
  51. if(userByPhone != null){
  52. userByPhone.setPushStatus(school.getStatus());
  53. }
  54. return succeed(userByPhone);
  55. }
  56. /**
  57. * 用户报名
  58. * @param applyInfo
  59. * @return
  60. */
  61. // @ApiOperation(value = "学生报名乐团")
  62. @PostMapping("/userApply")
  63. public Object userApply(ApplyInfo applyInfo){
  64. if(applyInfo != null){
  65. try {
  66. Date date = new Date();
  67. applyInfo.setCreateTime(date);
  68. applyInfo.setUpdateTime(date);
  69. applyInfoService.insert(applyInfo);
  70. return succeed(applyInfo.getId());
  71. }catch (Exception e){
  72. e.printStackTrace();
  73. if(e instanceof DuplicateKeyException){
  74. return failed("该用户已存在");
  75. }
  76. return failed("报名失败");
  77. }
  78. }
  79. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  80. }
  81. /**
  82. * 根据乐团id获取乐团详情,查询乐团状态也通过该接口
  83. * @param clazzId
  84. * @return
  85. */
  86. // @ApiOperation(value = "根据乐团编号获取乐团详情,查询乐团状态也通过该接口")
  87. @PostMapping("/getClassDetail")
  88. // @ApiImplicitParams({ @ApiImplicitParam(name = "clazzId", value = "乐团编号", required = true, dataType = "Integer"),
  89. // @ApiImplicitParam(name = "schoolId", value = "学校编号", required = true, dataType = "Integer")})
  90. public Object getSchoolDetail(Integer schoolId,Integer clazzId){
  91. if(schoolId == null || clazzId == null){
  92. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  93. }
  94. return succeed(orderService.getSchoolDetail(schoolId,clazzId));
  95. }
  96. /**
  97. * 根据学生编号获取乐团注册页面数据
  98. * @param stuId
  99. * @return
  100. */
  101. // @ApiOperation(value = "根据学生编号获取乐团注册页面数据")
  102. @PostMapping("/getUserRegisterViewDetail")
  103. public Object getUserRegisterViewDetail(Integer stuId){
  104. if(stuId == null){
  105. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  106. }
  107. return succeed(applyInfoService.getUserRegisterViewDetail(stuId));
  108. }
  109. /**
  110. * 推送用户到mec注册
  111. * @return
  112. */
  113. /*@PostMapping("/userRegister")
  114. public Object userRegister(String phone){
  115. return succeed(applyInfoService.userRegister(phone));
  116. }*/
  117. /**
  118. * 获取乐团课程组列表
  119. * @return
  120. */
  121. @PostMapping("/getCourses")
  122. // @ApiOperation(value = "根据乐团编号,获取乐团课程组列表")
  123. // @ApiImplicitParams({ @ApiImplicitParam(name = "clazzId", value = "乐团编号", required = true, dataType = "Integer")})
  124. public Object getCourses(Integer clazzId){
  125. if(clazzId == null){
  126. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  127. }
  128. return succeed(courseGroupInfoService.getCourses(clazzId));
  129. }
  130. // @ApiOperation(value = "获取所有乐团列表")
  131. @PostMapping("/getMusicTeams")
  132. public Object getMusicTeams(MusicTeamsPageInfo pageInfo){
  133. return succeed(schoolService.queryPage(pageInfo));
  134. }
  135. // @ApiOperation(value = "根据乐团编号,获取学员列表")
  136. @PostMapping("/getMusicTeamStu")
  137. public Object getMusicTeamStu(StudentsQueryInfo queryInfo){
  138. return succeed(applyInfoService.queryUserPage(queryInfo));
  139. }
  140. // @ApiOperation(value = "获取所有分部列表")
  141. @GetMapping("/getBranches")
  142. public Object getBranches(){
  143. return succeed(applyInfoService.getBranches());
  144. }
  145. // @ApiOperation(value = "获取学校详情")
  146. @GetMapping("/getSchool")
  147. public Object getSchool(Integer schoolId){
  148. if(schoolId == null){
  149. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  150. }
  151. return succeed(applyInfoService.get(schoolId));
  152. }
  153. /**
  154. * 保存学校列表
  155. * @return
  156. */
  157. // @GetMapping("/saveSeminary")
  158. // public Object saveSeminary(){
  159. // applyInfoService.saveSeminary();
  160. // return succeed();
  161. // }
  162. /**
  163. * 修改乐团信息
  164. * @return
  165. */
  166. // @ApiOperation(value = "修改乐团信息")
  167. @PostMapping("/updateClass")
  168. public Object updateClass(School school){
  169. school.setUpdateTime(new Date());
  170. schoolService.update(school);
  171. return succeed();
  172. }
  173. /**
  174. * 开启乐团缴费功能
  175. * @return
  176. */
  177. // @ApiOperation(value = "开启乐团缴费功能")
  178. @PostMapping("/openClassPay")
  179. public Object openClassPay(Integer id){
  180. if(id == null){
  181. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  182. }
  183. schoolService.openClassPay(id);
  184. return succeed();
  185. }
  186. /**
  187. * 修改学生信息
  188. * @return
  189. */
  190. // @ApiOperation(value = "修改学生信息")
  191. @PostMapping("/updateUser")
  192. public Object updateUser(@ModelAttribute ApplyInfo applyInfo){
  193. applyInfo.setUpdateTime(new Date());
  194. applyInfoService.update(applyInfo);
  195. return succeed("修改成功");
  196. }
  197. /**
  198. * 修改学生信息
  199. * @return
  200. */
  201. // @ApiOperation(value = "批量调剂学员专业")
  202. @PostMapping("/updateUserSub")
  203. public Object updateUserSub(String userId,Integer subId,Integer courseId){
  204. if(StringUtils.isEmpty(userId) || subId == null || courseId == null){
  205. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  206. }
  207. applyInfoService.updateUserSub(userId,subId,courseId);
  208. return succeed("修改成功");
  209. }
  210. // @ApiOperation(value = "学员课程班查询,本接口用于查询指定学员报名的课程班(小课或乐团)列表")
  211. @PostMapping("/queryUserCourse")
  212. // @ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "用户编号", required = true, dataType = "Integer")})
  213. public Object queryUserCourse(Integer userId){
  214. if(userId == null){
  215. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  216. }
  217. return succeed(applyInfoService.queryUserCourse(userId));
  218. }
  219. /**
  220. * 推送学生续费成功的订单数据到mec
  221. * @return
  222. */
  223. // @PostMapping("/pushRenew")
  224. // public Object pushRenew(RenewBean renewBean){
  225. // applyInfoService.pushRenew(renewBean);
  226. // return succeed();
  227. // }
  228. /**
  229. * 查询mec用户信息
  230. * @return
  231. */
  232. @PostMapping("/findMecUser")
  233. public Object findMecUser(Integer userId){
  234. if(userId == null){
  235. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  236. }
  237. return succeed(applyInfoService.findMecUser(userId));
  238. }
  239. @PostMapping("/mecUserIsExist")
  240. public Object mecUserIsExist(String phone){
  241. return succeed(applyInfoService.mecUserIsExist(phone));
  242. }
  243. }