|
|
@ -1,17 +1,22 @@
|
|
|
|
package com.luoo.user.controller;
|
|
|
|
package com.luoo.user.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestHeader;
|
|
|
|
import org.springframework.web.bind.annotation.RequestHeader;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
|
|
import com.luoo.user.annotation.GlobalInterceptor;
|
|
|
|
import com.luoo.user.annotation.GlobalInterceptor;
|
|
|
|
|
|
|
|
import com.luoo.user.constants.Constants;
|
|
|
|
import com.luoo.user.dto.response.UserRespDTO;
|
|
|
|
import com.luoo.user.dto.response.UserRespDTO;
|
|
|
|
import com.luoo.user.pojo.User;
|
|
|
|
import com.luoo.user.pojo.User;
|
|
|
|
import com.luoo.user.service.UserService;
|
|
|
|
import com.luoo.user.service.UserService;
|
|
|
@ -22,6 +27,7 @@ import dto.UserLoginDto;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
import util.JwtUtil;
|
|
|
|
import util.JwtUtil;
|
|
|
|
|
|
|
|
import util.StringTools;
|
|
|
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
@RestController
|
|
|
|
@CrossOrigin
|
|
|
|
@CrossOrigin
|
|
|
@ -33,6 +39,10 @@ public class MyController {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private UserService userService;
|
|
|
|
private UserService userService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* @Value("${project.folder:}") private String projectFolder="./";
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "1.获取个人信息")
|
|
|
|
@ApiOperation(value = "1.获取个人信息")
|
|
|
|
@PostMapping("/getUserInfo")
|
|
|
|
@PostMapping("/getUserInfo")
|
|
|
|
@GlobalInterceptor
|
|
|
|
@GlobalInterceptor
|
|
|
@ -44,7 +54,52 @@ public class MyController {
|
|
|
|
User user = userService.findById(userLoginDto.getUserId());
|
|
|
|
User user = userService.findById(userLoginDto.getUserId());
|
|
|
|
UserRespDTO userRespDTO = new UserRespDTO();
|
|
|
|
UserRespDTO userRespDTO = new UserRespDTO();
|
|
|
|
BeanUtils.copyProperties(user, userRespDTO);
|
|
|
|
BeanUtils.copyProperties(user, userRespDTO);
|
|
|
|
userRespDTO.setToken(token);
|
|
|
|
|
|
|
|
return Result.success(userRespDTO);
|
|
|
|
return Result.success(userRespDTO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* @ApiOperation(value = "2.上传个人头像")
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @RequestMapping("/uploadAvatar")
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @GlobalInterceptor(checkLogin = true) public Result
|
|
|
|
|
|
|
|
* uploadAvatar(@RequestHeader(value = "token", required = false) String token,
|
|
|
|
|
|
|
|
* MultipartFile file) throws IOException { UserLoginDto userLoginDto =
|
|
|
|
|
|
|
|
* jwtUtil.getUserLoginDto(token); String folderName = projectFolder +
|
|
|
|
|
|
|
|
* Constants.FOLDER_AVATAR; File folder = new File(folderName); if
|
|
|
|
|
|
|
|
* (!folder.exists()) { folder.exists(); }
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* String avatarName = userLoginDto.getUserId() +
|
|
|
|
|
|
|
|
* StringTools.getFileSuffix(file.getOriginalFilename()); File avatarFileName =
|
|
|
|
|
|
|
|
* new File(folder.getPath() + "/" + avatarName);
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* file.transferTo(avatarFileName);
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* ScaleFilter.createThumbnail(avatarFileName, Constants.LENGTH_70,
|
|
|
|
|
|
|
|
* Constants.LENGTH_70, avatarFileName);
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* AppUserInfo appUserInfo = new AppUserInfo();
|
|
|
|
|
|
|
|
* appUserInfo.setAvatar(Constants.FOLDER_AVATAR + avatarName);
|
|
|
|
|
|
|
|
* appUserInfoService.updateAppUserInfoByUserId(appUserInfo,
|
|
|
|
|
|
|
|
* userLoginDto.getUserId()); return getSuccessResponseVO(null); }
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @ApiOperation(value = "1.获取个人信息")
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @RequestMapping("/updateUserInfo")
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @GlobalInterceptor(checkLogin = true) public ResponseVO
|
|
|
|
|
|
|
|
* updateUserInfo(@RequestHeader(value = "token", required = false) String
|
|
|
|
|
|
|
|
* token,
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @VerifyParam(required = true) Integer sex,
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @VerifyParam(regex = VerifyRegexEnum.PASSWORD) String passwrd) {
|
|
|
|
|
|
|
|
* AppUserLoginDto userLoginDto = getAppUserLoginfoFromToken(token);
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* AppUserInfo updateInfo = new AppUserInfo(); updateInfo.setSex(sex); if
|
|
|
|
|
|
|
|
* (!StringTools.isEmpty(passwrd)) {
|
|
|
|
|
|
|
|
* updateInfo.setPassword(StringTools.encodeByMD5(passwrd)); }
|
|
|
|
|
|
|
|
* appUserInfoService.updateAppUserInfoByUserId(updateInfo,
|
|
|
|
|
|
|
|
* userLoginDto.getUserId()); return getSuccessResponseVO(null); }
|
|
|
|
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|