PLF 5 lat temu
rodzic
commit
a3f2276ab2

+ 171 - 0
src/main/java/com/caimei/controller/user/LoginController.java

@@ -0,0 +1,171 @@
+package com.caimei.controller.user;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.caimei.entity.CmOperationUser;
+import com.caimei.entity.WxJsonModel;
+import com.caimei.service.user.LoginService;
+import com.caimei.utils.HttpRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Controller;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 登录
+ */
+@Controller
+@RequestMapping("/login")
+public class LoginController {
+    @Autowired
+    private LoginService loginService;
+
+    @Value("${miniprogram.AppId}")
+    private String AppId;
+
+    @Value("${miniprogram.AppSecret}")
+    private String AppSecret;
+
+    /**
+     * 判断是否是游客
+     *
+     * @param code
+     * @param request
+     * @return
+     */
+    @ResponseBody
+    @RequestMapping("/doLogin")
+    public WxJsonModel doLogin(@RequestParam(value = "code", required = true) String code,
+                               @RequestParam(value = "userOrganizeID") Integer userOrganizeID,
+                               HttpServletRequest request) {
+        WxJsonModel res = WxJsonModel.newInstance();
+        Map<String, Object> map = new HashMap<>();
+        String referer = request.getHeader("Referer"); //获取当前微信小程序的环境
+        map.put("referer", referer);
+        String requestUrl = "https://api.weixin.qq.com/sns/jscode2session";
+        Map<String, String> requestUrlParam = new HashMap<String, String>();
+        requestUrlParam.put("appid", AppId);//小程序appId
+        requestUrlParam.put("secret", AppSecret);//小程序appsecret
+        requestUrlParam.put("js_code", code);//小程序端返回的code
+        requestUrlParam.put("grant_type", "authorization_code");//默认参数
+        //发送post请求读取调用微信接口获取openid用户唯一标识
+        String infos;
+        try {
+            infos = HttpRequest.sendPost(requestUrl, requestUrlParam);
+        } catch (Exception e) {
+            res.setData(map);
+            return res.error("服务器内部异常");
+        }
+        //解析相应内容(转换成json对象)
+        JSONObject jsonObject = JSON.parseObject(infos);
+        String openid = jsonObject.getString("openid");
+        String session_key = jsonObject.getString("session_key");
+        String errcode = jsonObject.getString("errcode");
+        String errmsg = jsonObject.getString("errmsg");
+        if (!StringUtils.isEmpty(errcode) &&
+                (errcode.equals("-1") || errcode.equals("40029") || errcode.equals("45011"))) {
+            res.setMsg(errmsg);
+            res.setData(map);
+            map.put("sessionKey", session_key);
+            res.setCode("-1");
+            return res;
+        }
+        CmOperationUser operationUser = loginService.doLogin(openid, userOrganizeID);
+        if (operationUser == null) {
+            return res.error("-1", "游客,请登录");
+        }
+        return res.error("1", "登录成功");
+    }
+
+    /**
+     * 判断邀请码是否有效
+     *
+     * @param invitationCode 邀请码
+     * @param userOrganizeID 组织id
+     * @return
+     */
+    @RequestMapping("/isEnabled")
+    @ResponseBody
+    public WxJsonModel isEnabled(String invitationCode, Integer userOrganizeID) {
+        WxJsonModel res = WxJsonModel.newInstance();
+        CmOperationUser operationUser = loginService.isEnabled(invitationCode, userOrganizeID);
+        if (operationUser == null) {
+            return res.error("-1", "邀请码错误");
+        }
+        Date date = new Date();
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(Calendar.DATE, 2);
+        if (operationUser.getStatus().equals("1") && date.getTime() > calendar.getTime().getTime() && operationUser.getDelFlag().equals('0')) {
+            return res.error("-1", "邀请码已失效");
+        }
+        if (operationUser.getStatus().equals("2") && operationUser.getDelFlag().equals("0")) {
+            return res.error("-1", "邀请码已被使用");
+        }
+        if (!operationUser.getDelFlag().equals("0")) {
+            return res.error("-1", "您的账号已下线");
+        }
+        if (operationUser.getClubStatus().equals("91")) {
+            return res.error("-1", "您所在的会所已下线");
+        }
+        return res.error("1", "邀请码通过");
+    }
+
+
+    /**
+     * 注册并登录
+     *
+     * @param code
+     * @param request
+     * @return
+     */
+    @RequestMapping("/register")
+    @ResponseBody
+    public WxJsonModel register(@RequestParam(value = "code", required = true) String code,
+                                CmOperationUser operationUser, HttpServletRequest request) {
+        WxJsonModel res = WxJsonModel.newInstance();
+        Map<String, Object> map = new HashMap<>();
+        String referer = request.getHeader("Referer"); //获取当前微信小程序的环境
+        map.put("referer", referer);
+        String requestUrl = "https://api.weixin.qq.com/sns/jscode2session";
+        Map<String, String> requestUrlParam = new HashMap<String, String>();
+        requestUrlParam.put("appid", AppId);//小程序appId
+        requestUrlParam.put("secret", AppSecret);//小程序appsecret
+        requestUrlParam.put("js_code", code);//小程序端返回的code
+        requestUrlParam.put("grant_type", "authorization_code");//默认参数
+        //发送post请求读取调用微信接口获取openid用户唯一标识
+        String infos;
+        try {
+            infos = HttpRequest.sendPost(requestUrl, requestUrlParam);
+        } catch (Exception e) {
+            res.setData(map);
+            return res.error("服务器内部异常");
+        }
+        //解析相应内容(转换成json对象)
+        JSONObject jsonObject = JSON.parseObject(infos);
+        String openid = jsonObject.getString("openid");
+        String session_key = jsonObject.getString("session_key");
+        String errcode = jsonObject.getString("errcode");
+        String errmsg = jsonObject.getString("errmsg");
+        if (!StringUtils.isEmpty(errcode) &&
+                (errcode.equals("-1") || errcode.equals("40029") || errcode.equals("45011"))) {
+            res.setMsg(errmsg);
+            res.setData(map);
+            map.put("sessionKey", session_key);
+            res.setCode("-1");
+            return res;
+        }
+        operationUser.setOpenid(openid);
+        loginService.update(operationUser);
+        return res.error("1", "注册并登录成功");
+    }
+}

+ 17 - 0
src/main/java/com/caimei/controller/user/PersonalController.java

@@ -0,0 +1,17 @@
+package com.caimei.controller.user;
+
+import com.caimei.service.user.PersonalService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * 个人中心
+ */
+@Controller
+@RequestMapping("/personal")
+public class PersonalController {
+    @Autowired
+    private PersonalService personalService;
+
+}

+ 151 - 0
src/main/java/com/caimei/entity/CmOperationUser.java

@@ -0,0 +1,151 @@
+package com.caimei.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+public class CmOperationUser implements Serializable {
+    private Integer id;
+    private Integer userOrganizeID;      //具体对应cm_user_organize表ID
+    private Integer clubID;              //会所ID:隶属于哪个会所的运营人员
+    private String mobile;              //手机号码
+    private String linkName;            //联系人
+    private String invitationCode;      //邀请码
+    private String status;              //1未绑定,2已绑定
+    private String nickName;            //微信昵称
+    private String openid;               //小程序openid
+    private Date invitationCodeTime;    //邀请码生成时间(此时间起48小时有效)
+    private Date bindTime;              //绑定时间
+    private Date updateTime;            //更新时间
+    private Date addTime;               //添加时间
+    private String delFlag;              //0 有效 其它无效
+    private String clubStatus;          //会所状态  (90, "已上线"),(91, "已冻结")
+    private Integer userID;             //用户ID:隶属于哪个用户的运营人员
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getUserOrganizeID() {
+        return userOrganizeID;
+    }
+
+    public void setUserOrganizeID(Integer userOrganizeID) {
+        this.userOrganizeID = userOrganizeID;
+    }
+
+    public Integer getClubID() {
+        return clubID;
+    }
+
+    public void setClubID(Integer clubID) {
+        this.clubID = clubID;
+    }
+
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+
+    public String getLinkName() {
+        return linkName;
+    }
+
+    public void setLinkName(String linkName) {
+        this.linkName = linkName;
+    }
+
+    public String getInvitationCode() {
+        return invitationCode;
+    }
+
+    public void setInvitationCode(String invitationCode) {
+        this.invitationCode = invitationCode;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    public String getNickName() {
+        return nickName;
+    }
+
+    public void setNickName(String nickName) {
+        this.nickName = nickName;
+    }
+
+    public String getOpenid() {
+        return openid;
+    }
+
+    public void setOpenid(String openid) {
+        this.openid = openid;
+    }
+
+    public Date getInvitationCodeTime() {
+        return invitationCodeTime;
+    }
+
+    public void setInvitationCodeTime(Date invitationCodeTime) {
+        this.invitationCodeTime = invitationCodeTime;
+    }
+
+    public Date getBindTime() {
+        return bindTime;
+    }
+
+    public void setBindTime(Date bindTime) {
+        this.bindTime = bindTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public Date getAddTime() {
+        return addTime;
+    }
+
+    public void setAddTime(Date addTime) {
+        this.addTime = addTime;
+    }
+
+    public String getDelFlag() {
+        return delFlag;
+    }
+
+    public void setDelFlag(String delFlag) {
+        this.delFlag = delFlag;
+    }
+
+    public String getClubStatus() {
+        return clubStatus;
+    }
+
+    public void setClubStatus(String clubStatus) {
+        this.clubStatus = clubStatus;
+    }
+
+    public Integer getUserID() {
+        return userID;
+    }
+
+    public void setUserID(Integer userID) {
+        this.userID = userID;
+    }
+}

+ 0 - 139
src/main/java/com/caimei/entity/Page.java

@@ -1,139 +0,0 @@
-package com.caimei.entity;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.List;
-
-public class Page<T> implements Serializable{
-	private static final long serialVersionUID = 1L;
-	private int index;//当前页码
-	private int pageSize;//每页大小
-	private int totalRecord;//总记录数
-	private int totalPage;//总页数?
-    private boolean hasNextPage;//是否有后一页
-    private boolean hasPreviousPage;//是否有前一页
-	List<T> results;//查询结果
-	
-	public Page(List<T> list){
-		if(list instanceof com.github.pagehelper.Page){
-			com.github.pagehelper.Page<T> page = (com.github.pagehelper.Page<T>)list;
-			this.index = page.getPageNum();
-			this.pageSize = page.getPageSize();
-			this.totalRecord = (int) page.getTotal();
-			this.totalPage = page.getPages();
-			setHasPreviousAndNext();
-			this.results = page;
-		}else if(list instanceof Collection){
-			this.index = 1;
-            this.pageSize = list.size();
-            this.totalRecord = list.size();
-            this.totalPage = 1;
-            this.results = list;
-		}
-	}
-	
-	public Page(int index, int pageSize, int totalRecord, List<T> results) {
-		super();
-		this.index = index;
-		this.pageSize = pageSize;
-		this.totalRecord = totalRecord;
-		this.totalPage = totalRecord % pageSize == 0 ? totalRecord/pageSize : totalRecord/pageSize+1;
-		this.results = results;
-		if(this.index<2){
-			hasPreviousPage=false;
-		}else{
-			hasPreviousPage=true;
-		}
-		if(this.index<totalPage){
-			hasNextPage = true;
-		}else{
-			hasNextPage = false;
-		}
-	}
-	
-	public Page(int index, int maxSize, int totalRecord, int totalPage,
-			List<T> results) {
-		super();
-		this.index = index;
-		this.pageSize = maxSize;
-		this.totalRecord = totalRecord;
-		this.totalPage = totalPage;
-		this.results = results;
-		if(this.index<2){
-			hasPreviousPage=false;
-		}else{
-			hasPreviousPage=true;
-		}
-		if(this.index<totalPage){
-			hasNextPage = true;
-		}else{
-			hasNextPage = false;
-		}
-	}
-	public void setHasPreviousAndNext(){
-		if(this.index<2){
-			hasPreviousPage=false;
-		}else{
-			hasPreviousPage=true;
-		}
-		if(this.index<totalPage){
-			hasNextPage = true;
-		}else{
-			hasNextPage = false;
-		}
-	}
-	
-	public Page() {
-		super();
-	}
-	public int getIndex() {
-		return index;
-	}
-	public void setIndex(int index) {
-		this.index = index;
-	}
-	public int getPageSize() {
-		return pageSize;
-	}
-	public void setPageSize(int maxSize) {
-		this.pageSize = maxSize;
-	}
-	public int getTotalRecord() {
-		return totalRecord;
-	}
-	public void setTotalRecord(int totalRecord) {
-		this.totalRecord = totalRecord;
-	}
-	public int getTotalPage() {
-		return totalPage;
-	}
-	public void setTotalPage(int totalPage) {
-		this.totalPage = totalPage;
-	}
-	public List<T> getResults() {
-		return results;
-	}
-	public void setResults(List<T> results) {
-		this.results = results;
-	}
-	
-	
-	public boolean isHasNextPage() {
-		return hasNextPage;
-	}
-	public void setHasNextPage(boolean hasNextPage) {
-		this.hasNextPage = hasNextPage;
-	}
-	public boolean isHasPreviousPage() {
-		return hasPreviousPage;
-	}
-	public void setHasPreviousPage(boolean hasPreviousPage) {
-		this.hasPreviousPage = hasPreviousPage;
-	}
-	public int countTotalPage(){
-		int total = totalRecord % pageSize == 0 ? totalRecord/pageSize : totalRecord/pageSize+1;
-		this.setTotalPage(total);
-	    return total;
-	}
-	
-}

+ 2 - 2
src/main/java/com/caimei/entity/WxJsonModel.java

@@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 
 import java.io.Serializable;
 
-public class WxJsonModel implements Serializable {
+public class WxJsonModel implements Serializable{
 	
 	private static final long serialVersionUID = 1L;
 	
@@ -93,4 +93,4 @@ public class WxJsonModel implements Serializable {
 		return JSONObject.toJSONString(this);
 	}
 	
-}
+}

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

@@ -0,0 +1,19 @@
+package com.caimei.mapper.user;
+
+import com.caimei.entity.CmOperationUser;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+@Mapper
+public interface LoginMapper {
+
+    CmOperationUser doLogin(@Param("openid") String openid, @Param("userOrganizeID") Integer userOrganizeID);
+
+    CmOperationUser isEnabled(@Param("invitationCode") String invitationCode, @Param("userOrganizeID") Integer userOrganizeID);
+
+    void update(CmOperationUser operationUser);
+
+    CmOperationUser query(CmOperationUser operationUser);
+
+    void updateOperationUser(CmOperationUser user);
+}

+ 8 - 0
src/main/java/com/caimei/mapper/user/PersonalMapper.java

@@ -0,0 +1,8 @@
+package com.caimei.mapper.user;
+
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface PersonalMapper {
+
+}

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

@@ -0,0 +1,12 @@
+package com.caimei.service.user;
+
+import com.caimei.entity.CmOperationUser;
+
+public interface LoginService {
+
+    CmOperationUser doLogin(String openid, Integer userOrganizeID);
+
+    CmOperationUser isEnabled(String invitationCode, Integer userOrganizeID);
+
+    void update(CmOperationUser operationUser);
+}

+ 4 - 0
src/main/java/com/caimei/service/user/PersonalService.java

@@ -0,0 +1,4 @@
+package com.caimei.service.user;
+
+public interface PersonalService {
+}

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

@@ -0,0 +1,45 @@
+package com.caimei.service.user.impl;
+
+import com.caimei.entity.CmOperationUser;
+import com.caimei.mapper.user.LoginMapper;
+import com.caimei.service.user.LoginService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+
+@Service
+public class LoginServiceImpl implements LoginService {
+    @Autowired
+    private LoginMapper loginMapper;
+
+    @Override
+    public CmOperationUser doLogin(String openid, Integer userOrganizeID) {
+        CmOperationUser operationUser = loginMapper.doLogin(openid, userOrganizeID);
+        return operationUser;
+    }
+
+    @Override
+    public CmOperationUser isEnabled(String invitationCode, Integer userOrganizeID) {
+        CmOperationUser operationUser = loginMapper.isEnabled(invitationCode, userOrganizeID);
+        return operationUser;
+    }
+
+    @Override
+    public void update(CmOperationUser operationUser) {
+        CmOperationUser user = loginMapper.query(operationUser);
+        //判断是否存在已下线的会所用户
+        if (user != null) {
+            user.setOpenid("");
+            user.setLinkName("");
+            user.setDelFlag("1");
+            user.setStatus("1");
+            user.setUpdateTime(new Date());
+            loginMapper.updateOperationUser(user);
+        }
+        operationUser.setStatus("2");
+        operationUser.setBindTime(new Date());
+        operationUser.setUpdateTime(new Date());
+        loginMapper.update(operationUser);
+    }
+}

+ 13 - 0
src/main/java/com/caimei/service/user/impl/PersonalServiceImpl.java

@@ -0,0 +1,13 @@
+package com.caimei.service.user.impl;
+
+import com.caimei.mapper.user.PersonalMapper;
+import com.caimei.service.user.PersonalService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class PersonalServiceImpl implements PersonalService {
+    @Autowired
+    private PersonalMapper personalMapper;
+
+}

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

@@ -0,0 +1,240 @@
+package com.caimei.utils;
+
+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;
+    }
+
+}

+ 3 - 2
src/main/resources/dev/application-dev.yml

@@ -40,5 +40,6 @@ logging:
   file: E:/brand-alliance/catalina.out
   level: debug
 
-miniprogramAppId:
-miniprogramAppSecret:
+miniprogram:
+  AppId: wxffa5730591e05c04
+  AppSecret: 9c88bcbd2797877c7e3322b1eaa88966

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

@@ -0,0 +1,69 @@
+<?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.user.LoginMapper">
+    <select id="doLogin" resultType="com.caimei.entity.CmOperationUser">
+        SELECT
+          cou.*
+        FROM
+          cm_operation_user cou
+          LEFT JOIN USER u ON u.clubID = cou.clubID
+        WHERE
+          cou.openid = #{openid}
+          AND cou.userOrganizeID = #{userOrganizeID}
+          AND cou.delFlag = '0'
+          AND u.clubStatus = '90'
+    </select>
+
+    <select id="isEnabled" resultType="com.caimei.entity.CmOperationUser">
+        SELECT
+          cou.*,
+          u.clubStatus
+        FROM
+          cm_operation_user cou
+          LEFT JOIN USER u ON u.userID = cou.userID
+        WHERE
+          cou.invitationCode = #{invitationCode}
+          AND cou.userOrganizeID = #{userOrganizeID}
+    </select>
+
+    <update id="update" parameterType="com.caimei.entity.CmOperationUser">
+        UPDATE
+          cm_operation_user
+        SET
+          nickName = #{nickName},
+          openid = #{openid},
+          bindTime = #{bindTime},
+          status = #{status}
+        WHERE
+          invitationCode = #{invitationCode}
+          AND delFlag = '0'
+    </update>
+
+    <update id="updateOperationUser" parameterType="com.caimei.entity.CmOperationUser">
+        UPDATE
+          cm_operation_user
+        SET
+          nickName = #{nickName},
+          openid = #{openid},
+          bindTime = #{bindTime},
+          status = #{status},
+          delFlag = #{delFlag}
+        WHERE
+          openid = #{openid}
+    </update>
+
+    <select id="query" parameterType="com.caimei.entity.CmOperationUser">
+        SELECT
+          cou.*
+        FROM
+          cm_operation_user cou
+          LEFT JOIN USER u ON u.clubID = cou.clubID
+        WHERE
+          cou.openid = #{openid}
+          AND cou.userOrganizeID = #{userOrganizeID}
+          AND cou.delFlag = '0'
+          AND u.clubStatus = '91'
+    </select>
+</mapper>

+ 7 - 0
src/main/resources/mapper/PersonalService.xml

@@ -0,0 +1,7 @@
+<?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.user.PersonalMapper">
+
+</mapper>