|
@@ -2,15 +2,20 @@ package com.jpsoft.enterprise.modules.mobile.controller;
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
+import com.jpsoft.enterprise.config.OSSConfig;
|
|
|
|
|
+import com.jpsoft.enterprise.modules.base.dto.CompanyInfoDetailDTO;
|
|
|
|
|
+import com.jpsoft.enterprise.modules.base.entity.CompanyInfo;
|
|
|
import com.jpsoft.enterprise.modules.base.entity.PersonInfo;
|
|
import com.jpsoft.enterprise.modules.base.entity.PersonInfo;
|
|
|
import com.jpsoft.enterprise.modules.base.service.MessageReceiverService;
|
|
import com.jpsoft.enterprise.modules.base.service.MessageReceiverService;
|
|
|
|
|
+import com.jpsoft.enterprise.modules.base.service.CompanyInfoService;
|
|
|
import com.jpsoft.enterprise.modules.base.service.PersonInfoService;
|
|
import com.jpsoft.enterprise.modules.base.service.PersonInfoService;
|
|
|
import com.jpsoft.enterprise.modules.common.dto.MessageResult;
|
|
import com.jpsoft.enterprise.modules.common.dto.MessageResult;
|
|
|
-import com.jpsoft.enterprise.modules.common.utils.AESUtil;
|
|
|
|
|
-import com.jpsoft.enterprise.modules.common.utils.JwtUtil;
|
|
|
|
|
-import com.jpsoft.enterprise.modules.common.utils.SMSUtil;
|
|
|
|
|
|
|
+import com.jpsoft.enterprise.modules.common.utils.*;
|
|
|
|
|
+import com.jpsoft.enterprise.modules.sys.entity.DataDictionary;
|
|
|
|
|
+import com.jpsoft.enterprise.modules.sys.service.DataDictionaryService;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
|
|
+import io.swagger.annotations.ApiModelProperty;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import net.sf.json.JSONObject;
|
|
import net.sf.json.JSONObject;
|
|
@@ -19,8 +24,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.redis.core.ValueOperations;
|
|
import org.springframework.data.redis.core.ValueOperations;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
+import sun.misc.BASE64Decoder;
|
|
|
import sun.security.provider.MD5;
|
|
import sun.security.provider.MD5;
|
|
|
|
|
|
|
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -38,15 +46,24 @@ public class PersonInfoApiController {
|
|
|
@Value("${jwt.secret}")
|
|
@Value("${jwt.secret}")
|
|
|
private String jwtSecret;
|
|
private String jwtSecret;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private OSSConfig ossConfig;
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private PersonInfoService personInfoService;
|
|
private PersonInfoService personInfoService;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ValueOperations<String, Object> valueOperations;
|
|
private ValueOperations<String, Object> valueOperations;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private CompanyInfoService companyInfoService;
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private MessageReceiverService messageReceiverService;
|
|
private MessageReceiverService messageReceiverService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DataDictionaryService dataDictionaryService;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -254,8 +271,17 @@ public class PersonInfoApiController {
|
|
|
PersonInfo personInfo = personInfoService.findByOpenId(openId);
|
|
PersonInfo personInfo = personInfoService.findByOpenId(openId);
|
|
|
if (personInfo != null){
|
|
if (personInfo != null){
|
|
|
String token = JwtUtil.createToken(jwtSecret, personInfo.getId() + "", DateUtil.offsetHour(new Date(),6));
|
|
String token = JwtUtil.createToken(jwtSecret, personInfo.getId() + "", DateUtil.offsetHour(new Date(),6));
|
|
|
|
|
+ String registerTypeName = dataDictionaryService.findNameByCatalogNameAndValue("注册用户类型",personInfo.getRegisterType());
|
|
|
|
|
+ personInfo.setRegisterTypeName(registerTypeName);
|
|
|
dataMap.put("personInfo", personInfo);
|
|
dataMap.put("personInfo", personInfo);
|
|
|
dataMap.put("token", token);
|
|
dataMap.put("token", token);
|
|
|
|
|
+ CompanyInfoDetailDTO companyInfoDetailDTO = new CompanyInfoDetailDTO();
|
|
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
|
|
|
|
|
+ companyInfoDetailDTO.setCompanyName(companyInfo.getCompanyName());
|
|
|
|
|
+ companyInfoDetailDTO.setId(companyInfo.getId());
|
|
|
|
|
+ companyInfoDetailDTO.setLogoUrl(companyInfo.getLogoUrl());
|
|
|
|
|
+
|
|
|
|
|
+ dataMap.put("companyInfo",companyInfoDetailDTO);
|
|
|
|
|
|
|
|
int messageNum = messageReceiverService.countByReadStatus(personInfo.getId(),false);
|
|
int messageNum = messageReceiverService.countByReadStatus(personInfo.getId(),false);
|
|
|
|
|
|
|
@@ -275,7 +301,7 @@ public class PersonInfoApiController {
|
|
|
return messageResult;
|
|
return messageResult;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @PostMapping("resetPassword ")
|
|
|
|
|
|
|
+ @PostMapping("resetPassword")
|
|
|
@ApiOperation(value = "重置密码")
|
|
@ApiOperation(value = "重置密码")
|
|
|
@ApiImplicitParams({
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form"),
|
|
@ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form"),
|
|
@@ -353,5 +379,174 @@ public class PersonInfoApiController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ @PostMapping("basicInformation")
|
|
|
|
|
+ @ApiOperation(value = "企业基础信息")
|
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
|
+ @ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form"),
|
|
|
|
|
+ @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form")
|
|
|
|
|
+ })
|
|
|
|
|
+ public MessageResult<Map> basicInformation(String token, @RequestAttribute String subject) {
|
|
|
|
|
+
|
|
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> dataMap = new HashMap<String, Object>();
|
|
|
|
|
+ PersonInfo personInfo = personInfoService.get(subject);
|
|
|
|
|
+ if (personInfo == null){
|
|
|
|
|
+ throw new Exception("用户不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
|
|
|
|
|
+
|
|
|
|
|
+ if (companyInfo == null){
|
|
|
|
|
+ throw new Exception("企业不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ dataMap.put("companyInfo",companyInfo);
|
|
|
|
|
+ dataMap.put("personInfo",personInfo);
|
|
|
|
|
+ messageResult.setData(dataMap);
|
|
|
|
|
+ messageResult.setResult(true);
|
|
|
|
|
+ messageResult.setCode(200);
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
|
|
+ messageResult.setCode(400);
|
|
|
|
|
+ messageResult.setResult(false);
|
|
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return messageResult;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("updateBasicInformation")
|
|
|
|
|
+ @ApiOperation(value = "更新企业基础信息")
|
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
|
+ @ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form"),
|
|
|
|
|
+ @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form"),
|
|
|
|
|
+ @ApiImplicitParam(name = "creditCode", value = "社会信用代码", required = true, paramType = "form"),
|
|
|
|
|
+ @ApiImplicitParam(name = "companyName", value = "企业名称", required = true, paramType = "form"),
|
|
|
|
|
+ @ApiImplicitParam(name = "registerType", value = "注册用户类型", required = true, paramType = "form"),
|
|
|
|
|
+ @ApiImplicitParam(name = "region", value = "企业所在区域", required = true, paramType = "form"),
|
|
|
|
|
+ @ApiImplicitParam(name = "idCard", value = "身份证号码", required = true, paramType = "form"),
|
|
|
|
|
+ @ApiImplicitParam(name = "personName", value = "真实姓名", required = true, paramType = "form"),
|
|
|
|
|
+ @ApiImplicitParam(name = "phone", value = "手机号码", required = true, paramType = "form"),
|
|
|
|
|
+ @ApiImplicitParam(name = "idCardUrl", value = "身份证人脸面", required = false, paramType = "form"),
|
|
|
|
|
+ @ApiImplicitParam(name = "businessLicenseUrl", value = "营业执照照片", required = false, paramType = "form"),
|
|
|
|
|
+ @ApiImplicitParam(name = "type", value = "企业类型", required = false, paramType = "form"),
|
|
|
|
|
+ @ApiImplicitParam(name = "scale", value = "企业规模", required = false, paramType = "form"),
|
|
|
|
|
+ @ApiImplicitParam(name = "industry", value = "所属行业", required = false, paramType = "form"),
|
|
|
|
|
+ @ApiImplicitParam(name = "address", value = "公司地址", required = false, paramType = "form"),
|
|
|
|
|
+ @ApiImplicitParam(name = "companyIntroduction", value = "公司介绍", required = false, paramType = "form"),
|
|
|
|
|
+ @ApiImplicitParam(name = "enterpriserIntroduction", value = "企业家介绍", required = false, paramType = "form"),
|
|
|
|
|
+ })
|
|
|
|
|
+ public MessageResult<Map> updateBasicInformation(String token, @RequestAttribute String subject,String creditCode,String companyName,String registerType,String region,String idCard,String personName,String phone,String idCardUrl,String businessLicenseUrl,String type,String scale,String industry,String address,String companyIntroduction,String enterpriserIntroduction) {
|
|
|
|
|
+
|
|
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> dataMap = new HashMap<String, Object>();
|
|
|
|
|
+ PersonInfo personInfo = personInfoService.get(subject);
|
|
|
|
|
+ if (personInfo == null){
|
|
|
|
|
+ throw new Exception("用户不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
|
|
|
|
|
+
|
|
|
|
|
+ if (companyInfo == null){
|
|
|
|
|
+ throw new Exception("企业不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!com.jpsoft.enterprise.modules.common.utils.StringUtils.isValid(creditCode)){
|
|
|
|
|
+ throw new Exception("社会信用代码错误");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!new CheckIdCard(idCard).validate()){
|
|
|
|
|
+ throw new Exception("身份证号码错误");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ companyInfo.setCreditCode(creditCode);
|
|
|
|
|
+ companyInfo.setCompanyName(companyName);
|
|
|
|
|
+ companyInfo.setRegion(region);
|
|
|
|
|
+ if (StringUtils.isNotBlank(businessLicenseUrl)){
|
|
|
|
|
+ companyInfo.setBusinessLicenseUrl(businessLicenseUrl);
|
|
|
|
|
+ }
|
|
|
|
|
+ companyInfo.setType(type);
|
|
|
|
|
+ companyInfo.setScale(scale);
|
|
|
|
|
+ companyInfo.setIndustry(industry);
|
|
|
|
|
+ companyInfo.setAddress(address);
|
|
|
|
|
+ companyInfo.setCompanyIntroduction(companyIntroduction);
|
|
|
|
|
+ companyInfo.setEnterpriserIntroduction(enterpriserIntroduction);
|
|
|
|
|
+ companyInfoService.update(companyInfo);
|
|
|
|
|
+ //更新用户
|
|
|
|
|
+ personInfo.setRegisterType(registerType);
|
|
|
|
|
+ personInfo.setIdCard(idCard);
|
|
|
|
|
+ personInfo.setPersonName(personName);
|
|
|
|
|
+ personInfo.setPhone(phone);
|
|
|
|
|
+ if (StringUtils.isNotBlank(idCardUrl)){
|
|
|
|
|
+ personInfo.setIdCardUrl(idCardUrl);
|
|
|
|
|
+ }
|
|
|
|
|
+ personInfoService.update(personInfo);
|
|
|
|
|
+
|
|
|
|
|
+ messageResult.setData(dataMap);
|
|
|
|
|
+ messageResult.setResult(true);
|
|
|
|
|
+ messageResult.setCode(200);
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
|
|
+ messageResult.setCode(400);
|
|
|
|
|
+ messageResult.setResult(false);
|
|
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return messageResult;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("uploadBase64")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ @ApiOperation(value = "员工照片上传")
|
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
|
+ @ApiImplicitParam(name = "photoName", value = "照片名称", required = true, paramType = "form"),
|
|
|
|
|
+ @ApiImplicitParam(name = "photoBase64Data", value = "员工照片base64编码", required = true, paramType = "form")
|
|
|
|
|
+ })
|
|
|
|
|
+ public MessageResult<String> uploadBase64(String photoName, String photoBase64Data) {
|
|
|
|
|
+ MessageResult<String> messageResult = new MessageResult<>();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ BASE64Decoder decoder = new BASE64Decoder();
|
|
|
|
|
+
|
|
|
|
|
+ String[] arr = photoBase64Data.split(",");
|
|
|
|
|
+
|
|
|
|
|
+ byte[] imgData = decoder.decodeBuffer(arr[1]);
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < imgData.length; ++i) {
|
|
|
|
|
+ if (imgData[i] < 0) {// 调整异常数据
|
|
|
|
|
+ imgData[i] += 256;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(imgData);
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isEmpty(photoName)) {
|
|
|
|
|
+ photoName = "1.jpg";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String retFileUrl = OSSUtil.upload(ossConfig, "/person", photoName, inputStream);
|
|
|
|
|
+
|
|
|
|
|
+ messageResult.setResult(true);
|
|
|
|
|
+ messageResult.setData(retFileUrl);
|
|
|
|
|
+ messageResult.setCode(200);
|
|
|
|
|
+
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
|
|
+ messageResult.setCode(400);
|
|
|
|
|
+ messageResult.setResult(false);
|
|
|
|
|
+ messageResult.setMessage(e.getMessage());
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ return messageResult;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
}
|
|
}
|