| | |
| | | |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.ycl.jxkg.controller.wx.BaseWXApiController; |
| | | import com.ycl.jxkg.domain.Message; |
| | | import com.ycl.jxkg.domain.MessageUser; |
| | | import com.ycl.jxkg.domain.User; |
| | | import com.ycl.jxkg.domain.UserEventLog; |
| | | import com.ycl.jxkg.domain.enums.RoleEnum; |
| | | import com.ycl.jxkg.domain.enums.UserStatusEnum; |
| | | import com.ycl.jxkg.domain.entity.Message; |
| | | import com.ycl.jxkg.domain.entity.MessageUser; |
| | | import com.ycl.jxkg.domain.entity.User; |
| | | import com.ycl.jxkg.domain.entity.UserEventLog; |
| | | import com.ycl.jxkg.enums.RoleEnum; |
| | | import com.ycl.jxkg.enums.UserStatusEnum; |
| | | import com.ycl.jxkg.event.UserEvent; |
| | | import com.ycl.jxkg.service.AuthenticationService; |
| | | import com.ycl.jxkg.service.MessageService; |
| | |
| | | import com.ycl.jxkg.service.UserService; |
| | | import com.ycl.jxkg.utils.DateTimeUtil; |
| | | import com.ycl.jxkg.utils.PageInfoHelper; |
| | | import com.ycl.jxkg.vo.student.user.*; |
| | | import com.ycl.jxkg.domain.vo.student.user.*; |
| | | 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.context.ApplicationEventPublisher; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | import java.util.UUID; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | | @RequiredArgsConstructor |
| | | @Controller("WXStudentUserController") |
| | | @RequestMapping(value = "/api/wx/student/user") |
| | | @ResponseBody |
| | |
| | | private final MessageService messageService; |
| | | private final AuthenticationService authenticationService; |
| | | private final ApplicationEventPublisher eventPublisher; |
| | | |
| | | @Autowired |
| | | public UserController(UserService userService, UserEventLogService userEventLogService, MessageService messageService, AuthenticationService authenticationService, ApplicationEventPublisher eventPublisher) { |
| | | this.userService = userService; |
| | | this.userEventLogService = userEventLogService; |
| | | this.messageService = messageService; |
| | | this.authenticationService = authenticationService; |
| | | this.eventPublisher = eventPublisher; |
| | | } |
| | | |
| | | @RequestMapping(value = "/current", method = RequestMethod.POST) |
| | | public Result<UserResponseVO> current() { |
| | |
| | | user.setStatus(UserStatusEnum.Enable.getCode()); |
| | | user.setLastActiveTime(new Date()); |
| | | user.setCreateTime(new Date()); |
| | | user.setDeleted(false); |
| | | userService.insertByFilter(user); |
| | | userService.insertUser(user); |
| | | UserEventLog userEventLog = new UserEventLog(user.getId(), user.getUserName(), user.getRealName(), new Date()); |
| | | userEventLog.setContent("欢迎 " + user.getUserName() + " 注册来到学之思开源考试系统"); |
| | | userEventLog.setContent("欢迎 " + user.getUserName() + " 注册来到江西空管音视频培训系统"); |
| | | eventPublisher.publishEvent(new UserEvent(userEventLog)); |
| | | return Result.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/update", method = RequestMethod.POST) |
| | | public Result<UserResponseVO> update(@Valid UserUpdateVO model) { |
| | | if (StringUtils.isBlank(model.getBirthDay())) { |
| | | model.setBirthDay(null); |
| | | } |
| | | User user = userService.selectById(getCurrentUser().getId()); |
| | | User user = userService.getById(getCurrentUser().getId()); |
| | | BeanUtils.copyProperties(model, user); |
| | | user.setModifyTime(new Date()); |
| | | userService.updateByIdFilter(user); |
| | | userService.updateUser(user); |
| | | UserEventLog userEventLog = new UserEventLog(user.getId(), user.getUserName(), user.getRealName(), new Date()); |
| | | userEventLog.setContent(user.getUserName() + " 更新了个人资料"); |
| | | eventPublisher.publishEvent(new UserEvent(userEventLog)); |