|
|
@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
package com.hzu.bookingsystem.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.hzu.bookingsystem.VO.ResultVO;
|
|
|
|
|
|
|
|
import com.hzu.bookingsystem.bean.UserCourseBean;
|
|
|
|
|
|
|
|
import com.hzu.bookingsystem.converter.Map2Object;
|
|
|
|
|
|
|
|
import com.hzu.bookingsystem.service.UserCourseService;
|
|
|
|
|
|
|
|
import com.hzu.bookingsystem.utils.ResultVOUtil;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
|
|
|
|
@CrossOrigin
|
|
|
|
|
|
|
|
@RequestMapping("/usercourse")
|
|
|
|
|
|
|
|
public class UserCourseController {
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private UserCourseService usercourseService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 根据id查看课程记录
|
|
|
|
|
|
|
|
@GetMapping(value = "/findusercourse/{uc_id}")
|
|
|
|
|
|
|
|
public ResultVO<Map<String, UserCourseBean>> FindUserCourseId(@PathVariable("uc_id") Integer uc_id) {
|
|
|
|
|
|
|
|
UserCourseBean usercourse = usercourseService.findById( uc_id) ;
|
|
|
|
|
|
|
|
return ResultVOUtil.success(usercourse);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查找所有课程列表
|
|
|
|
|
|
|
|
@GetMapping(value = "/getusercourselist")
|
|
|
|
|
|
|
|
public ResultVO getUserCourseList(){
|
|
|
|
|
|
|
|
List<UserCourseBean> usercourselist = usercourseService.findAll();
|
|
|
|
|
|
|
|
return ResultVOUtil.success(usercourselist);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 根据教师id和学年,学期查询课程
|
|
|
|
|
|
|
|
@GetMapping(value = "/finduidandyearandsemester/{u_id}/{year}/{semester}")
|
|
|
|
|
|
|
|
public ResultVO<Map<String, UserCourseBean>> findUidandYearandSemester(@PathVariable("u_id") Integer u_id,@PathVariable("year") String year,@PathVariable("semester") Integer semester ) {
|
|
|
|
|
|
|
|
List<UserCourseBean> usercourselist = usercourseService.findAllByUidAndYearAndSemester( u_id,year,semester) ;
|
|
|
|
|
|
|
|
return ResultVOUtil.success(usercourselist);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 增加课程记录
|
|
|
|
|
|
|
|
@PostMapping(value = "/addusercourse", consumes = "application/json")
|
|
|
|
|
|
|
|
public ResultVO addUserCourse(@RequestBody Map<String,Object> map) {
|
|
|
|
|
|
|
|
// 1.转换对象
|
|
|
|
|
|
|
|
UserCourseBean usercourse = (UserCourseBean) Map2Object.map2Object(map,UserCourseBean.class);
|
|
|
|
|
|
|
|
// 2.插入
|
|
|
|
|
|
|
|
usercourseService.add(usercourse);
|
|
|
|
|
|
|
|
return ResultVOUtil.success();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//更新记录
|
|
|
|
|
|
|
|
@PostMapping(value = "/updateusercourse", consumes = "application/json")
|
|
|
|
|
|
|
|
public ResultVO updateUserCourse(@RequestBody Map<String,Object> map, HttpServletRequest request){
|
|
|
|
|
|
|
|
// 转换对象
|
|
|
|
|
|
|
|
UserCourseBean usercourse = (UserCourseBean) Map2Object.map2Object(map,UserCourseBean.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UserCourseBean usercoursenew = usercourseService.update(usercourse) ;
|
|
|
|
|
|
|
|
return ResultVOUtil.success(usercoursenew);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 通过uc_id删除记录
|
|
|
|
|
|
|
|
@PostMapping(value = "/deleteusercourse/{uc_id}", consumes = "application/json")
|
|
|
|
|
|
|
|
public ResultVO deleteUsercourse(@PathVariable("uc_id") Integer uc_id){
|
|
|
|
|
|
|
|
// 查找该用户看是否存在
|
|
|
|
|
|
|
|
UserCourseBean usercourse = usercourseService.findById(uc_id);
|
|
|
|
|
|
|
|
if (usercourse == null){
|
|
|
|
|
|
|
|
return ResultVOUtil.error(-1,"记录不存在");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 删除记录
|
|
|
|
|
|
|
|
usercourseService.deleteByUcId(uc_id);
|
|
|
|
|
|
|
|
return ResultVOUtil.success();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|