huanghongfa
2021-07-31 802bbc9b1a26334607b04ab562e62594e383d2c2
springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/CommonApi.java
@@ -1,17 +1,20 @@
package com.panzhihua.applets.api;
import cn.binarywang.wx.miniapp.api.WxMaSecCheckService;
import com.alibaba.fastjson.JSON;
import com.panzhihua.applets.config.WxMaConfiguration;
import com.panzhihua.common.constants.Constants;
import com.panzhihua.common.constants.FtpConstants;
import com.panzhihua.common.constants.UserConstants;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.WeatherVO;
import com.panzhihua.common.model.vos.user.UserPhoneVO;
import com.panzhihua.common.service.community.CommunityService;
import com.panzhihua.common.utlis.HttpUtils;
import com.panzhihua.common.utlis.SFTPUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import org.apache.commons.lang3.RandomUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
@@ -107,15 +110,16 @@
            InputStream is = file.getInputStream();
            file.transferTo(file1);
            try {
                boolean b = wxMaSecCheckService.checkImage(file1);
//                boolean b = wxMaSecCheckService.checkImage(file1);
                boolean delete = file1.delete();
                log.info("临时文件删除【{}】", delete);
                if (!b) {
                    return R.fail("图片内容违规");
                }
            } catch (WxErrorException e) {
//                if (!b) {
//                    return R.fail("图片内容违规");
//                }
            } catch (Exception e) {
                log.error("微信审核图片出错【{}】", e.getMessage());
                e.printStackTrace();
                return R.fail("图片上传失败");
//                e.printStackTrace();
            }
            sftp.uploadMore(FtpConstants.FTPFILEPATH_IDCARD, name, is);
            sftp.logout();
@@ -141,6 +145,16 @@
        return R.ok(nextInt);
    }
    @ApiOperation(value = "获取天气",response = WeatherVO.class)
    @GetMapping(value = "/getWeather/noToken")
    public R getWeather(){
        //获取请求url
        String url = Constants.G_D_WEATHER_URL;
        //获取请求参数
        String param = "key=" + Constants.G_D_WEATHER_KEY + "&city=510400";
        String result = HttpUtils.sendGet(url,param);
        return R.ok(JSON.parseObject(result));
    }
    public static void main(String[] args) {
//        int nextInt = RandomUtils.nextInt(99999, 1000000);