Bläddra i källkod

小程序登录

plf 4 år sedan
förälder
incheckning
499fee06e6

+ 41 - 1
caimei-applets-weisha-api.iml

@@ -103,7 +103,7 @@
     <orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.6.2" level="project" />
     <orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.6.2" level="project" />
     <orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:3.3.3" level="project" />
-    <orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy:1.10.14" level="project" />
+    <orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.10.14" level="project" />
     <orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.10.14" level="project" />
     <orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.6" level="project" />
     <orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-junit-jupiter:3.3.3" level="project" />
@@ -124,5 +124,45 @@
     <orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:2.0" level="project" />
     <orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.6" level="project" />
     <orderEntry type="library" name="Maven: caimei:smsClient:1.0" level="project" />
+    <orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-spring-boot-starter:3.0.2" level="project" />
+    <orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-spring-boot-autoconfigure:3.0.2" level="project" />
+    <orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-spring:3.0.2" level="project" />
+    <orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-annotations:3.0.2" level="project" />
+    <orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.22" level="project" />
+    <orderEntry type="library" name="Maven: io.swagger.core.v3:swagger-annotations:2.1.2" level="project" />
+    <orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-core:3.0.2" level="project" />
+    <orderEntry type="library" name="Maven: org.javassist:javassist:3.25.0-GA" level="project" />
+    <orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:3.0.0" level="project" />
+    <orderEntry type="library" name="Maven: io.springfox:springfox-spi:3.0.0" level="project" />
+    <orderEntry type="library" name="Maven: io.springfox:springfox-schema:3.0.0" level="project" />
+    <orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:3.0.0" level="project" />
+    <orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:3.0.0" level="project" />
+    <orderEntry type="library" name="Maven: io.github.classgraph:classgraph:4.8.83" level="project" />
+    <orderEntry type="library" name="Maven: io.springfox:springfox-spring-webflux:3.0.0" level="project" />
+    <orderEntry type="library" scope="RUNTIME" name="Maven: org.mapstruct:mapstruct:1.3.1.Final" level="project" />
+    <orderEntry type="library" name="Maven: io.springfox:springfox-spring-webmvc:3.0.0" level="project" />
+    <orderEntry type="library" name="Maven: io.springfox:springfox-core:3.0.0" level="project" />
+    <orderEntry type="library" name="Maven: io.springfox:springfox-oas:3.0.0" level="project" />
+    <orderEntry type="library" name="Maven: io.swagger.core.v3:swagger-models:2.1.2" level="project" />
+    <orderEntry type="library" name="Maven: io.springfox:springfox-bean-validators:3.0.0" level="project" />
+    <orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.22" level="project" />
+    <orderEntry type="library" name="Maven: io.swagger:swagger-core:1.5.22" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.10" level="project" />
+    <orderEntry type="library" name="Maven: com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.11.2" level="project" />
+    <orderEntry type="library" name="Maven: com.google.guava:guava:27.0.1-android" level="project" />
+    <orderEntry type="library" name="Maven: com.google.guava:failureaccess:1.0.1" level="project" />
+    <orderEntry type="library" name="Maven: com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava" level="project" />
+    <orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
+    <orderEntry type="library" name="Maven: org.checkerframework:checker-compat-qual:2.5.2" level="project" />
+    <orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.2.0" level="project" />
+    <orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.1" level="project" />
+    <orderEntry type="library" name="Maven: org.codehaus.mojo:animal-sniffer-annotations:1.17" level="project" />
+    <orderEntry type="library" name="Maven: javax.validation:validation-api:2.0.1.Final" level="project" />
+    <orderEntry type="library" name="Maven: io.springfox:springfox-boot-starter:3.0.0" level="project" />
+    <orderEntry type="library" name="Maven: io.springfox:springfox-data-rest:3.0.0" level="project" />
+    <orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:2.0.0.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:2.0.0.RELEASE" level="project" />
+    <orderEntry type="library" name="Maven: com.github.xiaoymin:knife4j-spring-ui:3.0.2" level="project" />
   </component>
 </module>

+ 5 - 1
pom.xml

@@ -112,9 +112,13 @@
             <version>1.0</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.github.xiaoymin</groupId>
+            <artifactId>knife4j-spring-boot-starter</artifactId>
+            <version>3.0.2</version>
+        </dependency>
     </dependencies>
 
-
     <profiles>
         <profile>
             <id>dev</id>

+ 51 - 0
src/main/java/com/caimei/config/SwaggerConfig.java

@@ -0,0 +1,51 @@
+package com.caimei.config;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.oas.annotations.EnableOpenApi;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+
+/**
+ * `@EnableOpenApi`: 用于开启Swagger的自动配置
+ *
+ * @author Aslee
+ * @date 2021/3/10
+ */
+@EnableOpenApi
+@Configuration
+public class SwaggerConfig {
+    @Value(value = "${swagger.enabled}")
+    Boolean swaggerEnabled;
+
+    @Bean
+    public Docket createRestApi() {
+        return new Docket(DocumentationType.SWAGGER_2)
+                .apiInfo(apiInfo())
+                // 是否开启swagger
+                .enable(swaggerEnabled)
+                .select()
+                // 扫描api
+                .apis(RequestHandlerSelectors.basePackage("com.caimei.controller"))
+                .paths(PathSelectors.any())
+                .build();
+    }
+
+    private ApiInfo apiInfo() {
+        return new ApiInfoBuilder().
+                // 标题
+                        title("weisha")
+                // 描述
+                .description("weisha")
+                // 服务地址
+                .termsOfServiceUrl("https://www.caimei365.com")
+                // 版本号
+                .version("1.0.0")
+                .build();
+    }
+}

+ 50 - 0
src/main/java/com/caimei/controller/LoginApi.java

@@ -0,0 +1,50 @@
+package com.caimei.controller;
+
+import com.caimei.model.ResponseJson;
+import com.caimei.model.dto.BuyerUserDto;
+import com.caimei.model.vo.BuyerUserVo;
+import com.caimei.service.LoginService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/22
+ */
+@RestController
+@RequestMapping("/buyer")
+public class LoginApi {
+
+    private LoginService loginService;
+
+    @Autowired
+    public void setLoginService(LoginService loginService) {
+        this.loginService = loginService;
+    }
+
+    /**
+     * 小程序授权登录
+     *
+     * @param code 小程序登录唯一凭证
+     */
+    @PostMapping("/authorization")
+    public ResponseJson<BuyerUserVo> authorizationLogin(String code) {
+        if (StringUtils.isEmpty(code)) {
+            return ResponseJson.error("参数异常", null);
+        }
+        return loginService.authorizationLogin(code);
+    }
+
+    /**
+     * 邀请码登录
+     */
+    @PostMapping("/invitation/code")
+    public ResponseJson<BuyerUserVo> invitationCode(BuyerUserDto buyerUserDto) {
+        return loginService.invitationCode(buyerUserDto);
+    }
+}

+ 20 - 0
src/main/java/com/caimei/mapper/LoginMapper.java

@@ -0,0 +1,20 @@
+package com.caimei.mapper;
+
+import com.caimei.model.vo.BuyerUserVo;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/22
+ */
+@Mapper
+public interface LoginMapper {
+    /**
+     * 查询采购员
+     * @param openid
+     * @return
+     */
+    BuyerUserVo findBuyer(String openid);
+}

+ 21 - 0
src/main/java/com/caimei/model/dto/BuyerUserDto.java

@@ -0,0 +1,21 @@
+package com.caimei.model.dto;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/22
+ */
+public class BuyerUserDto {
+    /**
+     * 邀请码
+     */
+    private String invitationCode;
+
+    /**
+     * 小程序openid
+     */
+    private String openid;
+
+
+}

+ 78 - 0
src/main/java/com/caimei/model/po/CmOrganizeBuyerPo.java

@@ -0,0 +1,78 @@
+package com.caimei.model.po;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * cm_organize_buyer
+ *
+ * @author
+ */
+@Data
+public class CmOrganizeBuyerPo implements Serializable {
+    private Integer id;
+
+    /**
+     * 组织id
+     */
+    private Integer organizeId;
+
+    /**
+     * 采购员名称
+     */
+    private String name;
+
+    /**
+     * 手机号
+     */
+    private String mobile;
+
+    /**
+     * 邀请码
+     */
+    private String invitationCode;
+
+    /**
+     * 1未绑定,2已绑定
+     */
+    private String status;
+
+    /**
+     * 微信昵称
+     */
+    private String nickName;
+
+    /**
+     * 小程序openid
+     */
+    private String openid;
+
+    /**
+     * 添加时间
+     */
+    private Date addTime;
+
+    /**
+     * 邀请码有效截止时间
+     */
+    private Date invitationCodeTime;
+
+    /**
+     * 绑定时间
+     */
+    private Date bindTime;
+
+    /**
+     * 更新时间
+     */
+    private Date updateTime;
+
+    /**
+     * 0 有效 其它无效
+     */
+    private String delFlag;
+
+    private static final long serialVersionUID = 1L;
+}

+ 27 - 0
src/main/java/com/caimei/model/vo/BuyerUserVo.java

@@ -0,0 +1,27 @@
+package com.caimei.model.vo;
+
+import lombok.Data;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/22
+ */
+@Data
+public class BuyerUserVo {
+    /**
+     * 组织id
+     */
+    private Integer organizeId;
+
+    /**
+     * 采购员名称
+     */
+    private String name;
+
+    /**
+     * 小程序openid
+     */
+    private String openid;
+}

+ 0 - 127
src/main/java/com/caimei/service/HomePageService.java

@@ -1,127 +0,0 @@
-/*
-package com.caimei365.service;
-
-import com.caimei.module.base.entity.bo.JsonModel;
-import com.caimei.module.base.entity.bo.PageVo;
-
-*/
-/**
- * Description
- *
- * @author : Charles
- * @date : 2020/3/20
- *//*
-
-public interface HomePageService {
-    */
-/**
-     * 医美机构正品联盟
-     *//*
-
-    JsonModel getMember(PageVo pageVo);
-
-    */
-/**
-     * 售后无忧,购物须知
-     *//*
-
-    JsonModel afterSale();
-
-    */
-/**
-     * 获取模块数据
-     *//*
-
-    JsonModel getModules(Integer userId);
-
-    JsonModel productsClassify(Integer classifyId, Integer userId, PageVo page);
-
-    */
-/**
-     * 首页推荐专区
-     *//*
-
-    JsonModel getRecommendProducts(Integer identity);
-
-
-    */
-/**
-     * 新版首页数据
-     *//*
-
-    JsonModel getHomeData(Integer userId, Integer source);
-
-
-    */
-/**
-     * 首页直播/文章/活动置顶数据
-     *
-     * @param source
-     * @return
-     *//*
-
-    JsonModel getTopData(Integer source);
-
-
-    */
-/**
-     * 首页轮播图列表
-     *
-     * @return
-     *//*
-
-    JsonModel getHomeBanners();
-
-    */
-/**
-     * 楼层详情
-     *
-     * @param floorId 楼层id
-     * @param source  来源 : 1 网站 ; 2 小程序
-     * @return
-     *//*
-
-    JsonModel floorContentDetails(Integer floorId, Integer source, Integer userId);
-
-    */
-/**
-     * 产品,仪器数据
-     *
-     * @param pageId 页面信息id
-     * @param userId 用户id
-     * @param source 来源 : 1 网站 ; 2 小程序
-     * @return
-     *//*
-
-    JsonModel instrumentData(Integer pageId, Integer userId, Integer source);
-
-    */
-/**
-     * 页面信息商品楼层
-     *
-     * @param centreId 页面信息楼层id
-     * @param source   来源
-     * @param userId
-     * @return
-     *//*
-
-    JsonModel pageFloorDetails(Integer centreId, Integer source, Integer userId);
-
-    */
-/**
-     * 产品仪器热搜词
-     *
-     * @return
-     *//*
-
-    JsonModel hotSearchTerms();
-
-    */
-/**
-     * 直播宣传图
-     * @return
-     *//*
-
-    JsonModel getLiveAdvertisingImage();
-}
-*/

+ 30 - 0
src/main/java/com/caimei/service/LoginService.java

@@ -0,0 +1,30 @@
+package com.caimei.service;
+
+import com.caimei.model.ResponseJson;
+import com.caimei.model.dto.BuyerUserDto;
+import com.caimei.model.vo.BuyerUserVo;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/22
+ */
+public interface LoginService {
+
+    /**
+     * 小程序授权登录
+     *
+     * @param code
+     * @return
+     */
+    ResponseJson<BuyerUserVo> authorizationLogin(String code);
+
+    /**
+     * 邀请码登录
+     *
+     * @param buyerUserDto
+     * @return
+     */
+    ResponseJson<BuyerUserVo> invitationCode(BuyerUserDto buyerUserDto);
+}

+ 81 - 0
src/main/java/com/caimei/service/impl/LoginServiceImpl.java

@@ -0,0 +1,81 @@
+package com.caimei.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.caimei.mapper.LoginMapper;
+import com.caimei.model.ResponseJson;
+import com.caimei.model.dto.BuyerUserDto;
+import com.caimei.model.vo.BuyerUserVo;
+import com.caimei.service.LoginService;
+import com.caimei.util.HttpRequest;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/3/22
+ */
+@Slf4j
+@Service
+public class LoginServiceImpl implements LoginService {
+    @Resource
+    private LoginMapper loginMapper;
+
+    @Value("${wx.AppId}")
+    private String appId;
+
+    @Value("${wx.AppSecret}")
+    private String appSecret;
+
+    @Override
+    public ResponseJson<BuyerUserVo> authorizationLogin(String code) {
+        String requestUrl = "https://api.weixin.qq.com/sns/jscode2session";
+        Map<String, String> requestUrlParam = new HashMap<>(4);
+        //小程序appId
+        requestUrlParam.put("appid", appId);
+        //小程序appSecret
+        requestUrlParam.put("secret", appSecret);
+        //小程序端返回的code
+        requestUrlParam.put("js_code", code);
+        //默认参数
+        requestUrlParam.put("grant_type", "authorization_code");
+        //发送post请求读取调用微信接口获取openid用户唯一标识
+        String infos;
+        try {
+            infos = HttpRequest.sendPost(requestUrl, requestUrlParam);
+        } catch (Exception e) {
+            log.info("微信服务器异常", e);
+            return ResponseJson.error("微信服务器异常", null);
+        }
+        //解析相应内容(转换成json对象)
+        JSONObject jsonObject = JSON.parseObject(infos);
+        String openid = jsonObject.getString("openid");
+        log.info("小程序openid----->" + openid);
+        String errCode = jsonObject.getString("errcode");
+        String errMsg = jsonObject.getString("errmsg");
+        if (!StringUtils.isEmpty(errCode) && ("-1".equals(errCode) || "40029".equals(errCode) || "45011".equals(errCode))) {
+            log.error(errMsg);
+            return ResponseJson.error("授权登录失败", null);
+        }
+        BuyerUserVo buyerUser = loginMapper.findBuyer(openid);
+        if (buyerUser == null) {
+            buyerUser = new BuyerUserVo();
+            buyerUser.setOpenid(openid);
+            return ResponseJson.error("未绑定微信", buyerUser);
+        }
+        return ResponseJson.success(buyerUser);
+    }
+
+    @Override
+    public ResponseJson<BuyerUserVo> invitationCode(BuyerUserDto buyerUserDto) {
+        return null;
+    }
+}

+ 240 - 0
src/main/java/com/caimei/util/HttpRequest.java

@@ -0,0 +1,240 @@
+package com.caimei.util;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * HTTP 请求工具
+ */
+public class HttpRequest {
+    /**
+     * 向指定URL发送GET方法的请求
+     *
+     * @param url   发送请求的URL
+     * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
+     * @return URL 所代表远程资源的响应结果
+     * @throws Exception
+     */
+    @SuppressWarnings("unused")
+    public static String sendGetWithParameter(String url, String param) throws Exception {
+        StringBuffer result=new StringBuffer();
+        BufferedReader in = null;
+        try {
+            String urlNameString = url + "?" + param;
+            URL realUrl = new URL(urlNameString);
+            // 打开和URL之间的连接
+            URLConnection connection = realUrl.openConnection();
+            // 设置通用的请求属性
+            connection.setRequestProperty("accept", "*/*");
+            connection.setRequestProperty("connection", "Keep-Alive");
+            connection.setRequestProperty("Accept-Charset", "utf-8");
+            connection.setRequestProperty("contentType", "utf-8");
+            connection.setConnectTimeout(5000);
+            // 建立实际的连接
+            connection.connect();
+            // 获取所有响应头字段
+            Map<String, List<String>> map = connection.getHeaderFields();
+            // 遍历所有的响应头字段
+            for (String key : map.keySet()) {
+                // System.out.println(key + "--->" + map.get(key)); //关闭响应头的输出
+            }
+            // 定义 BufferedReader输入流来读取URL的响应
+            in = new BufferedReader(new InputStreamReader(
+                    connection.getInputStream()));
+            String line;
+            while ((line = in.readLine()) != null) {
+                result.append(line);
+            }
+        } catch (Exception e) {
+            throw e;
+        }
+        // 使用finally块来关闭输入流
+        finally {
+            try {
+                if (in != null) {
+                    in.close();
+                }
+            } catch (Exception e2) {
+                throw e2;
+            }
+        }
+        return result.toString();
+    }
+
+
+    @SuppressWarnings("unused")
+    public static String sendGet(String url) throws Exception {
+        StringBuffer result=new StringBuffer();
+        BufferedReader in = null;
+        try {
+
+            URL realUrl = new URL(url);
+            // 打开和URL之间的连接
+            URLConnection connection = realUrl.openConnection();
+            // 设置通用的请求属性
+            connection.setRequestProperty("accept", "*/*");
+            connection.setRequestProperty("connection", "Keep-Alive");
+            connection.setRequestProperty("Accept-Charset", "utf-8");
+            connection.setRequestProperty("contentType", "utf-8");
+            connection.setConnectTimeout(5000);
+            // 建立实际的连接
+            connection.connect();
+            // 获取所有响应头字段
+            Map<String, List<String>> map = connection.getHeaderFields();
+            // 遍历所有的响应头字段
+            for (String key : map.keySet()) {
+                //  System.out.println(key + "--->" + map.get(key));
+            }
+            // 定义 BufferedReader输入流来读取URL的响应
+            in = new BufferedReader(new InputStreamReader(
+                    connection.getInputStream()));
+            String line;
+            while ((line = in.readLine()) != null) {
+                result.append(line);
+            }
+        } catch (Exception e) {
+            throw e;
+        }
+        // 使用finally块来关闭输入流
+        finally {
+            try {
+                if (in != null) {
+                    in.close();
+                }
+            } catch (Exception e2) {
+                throw e2;
+            }
+        }
+        return result.toString();
+    }
+
+    /**
+     * 向指定 URL 发送POST方法的请求
+     *
+     * @param url   发送请求的 URL
+     * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
+     * @return 所代表远程资源的响应结果
+     * @throws Exception
+     */
+    public static String sendPost(String url, String param) throws Exception {
+        PrintWriter out = null;
+        BufferedReader in = null;
+        StringBuffer result=new StringBuffer();
+        try {
+            URL realUrl = new URL(url);
+            // 打开和URL之间的连接
+            URLConnection conn = realUrl.openConnection();
+            // 设置通用的请求属性
+            conn.setRequestProperty("accept", "*/*");
+            conn.setRequestProperty("connection", "Keep-Alive");
+            conn.setRequestProperty("Accept-Charset", "utf-8");
+            conn.setRequestProperty("contentType", "utf-8");
+            conn.setConnectTimeout(5000);
+            // 发送POST请求必须设置如下两行
+            conn.setDoOutput(true);
+            conn.setDoInput(true);
+            // 获取URLConnection对象对应的输出流
+            out = new PrintWriter(conn.getOutputStream());
+            // 发送请求参数
+            out.print(param);
+            // flush输出流的缓冲
+            out.flush();
+            // 定义BufferedReader输入流来读取URL的响应
+            in = new BufferedReader(
+                    new InputStreamReader(conn.getInputStream()));
+            String line;
+            while ((line = in.readLine()) != null) {
+                result.append(line);
+            }
+        } catch (Exception e) {
+            throw e;
+        }
+        //使用finally块来关闭输出流、输入流
+        finally {
+            try {
+                if (out != null) {
+                    out.close();
+                }
+                if (in != null) {
+                    in.close();
+                }
+            } catch (Exception ex) {
+                throw ex;
+            }
+        }
+        return result.toString();
+    }
+
+
+    /**
+     * 向指定 URL 发送POST方法的请求
+     *
+     * @param url 发送请求的 URL
+     * @param paramMap 请求参数
+     * @return 所代表远程资源的响应结果
+     */
+    public static String sendPost(String url, Map<String, ?> paramMap) throws Exception{
+        PrintWriter out = null;
+        BufferedReader in = null;
+        String result = "";
+
+        String param = "";
+        Iterator<String> it = paramMap.keySet().iterator();
+
+        while(it.hasNext()) {
+            String key = it.next();
+            param += key + "=" + paramMap.get(key) + "&";
+        }
+
+        try {
+            URL realUrl = new URL(url);
+            // 打开和URL之间的连接
+            URLConnection conn = realUrl.openConnection();
+            // 设置通用的请求属性
+            conn.setRequestProperty("accept", "*/*");
+            conn.setRequestProperty("connection", "Keep-Alive");
+            conn.setRequestProperty("Accept-Charset", "utf-8");
+            conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
+            // 发送POST请求必须设置如下两行
+            conn.setDoOutput(true);
+            conn.setDoInput(true);
+            // 获取URLConnection对象对应的输出流
+            out = new PrintWriter(conn.getOutputStream());
+            // 发送请求参数
+            out.print(param);
+            // flush输出流的缓冲
+            out.flush();
+            // 定义BufferedReader输入流来读取URL的响应
+            in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
+            String line;
+            while ((line = in.readLine()) != null) {
+                result += line;
+            }
+        } catch (Exception e) {
+            throw e;
+        }
+        //使用finally块来关闭输出流、输入流
+        finally{
+            try{
+                if(out!=null){
+                    out.close();
+                }
+                if(in!=null){
+                    in.close();
+                }
+            }
+            catch(IOException ex){
+               throw ex;
+            }
+        }
+        return result;
+    }
+
+}

+ 1 - 10
src/main/resources/config/beta/application-beta.yml

@@ -51,14 +51,5 @@ logging:
 
 # swagger文档显示配置
 swagger:
-  enable: false
+  enabled: false
 
-#DFS配置
-fdfs:
-  so-timeout: 5000 #上传的超时时间
-  connect-timeout: 2000 #连接超时时间
-  thumb-image:             #缩略图生成参数
-    width: 150
-    height: 150
-  tracker-list:            #TrackerList参数,支持多个
-  - 10.104.50.235:22122

+ 5 - 11
src/main/resources/config/dev/application-dev.yml

@@ -52,15 +52,9 @@ logging:
 
 # swagger文档显示配置
 swagger:
-  enable: true
+  enabled: true
 
-
-#DFS配置
-fdfs:
-  so-timeout: 5000 #上传的超时时间
-  connect-timeout: 2000 #连接超时时间
-  thumb-image:             #缩略图生成参数
-    width: 150
-    height: 150
-  tracker-list:            #TrackerList参数,支持多个
-  - 119.29.0.46:22122
+#自定义配置
+wx:
+  AppId: wxca7172d7a20bdf7a
+  AppSecret: 7fa931d8eb126efc3aff935b879f595f

+ 1 - 10
src/main/resources/config/prod/application-prod.yml

@@ -51,15 +51,6 @@ logging:
 
 # swagger文档显示配置
 swagger:
-  enable: false
+  enabled: false
 
-#DFS配置
-fdfs:
-  so-timeout: 5000 #上传的超时时间
-  connect-timeout: 2000 #连接超时时间
-  thumb-image:             #缩略图生成参数
-    width: 150
-    height: 150
-  tracker-list:            #TrackerList参数,支持多个
-  - 172.31.165.24:22122
 

+ 17 - 0
src/main/resources/mapper/LoginMapper.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.caimei.mapper.LoginMapper">
+    <select id="findBuyer" resultType="com.caimei.model.vo.BuyerUserVo">
+        SELECT
+          organizeId,
+          name,
+          openid
+        FROM
+          cm_organize_buyer
+        WHERE
+          delFlag = 0
+          AND openid = #{openid}
+    </select>
+</mapper>