| | |
| | | package com.ycl.jxkg.controller.admin; |
| | | |
| | | import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.ycl.jxkg.base.BaseApiController; |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.ycl.jxkg.domain.form.UpdatePwdForm; |
| | | import com.ycl.jxkg.enums.RoleEnum; |
| | | import com.ycl.jxkg.domain.other.KeyValue; |
| | | import com.ycl.jxkg.base.SystemCode; |
| | | import com.ycl.jxkg.context.WebContext; |
| | | import com.ycl.jxkg.domain.entity.User; |
| | | import com.ycl.jxkg.domain.entity.UserEventLog; |
| | | import com.ycl.jxkg.enums.UserStatusEnum; |
| | | import com.ycl.jxkg.domain.other.KeyValue; |
| | | import com.ycl.jxkg.domain.vo.StudentVO; |
| | | import com.ycl.jxkg.domain.vo.admin.user.*; |
| | | import com.ycl.jxkg.enums.RoleEnum; |
| | | import com.ycl.jxkg.enums.UserStatusEnum; |
| | | import com.ycl.jxkg.service.AuthenticationService; |
| | | import com.ycl.jxkg.service.UserEventLogService; |
| | | import com.ycl.jxkg.service.UserService; |
| | | import com.ycl.jxkg.utils.DateTimeUtil; |
| | | import com.ycl.jxkg.domain.vo.admin.user.*; |
| | | import com.ycl.jxkg.utils.PageInfoHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | |
| | | private final UserService userService; |
| | | private final UserEventLogService userEventLogService; |
| | | private final AuthenticationService authenticationService; |
| | | |
| | | 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())) { |
| | | User currentUser = webContext.getCurrentUser(); |
| | | if (teacher.equals(currentUser.getRole())) { |
| | | return Result.fail(SystemCode.InnerError.getCode(), "您没有访问权限"); |
| | | } |
| | | } |
| | | PageInfo<User> pageInfo = userService.userPage(model); |
| | | PageInfo<UserResponseVO> page = PageInfoHelper.copyMap(pageInfo, d -> UserResponseVO.from(d)); |
| | | return Result.ok(page); |
| | |
| | | return Result.ok(keyValues); |
| | | } |
| | | |
| | | @PostMapping("/update/password") |
| | | public Result<Object> updatePassword(@RequestBody @Validated UpdatePwdForm form) { |
| | | userService.updatePassword(form); |
| | | return Result.ok("修改成功"); |
| | | @GetMapping("importTemplate") |
| | | public void importTemplate(HttpServletResponse response) { |
| | | userService.importTemplate(response); |
| | | } |
| | | |
| | | @PostMapping("import") |
| | | public Result<String> importExcel(MultipartFile file) { |
| | | return Result.ok(userService.importExcel(file)); |
| | | } |
| | | |
| | | |