|
@@ -2,6 +2,7 @@ package com.jpsoft.employment.modules.base.api;
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.github.pagehelper.Page;
|
|
import com.github.pagehelper.Page;
|
|
|
|
|
+import com.jpsoft.employment.config.OSSConfig;
|
|
|
import com.jpsoft.employment.exception.CustomException;
|
|
import com.jpsoft.employment.exception.CustomException;
|
|
|
import com.jpsoft.employment.modules.base.entity.RegUser;
|
|
import com.jpsoft.employment.modules.base.entity.RegUser;
|
|
|
import com.jpsoft.employment.modules.base.service.RegUserService;
|
|
import com.jpsoft.employment.modules.base.service.RegUserService;
|
|
@@ -9,6 +10,7 @@ import com.jpsoft.employment.modules.common.dto.MessageResult;
|
|
|
import com.jpsoft.employment.modules.common.dto.Sort;
|
|
import com.jpsoft.employment.modules.common.dto.Sort;
|
|
|
import com.jpsoft.employment.modules.common.utils.DES3;
|
|
import com.jpsoft.employment.modules.common.utils.DES3;
|
|
|
import com.jpsoft.employment.modules.common.utils.JwtUtil;
|
|
import com.jpsoft.employment.modules.common.utils.JwtUtil;
|
|
|
|
|
+import com.jpsoft.employment.modules.common.utils.OSSUtil;
|
|
|
import com.jpsoft.employment.modules.common.utils.PojoUtils;
|
|
import com.jpsoft.employment.modules.common.utils.PojoUtils;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
@@ -20,6 +22,7 @@ import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -32,6 +35,9 @@ public class RegUserApi {
|
|
|
@Value("${jwt.secret}")
|
|
@Value("${jwt.secret}")
|
|
|
private String jwtSecret;
|
|
private String jwtSecret;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private OSSConfig ossConfig;
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private RegUserService regUserService;
|
|
private RegUserService regUserService;
|
|
|
|
|
|
|
@@ -139,4 +145,78 @@ public class RegUserApi {
|
|
|
|
|
|
|
|
return msgResult;
|
|
return msgResult;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("updateDetails")
|
|
|
|
|
+ @ApiOperation(value = "更新个人信息")
|
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
|
+ @ApiImplicitParam(name="nickName", value="昵称", required=false, paramType="query"),
|
|
|
|
|
+ @ApiImplicitParam(name="headImg", value="头像", required=false, paramType="query"),
|
|
|
|
|
+ @ApiImplicitParam(name="openId", value="openId", required=true, paramType="query"),
|
|
|
|
|
+ })
|
|
|
|
|
+ public MessageResult updateDetails(String nickName, String headImg, String openId) {
|
|
|
|
|
+ MessageResult messageResult = new MessageResult<>();
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (StrUtil.isBlank(openId)) {
|
|
|
|
|
+ throw new Exception("微信标识不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isNotEmpty(openId)) {
|
|
|
|
|
+ RegUser regUser = regUserService.getByOpenId(openId);
|
|
|
|
|
+
|
|
|
|
|
+ if (regUser != null) {
|
|
|
|
|
+ regUser.setNickName(nickName);
|
|
|
|
|
+ regUser.setHeadImg(headImg);
|
|
|
|
|
+ regUser.setUpdateBy(regUser.getId());
|
|
|
|
|
+ regUser.setUpdateTime(new Date());
|
|
|
|
|
+ regUserService.update(regUser);
|
|
|
|
|
+
|
|
|
|
|
+ messageResult.setResult(true);
|
|
|
|
|
+ messageResult.setCode(200);
|
|
|
|
|
+ messageResult.setData(regUser);
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ throw new CustomException("openid不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ ex.printStackTrace();
|
|
|
|
|
+ logger.error(ex.getMessage());
|
|
|
|
|
+ messageResult.setCode(400);
|
|
|
|
|
+ messageResult.setResult(false);
|
|
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return messageResult;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+// @PostMapping("uploadPicture")
|
|
|
|
|
+// @ApiOperation(value="上传图片")
|
|
|
|
|
+// @ApiImplicitParams({
|
|
|
|
|
+// @ApiImplicitParam(name="subFolder",value = "路径",required = true,paramType = "form"),
|
|
|
|
|
+// @ApiImplicitParam(name = "photoFile",value = "员工照片", required = true,paramType="form", dataType = "__file")
|
|
|
|
|
+// })
|
|
|
|
|
+// public MessageResult<Map> uploadPicture(String subFolder, MultipartFile photoFile){
|
|
|
|
|
+// MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
|
|
+//
|
|
|
|
|
+// try {
|
|
|
|
|
+// String fileName = photoFile.getOriginalFilename();
|
|
|
|
|
+// String rawFileUrl = OSSUtil.upload(ossConfig,"/" + subFolder,fileName,photoFile.getInputStream());
|
|
|
|
|
+//
|
|
|
|
|
+// Map<String,Object> dataMap = new HashMap<>();
|
|
|
|
|
+// dataMap.put("fileName", fileName);
|
|
|
|
|
+// dataMap.put("fileUrl", rawFileUrl);
|
|
|
|
|
+//
|
|
|
|
|
+// messageResult.setResult(true);
|
|
|
|
|
+// messageResult.setData(dataMap);
|
|
|
|
|
+// messageResult.setCode(200);
|
|
|
|
|
+// } catch (Exception e) {
|
|
|
|
|
+// logger.error(e.getMessage(),e);
|
|
|
|
|
+//
|
|
|
|
|
+// messageResult.setResult(false);
|
|
|
|
|
+// messageResult.setMessage(e.getMessage());
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// return messageResult;
|
|
|
|
|
+// }
|
|
|
}
|
|
}
|