| | |
| | | import com.ycl.jxkg.base.BaseApiController; |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.ycl.jxkg.domain.other.KeyValue; |
| | | import com.ycl.jxkg.domain.User; |
| | | import com.ycl.jxkg.domain.UserEventLog; |
| | | import com.ycl.jxkg.domain.entity.User; |
| | | import com.ycl.jxkg.domain.entity.UserEventLog; |
| | | import com.ycl.jxkg.domain.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.vo.admin.user.*; |
| | | 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.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.Valid; |
| | |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | |
| | | @RequiredArgsConstructor |
| | | @RestController("AdminUserController") |
| | | @RequestMapping(value = "/api/admin/user") |
| | | public class UserController extends BaseApiController { |
| | |
| | | private final UserService userService; |
| | | private final UserEventLogService userEventLogService; |
| | | private final AuthenticationService authenticationService; |
| | | |
| | | @Autowired |
| | | public UserController(UserService userService, UserEventLogService userEventLogService, AuthenticationService authenticationService) { |
| | | this.userService = userService; |
| | | this.userEventLogService = userEventLogService; |
| | | this.authenticationService = authenticationService; |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/page/list", method = RequestMethod.POST) |
| | | public Result<PageInfo<UserResponseVO>> pageList(@RequestBody UserPageRequestVO model) { |
| | |
| | | user.setUserUuid(UUID.randomUUID().toString()); |
| | | user.setCreateTime(new Date()); |
| | | user.setLastActiveTime(new Date()); |
| | | user.setDeleted(false); |
| | | userService.insertByFilter(user); |
| | | userService.insertUser(user); |
| | | } else { |
| | | if (!StringUtils.isBlank(model.getPassword())) { |
| | | String encodePwd = authenticationService.pwdEncode(model.getPassword()); |
| | | user.setPassword(encodePwd); |
| | | } |
| | | user.setModifyTime(new Date()); |
| | | userService.updateByIdFilter(user); |
| | | userService.updateById(user); |
| | | } |
| | | return Result.ok(user); |
| | | } |
| | |
| | | |
| | | @RequestMapping(value = "/update", method = RequestMethod.POST) |
| | | public Result update(@RequestBody @Valid UserUpdateVO model) { |
| | | User user = userService.selectById(getCurrentUser().getId()); |
| | | User user = userService.getById(getCurrentUser().getId()); |
| | | BeanUtils.copyProperties(model, user); |
| | | user.setModifyTime(new Date()); |
| | | userService.updateByIdFilter(user); |
| | | userService.updateById(user); |
| | | return Result.ok(); |
| | | } |
| | | |
| | |
| | | Integer newStatus = userStatusEnum == UserStatusEnum.Enable ? UserStatusEnum.Disable.getCode() : UserStatusEnum.Enable.getCode(); |
| | | user.setStatus(newStatus); |
| | | user.setModifyTime(new Date()); |
| | | userService.updateByIdFilter(user); |
| | | userService.updateById(user); |
| | | return Result.ok(newStatus); |
| | | } |
| | | |
| | |
| | | @RequestMapping(value = "/delete/{id}", method = RequestMethod.POST) |
| | | public Result delete(@PathVariable Integer id) { |
| | | User user = userService.getUserById(id); |
| | | user.setDeleted(true); |
| | | userService.updateByIdFilter(user); |
| | | userService.updateById(user); |
| | | return Result.ok(); |
| | | } |
| | | |