瀏覽代碼

Merge remote-tracking branch 'origin/master'

xiao547607 4 年之前
父節點
當前提交
2682a62e4e

+ 83 - 74
web/src/main/java/com/jpsoft/enterprise/modules/mobile/controller/PersonInfoApiController.java

@@ -70,10 +70,6 @@ public class PersonInfoApiController {
     private DataDictionaryService dataDictionaryService;
 
 
-
-
-
-
     @PostMapping("findByPhone")
     @ApiOperation(value = "通过手机号查询用户(公开接口)")
     @ApiImplicitParams({
@@ -97,7 +93,7 @@ public class PersonInfoApiController {
             messageResult.setResult(true);
             messageResult.setCode(200);
         } catch (Exception ex) {
-            log.error(ex.getMessage(),ex);
+            log.error(ex.getMessage(), ex);
             messageResult.setCode(400);
             messageResult.setResult(false);
             messageResult.setMessage(ex.getMessage());
@@ -107,7 +103,6 @@ public class PersonInfoApiController {
     }
 
 
-
     @PostMapping("getVerifyCode")
     @ApiOperation(value = "获取短信验证码(公开接口)")
     @ApiImplicitParams({
@@ -139,11 +134,11 @@ public class PersonInfoApiController {
                 valueOperations.set(key, verifyCode, 5, TimeUnit.MINUTES);
             }
 
-        //    messageResult.setData(personInfo.getId());
+            //    messageResult.setData(personInfo.getId());
             messageResult.setResult(true);
             messageResult.setCode(200);
         } catch (Exception ex) {
-            log.error(ex.getMessage(),ex);
+            log.error(ex.getMessage(), ex);
             messageResult.setCode(400);
             messageResult.setResult(false);
             messageResult.setMessage(ex.getMessage());
@@ -153,7 +148,6 @@ public class PersonInfoApiController {
     }
 
 
-
     @ApiOperation(value = "密码登录")
     @RequestMapping(value = "loginByPassword", method = RequestMethod.POST)
     @ApiImplicitParams({
@@ -161,18 +155,18 @@ public class PersonInfoApiController {
             @ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "form"),
             @ApiImplicitParam(name = "openId", value = "微信ID", required = true, paramType = "query")
     })
-    public MessageResult<Map> loginByPassword(String userName,String password,String openId) {
+    public MessageResult<Map> loginByPassword(String userName, String password, String openId) {
         MessageResult<Map> messageResult = new MessageResult<>();
 
-        try{
+        try {
             PersonInfo personInfo = personInfoService.findByUserName(userName);
-            if (personInfo == null){
+            if (personInfo == null) {
                 throw new Exception("用户名或密码错误");
             }
-            if (StringUtils.isBlank(personInfo.getPassword())){
+            if (StringUtils.isBlank(personInfo.getPassword())) {
                 throw new Exception("该账户未设置密码,请使用验证码登录");
             }
-            if (!AESUtil.encrypt(password, AESUtil.MYSQL_ENC_KEY).equals(personInfo.getPassword())){
+            if (!AESUtil.encrypt(password, AESUtil.MYSQL_ENC_KEY).equals(personInfo.getPassword())) {
                 throw new Exception("用户名或密码错误");
             }
 
@@ -180,18 +174,27 @@ public class PersonInfoApiController {
             personInfo.setUpdateTime(new Date());
             personInfoService.update(personInfo);
 
+            CompanyInfoDetailDTO companyInfoDetailDTO = new CompanyInfoDetailDTO();
+            CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
+            companyInfoDetailDTO.setCompanyName(companyInfo.getCompanyName());
+            companyInfoDetailDTO.setId(companyInfo.getId());
+            companyInfoDetailDTO.setLogoUrl(companyInfo.getLogoUrl());
 
-            String token = JwtUtil.createToken(jwtSecret, personInfo.getId() + "", DateUtil.offsetHour(new Date(),6));
+            String token = JwtUtil.createToken(jwtSecret, personInfo.getId() + "", DateUtil.offsetHour(new Date(), 6));
 
             Map<String, Object> dataMap = new HashMap<String, Object>();
             dataMap.put("personInfo", personInfo);
             dataMap.put("token", token);
+            dataMap.put("companyInfo", companyInfoDetailDTO);
+            int messageNum = messageReceiverService.countByReadStatus(personInfo.getId(), false);
+
+            dataMap.put("messageNum", messageNum);
 
             messageResult.setData(dataMap);
             messageResult.setResult(true);
             messageResult.setCode(200);
-        }catch (Exception ex){
-            log.error(ex.getMessage(),ex);
+        } catch (Exception ex) {
+            log.error(ex.getMessage(), ex);
             messageResult.setCode(400);
             messageResult.setResult(false);
             messageResult.setMessage(ex.getMessage());
@@ -215,7 +218,7 @@ public class PersonInfoApiController {
         try {
 
             PersonInfo personInfo = personInfoService.findByPhone(phone);
-            if (personInfo == null){
+            if (personInfo == null) {
                 throw new Exception("用户不存在");
             }
             String smsKey = "SMS_" + personInfo.getId();
@@ -238,11 +241,21 @@ public class PersonInfoApiController {
                 personInfo.setUpdateTime(new Date());
                 personInfoService.update(personInfo);
 
+                CompanyInfoDetailDTO companyInfoDetailDTO = new CompanyInfoDetailDTO();
+                CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
+                companyInfoDetailDTO.setCompanyName(companyInfo.getCompanyName());
+                companyInfoDetailDTO.setId(companyInfo.getId());
+                companyInfoDetailDTO.setLogoUrl(companyInfo.getLogoUrl());
 
-                    String token = JwtUtil.createToken(jwtSecret, personInfo.getId() + "", DateUtil.offsetHour(new Date(),6));
+                String token = JwtUtil.createToken(jwtSecret, personInfo.getId() + "", DateUtil.offsetHour(new Date(), 6));
 
-                    dataMap.put("personInfo", personInfo);
-                    dataMap.put("token", token);
+                dataMap.put("personInfo", personInfo);
+                dataMap.put("token", token);
+                dataMap.put("companyInfo", companyInfoDetailDTO);
+
+                int messageNum = messageReceiverService.countByReadStatus(personInfo.getId(), false);
+
+                dataMap.put("messageNum", messageNum);
 
             }
 
@@ -250,7 +263,7 @@ public class PersonInfoApiController {
             messageResult.setResult(true);
             messageResult.setCode(200);
         } catch (Exception ex) {
-            log.error(ex.getMessage(),ex);
+            log.error(ex.getMessage(), ex);
             messageResult.setCode(400);
             messageResult.setResult(false);
             messageResult.setMessage(ex.getMessage());
@@ -268,23 +281,23 @@ public class PersonInfoApiController {
             @ApiImplicitParam(name = "phone", value = "phone", required = true, paramType = "query"),
             @ApiImplicitParam(name = "code", value = "验证码", required = true, paramType = "query")
     })
-    public MessageResult<Map> validateCodeAndUpdatePhone(@RequestAttribute String subject, String token,String phone, String code) {
+    public MessageResult<Map> validateCodeAndUpdatePhone(@RequestAttribute String subject, String token, String phone, String code) {
 
         MessageResult<Map> messageResult = new MessageResult<>();
 
         try {
 
             PersonInfo personInfo = personInfoService.get(subject);
-            if (personInfo == null){
+            if (personInfo == null) {
                 throw new Exception("用户不存在");
             }
 
-            if (personInfo.getPhone().equals(phone)){
+            if (personInfo.getPhone().equals(phone)) {
                 throw new Exception("请修改手机号");
             }
 
             PersonInfo personInfo1 = personInfoService.findByPhone(phone);
-            if (personInfo1 != null){
+            if (personInfo1 != null) {
                 throw new Exception("手机号已被人注册");
             }
 
@@ -307,12 +320,11 @@ public class PersonInfoApiController {
             personInfoService.update(personInfo);
 
 
-
             messageResult.setData(dataMap);
             messageResult.setResult(true);
             messageResult.setCode(200);
         } catch (Exception ex) {
-            log.error(ex.getMessage(),ex);
+            log.error(ex.getMessage(), ex);
             messageResult.setCode(400);
             messageResult.setResult(false);
             messageResult.setMessage(ex.getMessage());
@@ -335,30 +347,30 @@ public class PersonInfoApiController {
 
             Map<String, Object> dataMap = new HashMap<String, Object>();
             PersonInfo personInfo = personInfoService.findByOpenId(openId);
-           if (personInfo != null){
-               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("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);
-
-               dataMap.put("messageNum",messageNum);
-           }
+            if (personInfo != null) {
+                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("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);
+
+                dataMap.put("messageNum", messageNum);
+            }
 
             messageResult.setData(dataMap);
             messageResult.setResult(true);
             messageResult.setCode(200);
         } catch (Exception ex) {
-            log.error(ex.getMessage(),ex);
+            log.error(ex.getMessage(), ex);
             messageResult.setCode(400);
             messageResult.setResult(false);
             messageResult.setMessage(ex.getMessage());
@@ -375,7 +387,7 @@ public class PersonInfoApiController {
             @ApiImplicitParam(name = "firstPassword", value = "首次密码", required = true, paramType = "form"),
             @ApiImplicitParam(name = "secondPassword", value = "二次密码", required = true, paramType = "form")
     })
-    public MessageResult<Map> resetPassword(@RequestAttribute String subject, String token, String firstPassword,String secondPassword) {
+    public MessageResult<Map> resetPassword(@RequestAttribute String subject, String token, String firstPassword, String secondPassword) {
 
         MessageResult<Map> messageResult = new MessageResult<>();
 
@@ -383,22 +395,22 @@ public class PersonInfoApiController {
 
             Map<String, Object> dataMap = new HashMap<String, Object>();
             PersonInfo personInfo = personInfoService.get(subject);
-            if (!firstPassword.equals(secondPassword)){
+            if (!firstPassword.equals(secondPassword)) {
                 throw new Exception("两次密码不一致");
             }
 
 
-            if (personInfo != null){
-               personInfo.setPassword(AESUtil.encrypt(secondPassword,AESUtil.MYSQL_ENC_KEY));
-               personInfo.setUpdateTime(new Date());
-               personInfoService.update(personInfo);
+            if (personInfo != null) {
+                personInfo.setPassword(AESUtil.encrypt(secondPassword, AESUtil.MYSQL_ENC_KEY));
+                personInfo.setUpdateTime(new Date());
+                personInfoService.update(personInfo);
             }
 
             messageResult.setData(dataMap);
             messageResult.setResult(true);
             messageResult.setCode(200);
         } catch (Exception ex) {
-            log.error(ex.getMessage(),ex);
+            log.error(ex.getMessage(), ex);
             messageResult.setCode(400);
             messageResult.setResult(false);
             messageResult.setMessage(ex.getMessage());
@@ -408,8 +420,6 @@ public class PersonInfoApiController {
     }
 
 
-
-
     @PostMapping("logOut")
     @ApiOperation(value = "用户登出")
     public MessageResult<Map> logOut(String token, @RequestAttribute String subject) {
@@ -459,22 +469,22 @@ public class PersonInfoApiController {
 
             Map<String, Object> dataMap = new HashMap<String, Object>();
             PersonInfo personInfo = personInfoService.get(subject);
-            if (personInfo == null){
+            if (personInfo == null) {
                 throw new Exception("用户不存在");
             }
             CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
 
-            if (companyInfo == null){
+            if (companyInfo == null) {
                 throw new Exception("企业不存在");
             }
 
-            dataMap.put("companyInfo",companyInfo);
-            dataMap.put("personInfo",personInfo);
+            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);
+            log.error(ex.getMessage(), ex);
             messageResult.setCode(400);
             messageResult.setResult(false);
             messageResult.setMessage(ex.getMessage());
@@ -505,7 +515,7 @@ public class PersonInfoApiController {
             @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) {
+    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<>();
 
@@ -513,27 +523,27 @@ public class PersonInfoApiController {
 
             Map<String, Object> dataMap = new HashMap<String, Object>();
             PersonInfo personInfo = personInfoService.get(subject);
-            if (personInfo == null){
+            if (personInfo == null) {
                 throw new Exception("用户不存在");
             }
             CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
 
-            if (companyInfo == null){
+            if (companyInfo == null) {
                 throw new Exception("企业不存在");
             }
 
-            if (!com.jpsoft.enterprise.modules.common.utils.StringUtils.isValid(creditCode)){
+            if (!com.jpsoft.enterprise.modules.common.utils.StringUtils.isValid(creditCode)) {
                 throw new Exception("社会信用代码错误");
             }
 
-            if (!new CheckIdCard(idCard).validate()){
+            if (!new CheckIdCard(idCard).validate()) {
                 throw new Exception("身份证号码错误");
             }
 
             companyInfo.setCreditCode(creditCode);
             companyInfo.setCompanyName(companyName);
             companyInfo.setRegion(region);
-            if (StringUtils.isNotBlank(businessLicenseUrl)){
+            if (StringUtils.isNotBlank(businessLicenseUrl)) {
                 companyInfo.setBusinessLicenseUrl(businessLicenseUrl);
             }
             companyInfo.setType(type);
@@ -548,7 +558,7 @@ public class PersonInfoApiController {
             personInfo.setIdCard(idCard);
             personInfo.setPersonName(personName);
             personInfo.setPhone(phone);
-            if (StringUtils.isNotBlank(idCardUrl)){
+            if (StringUtils.isNotBlank(idCardUrl)) {
                 personInfo.setIdCardUrl(idCardUrl);
             }
             personInfoService.update(personInfo);
@@ -557,7 +567,7 @@ public class PersonInfoApiController {
             messageResult.setResult(true);
             messageResult.setCode(200);
         } catch (Exception ex) {
-            log.error(ex.getMessage(),ex);
+            log.error(ex.getMessage(), ex);
             messageResult.setCode(400);
             messageResult.setResult(false);
             messageResult.setMessage(ex.getMessage());
@@ -580,7 +590,6 @@ public class PersonInfoApiController {
         try {
 
 
-
             BASE64Decoder decoder = new BASE64Decoder();
 
             String[] arr = photoBase64Data.split(",");
@@ -625,15 +634,15 @@ public class PersonInfoApiController {
 
             WeatherDTO weatherDTO = null;
             Map<String, Object> dataMap = new HashMap<String, Object>();
-            dataMap.put("city",cityName);
+            dataMap.put("city", cityName);
 
-            String result = HttpUtil.get("http://wthrcdn.etouch.cn/weather_mini",dataMap);
+            String result = HttpUtil.get("http://wthrcdn.etouch.cn/weather_mini", dataMap);
             JSONObject jsonObject = JSONObject.fromObject(result);
 
             JSONObject jsonObject1 = jsonObject.getJSONObject("data");
 
             List<WeatherDTO> weatherList = com.alibaba.fastjson.JSONObject.parseArray(jsonObject1.getString("forecast"), WeatherDTO.class);
-            if (weatherList.size()>0){
+            if (weatherList.size() > 0) {
                 weatherDTO = weatherList.get(0);
                 weatherDTO.setHigh(weatherDTO.getHigh().substring(3));
                 weatherDTO.setLow(weatherDTO.getLow().substring(3));
@@ -642,7 +651,7 @@ public class PersonInfoApiController {
             messageResult.setResult(true);
             messageResult.setCode(200);
         } catch (Exception ex) {
-            log.error(ex.getMessage(),ex);
+            log.error(ex.getMessage(), ex);
             messageResult.setCode(400);
             messageResult.setResult(false);
             messageResult.setMessage(ex.getMessage());