| | |
| | | import com.ruoyi.common.utils.NumberUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.model.TbQuestion; |
| | | import com.ruoyi.system.model.TbSystemConfig; |
| | | import com.ruoyi.system.model.TbUser; |
| | | import com.ruoyi.system.service.TbQuestionService; |
| | | import com.ruoyi.system.service.TbSystemConfigService; |
| | | import com.ruoyi.system.service.TbUserService; |
| | | import com.ruoyi.system.vo.InviteUserListVo; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | @Slf4j |
| | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | |
| | | @ApiOperation(value = "修改用户信息",tags = {"修改用户信息"}) |
| | | @Autowired |
| | | private TbQuestionService questionService; |
| | | |
| | | @Autowired |
| | | private TbSystemConfigService systemConfigService; |
| | | |
| | | @ApiOperation(value = "修改用户信息",tags = {"用户模块"}) |
| | | @PostMapping("/updateUserInfo") |
| | | public R<?> updateUserInfo(String avatar,String username) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (StringUtils.isBlank(avatar)) { |
| | | return R.fail("头像不能为空"); |
| | | } |
| | | if (StringUtils.isBlank(username)) { |
| | | return R.fail("姓名不能为空"); |
| | | } |
| | | Long userId = loginUser.getUserId(); |
| | | |
| | | TbUser user = userService.getById(userId); |
| | | user.setUserName(username); |
| | | user.setAvatar(avatar); |
| | | if(StringUtils.isNotEmpty(username)) { |
| | | user.setUserName(username); |
| | | } |
| | | if(StringUtils.isNotEmpty(avatar)){ |
| | | user.setAvatar(avatar); |
| | | } |
| | | userService.updateById(user); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "获取最新用户信息",tags = {"获取最新用户信息"}) |
| | | @ApiOperation(value = "获取最新用户信息",tags = {"用户模块"}) |
| | | @GetMapping("/getUserInfo") |
| | | public R<?> getUserInfo() { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | |
| | | return R.ok(user); |
| | | } |
| | | |
| | | @ApiOperation(value = "账号注销",tags = {"账号注销"}) |
| | | @GetMapping("/accountCancellation") |
| | | @ApiOperation(value = "账号注销",tags = {"用户模块"}) |
| | | @PostMapping("/accountCancellation") |
| | | public R<?> accountCancellation() { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | Long userId = loginUser.getUserId(); |
| | |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "常见问题",tags = {"用户模块"}) |
| | | @GetMapping("/getQuestion") |
| | | public R<List<TbQuestion>> getQuestion() { |
| | | List<TbQuestion> list = questionService.list(new LambdaQueryWrapper<TbQuestion>().eq(TbQuestion::getDelFlag,0).orderByDesc(TbQuestion::getOrderNum)); |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @ApiOperation(value = "客服",tags = {"用户模块"}) |
| | | @GetMapping("/customerService") |
| | | public R<String> customerService() { |
| | | TbSystemConfig config = systemConfigService.getOne(new LambdaQueryWrapper<TbSystemConfig>().eq(TbSystemConfig::getType, 2)); |
| | | String content = config.getContent(); |
| | | return R.ok(content); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "退出登录",tags = {"用户模块"}) |
| | | @PostMapping("/quit") |
| | | public R<String> quit(HttpServletRequest request) { |
| | | tokenService.quitLogin(request); |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |