123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- package com.ym.mec.collectfee.controller;
- import com.ym.mec.collectfee.common.web.BaseController;
- import com.ym.mec.collectfee.entity.ApplyInfo;
- import com.ym.mec.collectfee.entity.MusicTeamsPageInfo;
- import com.ym.mec.collectfee.entity.School;
- import com.ym.mec.collectfee.entity.StudentsQueryInfo;
- import com.ym.mec.collectfee.service.ApplyInfoService;
- import com.ym.mec.collectfee.service.CourseGroupInfoService;
- import com.ym.mec.collectfee.service.OrderService;
- import com.ym.mec.collectfee.service.SchoolService;
- import com.ym.mec.collectfee.utils.Constants;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.dao.DuplicateKeyException;
- import org.springframework.web.bind.annotation.*;
- import java.util.Date;
- @RestController()
- @RequestMapping("user")
- //@Api("用户服务")
- public class UserController extends BaseController {
- @Autowired
- private ApplyInfoService applyInfoService;
- @Autowired
- private SchoolService schoolService;
- @Autowired
- private OrderService orderService;
- @Autowired
- private CourseGroupInfoService courseGroupInfoService;
- /**
- * 查询用户详情
- * @param phone
- * @param clazzId
- * @return
- */
- @GetMapping("/getUserDetailByPhone")
- // @ApiOperation(value = "根据乐团编号、用户手机,查询用户详情")
- // @ApiImplicitParams({ @ApiImplicitParam(name = "phone", value = "用户手机", required = true, dataType = "String"),
- // @ApiImplicitParam(name = "clazzId", value = "乐团编号", required = true, dataType = "Integer")})
- public Object getUserDetailByPhone(String phone,Integer clazzId,Integer cityId){
- if(StringUtils.isEmpty(phone) || clazzId == null || cityId == null){
- return failed(Constants.PARAM_VERIFY_ERROR_MSG);
- }
- if(applyInfoService.mecUserIsExist(phone)){
- return failed(Constants.PARAM_EXIST_ERROR_MSG);
- }
- ApplyInfo userByPhone = applyInfoService.findUserByPhone(phone, null);
- if(userByPhone != null && !userByPhone.getClassId().equals(clazzId)){//如果改用户存在其他团中
- return failed(Constants.PARAM_EXIST_ERROR_MSG);
- }
- School school = schoolService.get(clazzId);
- if(school != null){
- if(school.getCityId() == null){
- school.setCityId(cityId);
- school.setUpdateTime(new Date());
- schoolService.update(school);
- }
- if(userByPhone != null){
- userByPhone.setPushStatus(school.getStatus());
- }
- }
- return succeed(userByPhone);
- }
- /**
- * 用户报名
- * @param applyInfo
- * @return
- */
- // @ApiOperation(value = "学生报名乐团")
- @PostMapping("/userApply")
- public Object userApply(ApplyInfo applyInfo){
- if(applyInfo != null){
- try {
- Date date = new Date();
- applyInfo.setCreateTime(date);
- applyInfo.setUpdateTime(date);
- applyInfoService.insert(applyInfo);
- return succeed(applyInfo.getId());
- }catch (Exception e){
- e.printStackTrace();
- if(e instanceof DuplicateKeyException){
- return failed("该用户已存在");
- }
- return failed("报名失败");
- }
- }
- return failed(Constants.PARAM_VERIFY_ERROR_MSG);
- }
- /**
- * 根据乐团id获取乐团详情,查询乐团状态也通过该接口
- * @param clazzId
- * @return
- */
- // @ApiOperation(value = "根据乐团编号获取乐团详情,查询乐团状态也通过该接口")
- @PostMapping("/getClassDetail")
- // @ApiImplicitParams({ @ApiImplicitParam(name = "clazzId", value = "乐团编号", required = true, dataType = "Integer"),
- // @ApiImplicitParam(name = "schoolId", value = "学校编号", required = true, dataType = "Integer")})
- public Object getSchoolDetail(Integer schoolId,Integer clazzId){
- if(schoolId == null || clazzId == null){
- return failed(Constants.PARAM_VERIFY_ERROR_MSG);
- }
- return succeed(orderService.getSchoolDetail(schoolId,clazzId));
- }
- /**
- * 根据学生编号获取乐团注册页面数据
- * @param stuId
- * @return
- */
- // @ApiOperation(value = "根据学生编号获取乐团注册页面数据")
- @PostMapping("/getUserRegisterViewDetail")
- public Object getUserRegisterViewDetail(Integer stuId){
- if(stuId == null){
- return failed(Constants.PARAM_VERIFY_ERROR_MSG);
- }
- return succeed(applyInfoService.getUserRegisterViewDetail(stuId));
- }
- /**
- * 推送用户到mec注册
- * @return
- */
- /*@PostMapping("/userRegister")
- public Object userRegister(String phone){
- return succeed(applyInfoService.userRegister(phone));
- }*/
- /**
- * 获取乐团课程组列表
- * @return
- */
- @PostMapping("/getCourses")
- // @ApiOperation(value = "根据乐团编号,获取乐团课程组列表")
- // @ApiImplicitParams({ @ApiImplicitParam(name = "clazzId", value = "乐团编号", required = true, dataType = "Integer")})
- public Object getCourses(Integer clazzId){
- if(clazzId == null){
- return failed(Constants.PARAM_VERIFY_ERROR_MSG);
- }
- return succeed(courseGroupInfoService.getCourses(clazzId));
- }
- // @ApiOperation(value = "获取所有乐团列表")
- @PostMapping("/getMusicTeams")
- public Object getMusicTeams(MusicTeamsPageInfo pageInfo){
- return succeed(schoolService.queryPage(pageInfo));
- }
- // @ApiOperation(value = "根据乐团编号,获取学员列表")
- @PostMapping("/getMusicTeamStu")
- public Object getMusicTeamStu(StudentsQueryInfo queryInfo){
- return succeed(applyInfoService.queryUserPage(queryInfo));
- }
- // @ApiOperation(value = "获取所有分部列表")
- @GetMapping("/getBranches")
- public Object getBranches(){
- return succeed(applyInfoService.getBranches());
- }
- // @ApiOperation(value = "获取学校详情")
- @GetMapping("/getSchool")
- public Object getSchool(Integer schoolId){
- if(schoolId == null){
- return failed(Constants.PARAM_VERIFY_ERROR_MSG);
- }
- return succeed(applyInfoService.get(schoolId));
- }
- /**
- * 保存学校列表
- * @return
- */
- // @GetMapping("/saveSeminary")
- // public Object saveSeminary(){
- // applyInfoService.saveSeminary();
- // return succeed();
- // }
- /**
- * 修改乐团信息
- * @return
- */
- // @ApiOperation(value = "修改乐团信息")
- @PostMapping("/updateClass")
- public Object updateClass(School school){
- school.setUpdateTime(new Date());
- schoolService.update(school);
- return succeed();
- }
- /**
- * 开启乐团缴费功能
- * @return
- */
- // @ApiOperation(value = "开启乐团缴费功能")
- @PostMapping("/openClassPay")
- public Object openClassPay(Integer id){
- if(id == null){
- return failed(Constants.PARAM_VERIFY_ERROR_MSG);
- }
- schoolService.openClassPay(id);
- return succeed();
- }
- /**
- * 修改学生信息
- * @return
- */
- // @ApiOperation(value = "修改学生信息")
- @PostMapping("/updateUser")
- public Object updateUser(@ModelAttribute ApplyInfo applyInfo){
- applyInfo.setUpdateTime(new Date());
- applyInfoService.update(applyInfo);
- return succeed("修改成功");
- }
- /**
- * 修改学生信息
- * @return
- */
- // @ApiOperation(value = "批量调剂学员专业")
- @PostMapping("/updateUserSub")
- public Object updateUserSub(String userId,Integer subId,Integer courseId){
- if(StringUtils.isEmpty(userId) || subId == null || courseId == null){
- return failed(Constants.PARAM_VERIFY_ERROR_MSG);
- }
- applyInfoService.updateUserSub(userId,subId,courseId);
- return succeed("修改成功");
- }
- // @ApiOperation(value = "学员课程班查询,本接口用于查询指定学员报名的课程班(小课或乐团)列表")
- @PostMapping("/queryUserCourse")
- // @ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "用户编号", required = true, dataType = "Integer")})
- public Object queryUserCourse(Integer userId){
- if(userId == null){
- return failed(Constants.PARAM_VERIFY_ERROR_MSG);
- }
- return succeed(applyInfoService.queryUserCourse(userId));
- }
- /**
- * 推送学生续费成功的订单数据到mec
- * @return
- */
- // @PostMapping("/pushRenew")
- // public Object pushRenew(RenewBean renewBean){
- // applyInfoService.pushRenew(renewBean);
- // return succeed();
- // }
- /**
- * 查询mec用户信息
- * @return
- */
- @PostMapping("/findMecUser")
- public Object findMecUser(Integer userId){
- if(userId == null){
- return failed(Constants.PARAM_VERIFY_ERROR_MSG);
- }
- return succeed(applyInfoService.findMecUser(userId));
- }
- @PostMapping("/mecUserIsExist")
- public Object mecUserIsExist(String phone){
- return succeed(applyInfoService.mecUserIsExist(phone));
- }
- }
|