| | |
| | | package com.ycl.jxkg.controller.admin; |
| | | |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.ycl.jxkg.base.BaseApiController; |
| | | import com.ycl.jxkg.base.Result; |
| | |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.UUID; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | private final WebContext webContext; |
| | | private final Integer teacher = 2; |
| | | private final Integer student = 1; |
| | | |
| | | @RequestMapping(value = "/page/list", method = RequestMethod.POST) |
| | | public Result<PageInfo<UserResponseVO>> pageList(@RequestBody UserPageRequestVO model) { |
| | | if(!student.equals(model.getRole())) { |
| | |
| | | return student; |
| | | }).collect(Collectors.toList()); |
| | | return Result.ok().data(studentVOS); |
| | | } |
| | | |
| | | @RequestMapping(value = "/teacher/list", method = RequestMethod.GET) |
| | | public Result<?> teacherList() { |
| | | List<User> teacherList = new LambdaQueryChainWrapper<>(userService.getBaseMapper()) |
| | | .eq(User::getRole, RoleEnum.TEACHER.getCode()) |
| | | .orderByDesc(User::getCreateTime) |
| | | .list(); |
| | | List<StudentVO> teachers = teacherList.stream().map(item -> { |
| | | StudentVO student = new StudentVO(); |
| | | BeanUtils.copyProperties(item, student); |
| | | return student; |
| | | }).collect(Collectors.toList()); |
| | | return Result.ok().data(teachers); |
| | | } |
| | | |
| | | @RequestMapping(value = "/classes/students", method = RequestMethod.GET) |
| | |
| | | return new Result<>(3, "密码不能为空"); |
| | | } |
| | | } |
| | | if (StringUtils.isBlank(model.getBirthDay())) { |
| | | model.setBirthDay(null); |
| | | } |
| | | User user = new User(); |
| | | BeanUtils.copyProperties(model, user); |
| | | user.setAge(model.getAge()); |
| | | |
| | | if (model.getId() == null) { |
| | | String encodePwd = authenticationService.pwdEncode(model.getPassword()); |
| | |
| | | @RequestMapping(value = "/delete/{id}", method = RequestMethod.POST) |
| | | public Result delete(@PathVariable Integer id) { |
| | | User user = userService.getUserById(id); |
| | | userService.updateById(user); |
| | | userService.removeById(user.getId()); |
| | | return Result.ok(); |
| | | } |
| | | |