fllmoyu 4 anos atrás
pai
commit
16ffa4ce33

+ 30 - 0
common/src/main/java/com/jpsoft/enterprise/modules/base/dto/WeatherDTO.java

@@ -0,0 +1,30 @@
+package com.jpsoft.enterprise.modules.base.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2021-1-6 16:43
+ */
+@Data
+public class WeatherDTO {
+
+    @ApiModelProperty(value = "日期")
+    private String date;
+
+    @ApiModelProperty(value = "高温")
+    private String high;
+
+    @ApiModelProperty(value = "风力")
+    private String fengli;
+
+    @ApiModelProperty(value = "低温")
+    private String low;
+
+    @ApiModelProperty(value = "风向")
+    private String fengxiang;
+
+    @ApiModelProperty(value = "状态")
+    private String type;
+}

+ 2 - 0
web/src/main/java/com/jpsoft/enterprise/config/WebMvcConfig.java

@@ -58,6 +58,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
 				.excludePathPatterns("/mobile/personInfoApi/loginByPassword")
 				.excludePathPatterns("/mobile/personInfoApi/validateCode")
 				.excludePathPatterns("/mobile/personInfoApi/findByOpenId")
+				.excludePathPatterns("/mobile/personInfoApi/getWeather")
                 .excludePathPatterns("/mobile/companyInfoApi/companyNum")
 				.excludePathPatterns("/mobile/newsInfoApi/firstLevelDirectory")
 				.excludePathPatterns("/mobile/newsInfoApi/secondLevelDirectory")
@@ -68,6 +69,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
 				.excludePathPatterns("/mobile/companyInfoApi/companyDetail")
 				.excludePathPatterns("/mobile/companyInfoApi/attributeList")
 				.excludePathPatterns("/mobile/companyInfoApi/industryList")
+				.excludePathPatterns("/mobile/enterpriseInfoApi/enterpriseInfo")
         ;
 	}
 }

+ 57 - 0
web/src/main/java/com/jpsoft/enterprise/modules/mobile/controller/EnterpriseInfoApiController.java

@@ -0,0 +1,57 @@
+package com.jpsoft.enterprise.modules.mobile.controller;
+
+import com.jpsoft.enterprise.modules.base.entity.CompanyInfo;
+import com.jpsoft.enterprise.modules.base.entity.EnterpriseInfo;
+import com.jpsoft.enterprise.modules.base.service.EnterpriseInfoService;
+import com.jpsoft.enterprise.modules.common.dto.MessageResult;
+import io.swagger.annotations.ApiOperation;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2021-1-6 14:19
+ */
+@RestController
+@RequestMapping("/mobile/enterpriseInfoApi")
+@Slf4j
+public class EnterpriseInfoApiController {
+
+    @Autowired
+    private EnterpriseInfoService enterpriseInfoService;
+
+
+
+    @PostMapping("enterpriseInfo")
+    @ApiOperation(value = "企联信息(公开接口)")
+    public MessageResult<Map> enterpriseInfo() {
+        MessageResult<Map> messageResult = new MessageResult<>();
+
+        try {
+
+            Map<String, Object> map = new HashMap<>();
+            EnterpriseInfo enterpriseInfo = enterpriseInfoService.get("1");
+
+            map.put("enterpriseInfo", enterpriseInfo);
+
+            messageResult.setData(map);
+            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;
+    }
+}

+ 97 - 0
web/src/main/java/com/jpsoft/enterprise/modules/mobile/controller/PersonInfoApiController.java

@@ -1,9 +1,12 @@
 package com.jpsoft.enterprise.modules.mobile.controller;
 
+import cn.hutool.Hutool;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
+import cn.hutool.http.HttpUtil;
 import com.jpsoft.enterprise.config.OSSConfig;
 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.PersonInfo;
 import com.jpsoft.enterprise.modules.base.service.MessageReceiverService;
@@ -20,6 +23,7 @@ import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import net.sf.json.JSONObject;
 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.Value;
 import org.springframework.data.redis.core.ValueOperations;
@@ -31,6 +35,7 @@ import sun.security.provider.MD5;
 import java.io.ByteArrayInputStream;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 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")
     @ApiOperation(value = "获取个人信息(公开接口)")
@@ -549,4 +609,41 @@ public class PersonInfoApiController {
         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;
+    }
+
+
 }