|
@@ -1,9 +1,12 @@
|
|
|
package com.jpsoft.enterprise.modules.mobile.controller;
|
|
package com.jpsoft.enterprise.modules.mobile.controller;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.Hutool;
|
|
|
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 cn.hutool.http.HttpUtil;
|
|
|
import com.jpsoft.enterprise.config.OSSConfig;
|
|
import com.jpsoft.enterprise.config.OSSConfig;
|
|
|
import com.jpsoft.enterprise.modules.base.dto.CompanyInfoDetailDTO;
|
|
import com.jpsoft.enterprise.modules.base.dto.CompanyInfoDetailDTO;
|
|
|
|
|
+import com.jpsoft.enterprise.modules.base.dto.WeatherDTO;
|
|
|
import com.jpsoft.enterprise.modules.base.entity.CompanyInfo;
|
|
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;
|
|
@@ -20,6 +23,7 @@ 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;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
+import org.apache.poi.ddf.NullEscherSerializationListener;
|
|
|
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.data.redis.core.ValueOperations;
|
|
import org.springframework.data.redis.core.ValueOperations;
|
|
@@ -31,6 +35,7 @@ import sun.security.provider.MD5;
|
|
|
import java.io.ByteArrayInputStream;
|
|
import java.io.ByteArrayInputStream;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
@@ -255,6 +260,61 @@ public class PersonInfoApiController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ @PostMapping("validateCodeAndUpdatePhone")
|
|
|
|
|
+ @ApiOperation(value = "验证短信验证码并修改手机号")
|
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
|
+ @ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form"),
|
|
|
|
|
+ @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form"),
|
|
|
|
|
+ @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) {
|
|
|
|
|
+
|
|
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+
|
|
|
|
|
+ PersonInfo personInfo = personInfoService.get(subject);
|
|
|
|
|
+ if (personInfo == null){
|
|
|
|
|
+ throw new Exception("用户不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (personInfo.getPhone().equals(phone)){
|
|
|
|
|
+ throw new Exception("请修改手机号");
|
|
|
|
|
+ }
|
|
|
|
|
+ String smsKey = "SMS_" + personInfo.getId();
|
|
|
|
|
+
|
|
|
|
|
+ String beforeVerifyCode = (String) valueOperations.get(smsKey);
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isEmpty(beforeVerifyCode)) {
|
|
|
|
|
+ throw new Exception("验证码已过期!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!beforeVerifyCode.equals(code)) {
|
|
|
|
|
+ throw new Exception("验证码错误!");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> dataMap = new HashMap<String, Object>();
|
|
|
|
|
+
|
|
|
|
|
+ personInfo.setPhone(phone);
|
|
|
|
|
+ personInfo.setUpdateTime(new Date());
|
|
|
|
|
+ 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("findByOpenId")
|
|
@PostMapping("findByOpenId")
|
|
|
@ApiOperation(value = "获取个人信息(公开接口)")
|
|
@ApiOperation(value = "获取个人信息(公开接口)")
|
|
@@ -549,4 +609,41 @@ public class PersonInfoApiController {
|
|
|
return messageResult;
|
|
return messageResult;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @PostMapping("getWeather")
|
|
|
|
|
+ @ApiOperation(value = "获取当前城市的天气(公共接口)")
|
|
|
|
|
+ public MessageResult<WeatherDTO> getCity(String cityName) {
|
|
|
|
|
+
|
|
|
|
|
+ MessageResult<WeatherDTO> messageResult = new MessageResult<>();
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+
|
|
|
|
|
+ WeatherDTO weatherDTO = null;
|
|
|
|
|
+ Map<String, Object> dataMap = new HashMap<String, Object>();
|
|
|
|
|
+ dataMap.put("city",cityName);
|
|
|
|
|
+
|
|
|
|
|
+ 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){
|
|
|
|
|
+ weatherDTO = weatherList.get(0);
|
|
|
|
|
+ weatherDTO.setHigh(weatherDTO.getHigh().substring(3));
|
|
|
|
|
+ weatherDTO.setLow(weatherDTO.getLow().substring(3));
|
|
|
|
|
+ }
|
|
|
|
|
+ messageResult.setData(weatherDTO);
|
|
|
|
|
+ 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;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|