Commit c3ed3135 by 黄森林

微信注册

parent e5ad2787
...@@ -20,4 +20,7 @@ public interface SchoolMapper extends BaseMapper<School> { ...@@ -20,4 +20,7 @@ public interface SchoolMapper extends BaseMapper<School> {
@Select("select school_id schoolId from `hhr_user_school` where user_id = #{partner}") @Select("select school_id schoolId from `hhr_user_school` where user_id = #{partner}")
String selectSchoolIdByUserId(String partner); String selectSchoolIdByUserId(String partner);
@Select("SELECT sub_name FROM `hhr_school` GROUP BY sub_name")
List<String> selectAdress();
} }
...@@ -2,7 +2,10 @@ package com.winsun.mapper; ...@@ -2,7 +2,10 @@ package com.winsun.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper; import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.winsun.bean.SysUser; import com.winsun.bean.SysUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
...@@ -11,4 +14,7 @@ import org.springframework.stereotype.Component; ...@@ -11,4 +14,7 @@ import org.springframework.stereotype.Component;
@Mapper @Mapper
@Component @Component
public interface SysUserMapper extends BaseMapper<SysUser> { public interface SysUserMapper extends BaseMapper<SysUser> {
@Insert("insert into `hhr_user` (user_id,school_id) values(#{userId},#{schoolId})")
Integer insertUserSchool(@Param("userId")String userId,@Param("schoolId")String schoolId);
} }
...@@ -2,6 +2,7 @@ package com.winsun.utils; ...@@ -2,6 +2,7 @@ package com.winsun.utils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.winsun.auth.core.util.IOUtils;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
import org.apache.http.HttpHost; import org.apache.http.HttpHost;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
...@@ -91,15 +92,7 @@ public class HttpHelper { ...@@ -91,15 +92,7 @@ public class HttpHelper {
} catch (IOException e) { } catch (IOException e) {
log.error("http请求异常"+e.getMessage(), e); log.error("http请求异常"+e.getMessage(), e);
} finally { } finally {
if (response != null) try { IOUtils.closeQuite(response,httpClient);
response.close(); //释放资源
} catch (IOException e) {
log.error("http请求异常"+e.getMessage(), e);
}
if(httpClient!=null){
httpClient.close();
}
} }
return null; return null;
...@@ -168,15 +161,7 @@ public class HttpHelper { ...@@ -168,15 +161,7 @@ public class HttpHelper {
} catch (IOException e) { } catch (IOException e) {
log.error("http请求异常"+e.getMessage(), e); log.error("http请求异常"+e.getMessage(), e);
} finally { } finally {
if (response != null) try { IOUtils.closeQuite(response,httpClient);
response.close(); //释放资源
} catch (IOException e) {
log.error("http请求异常"+e.getMessage(), e);
}
if(httpClient!=null){
httpClient.close();
}
} }
return null; return null;
...@@ -243,12 +228,7 @@ public class HttpHelper { ...@@ -243,12 +228,7 @@ public class HttpHelper {
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
log.error("http代理请求异常"+e.getMessage(), e); log.error("http代理请求异常"+e.getMessage(), e);
}finally { }finally {
try { IOUtils.closeQuite(httpClient);
httpClient.close();
} catch (IOException e) {
// TODO Auto-generated catch block
log.error("http代理请求异常"+e.getMessage(), e);
}
} }
return string; return string;
......
...@@ -186,6 +186,7 @@ public class LoginPwdController extends BaseController { ...@@ -186,6 +186,7 @@ public class LoginPwdController extends BaseController {
String openId = map.get("openid").toString(); String openId = map.get("openid").toString();
Wrapper<HhrUser> wrapper = new EntityWrapper<>(); Wrapper<HhrUser> wrapper = new EntityWrapper<>();
wrapper.eq("open_id", openId); wrapper.eq("open_id", openId);
log.info("openId:"+openId);
List<HhrUser> hhrUsers = hhrUserMapper.selectList(wrapper); List<HhrUser> hhrUsers = hhrUserMapper.selectList(wrapper);
if (hhrUsers.size() == 0) { if (hhrUsers.size() == 0) {
return ResponseData.error("当前微信未绑定账号,请先绑定账号!"); return ResponseData.error("当前微信未绑定账号,请先绑定账号!");
...@@ -244,6 +245,7 @@ public class LoginPwdController extends BaseController { ...@@ -244,6 +245,7 @@ public class LoginPwdController extends BaseController {
} }
Map<String,Object> map = JSON.parseObject(jsonObject, Map.class); Map<String,Object> map = JSON.parseObject(jsonObject, Map.class);
String openId = map.get("openid").toString(); String openId = map.get("openid").toString();
log.info("openId:"+openId);
SysUser sysUser = users.get(0); SysUser sysUser = users.get(0);
Wrapper<HhrUser> wrapper = new EntityWrapper<>(); Wrapper<HhrUser> wrapper = new EntityWrapper<>();
wrapper.eq("id", sysUser.getId()); wrapper.eq("id", sysUser.getId());
...@@ -303,6 +305,7 @@ public class LoginPwdController extends BaseController { ...@@ -303,6 +305,7 @@ public class LoginPwdController extends BaseController {
} }
Map<String,Object> map = JSON.parseObject(jsonObject, Map.class); Map<String,Object> map = JSON.parseObject(jsonObject, Map.class);
String openId = map.get("openid").toString(); String openId = map.get("openid").toString();
log.info("openId:"+openId);
SysUser sysUser = users.get(0); SysUser sysUser = users.get(0);
Wrapper wrapper = new EntityWrapper<>(); Wrapper wrapper = new EntityWrapper<>();
wrapper.eq("id", sysUser.getId()); wrapper.eq("id", sysUser.getId());
......
...@@ -131,6 +131,10 @@ ...@@ -131,6 +131,10 @@
<artifactId>easyexcel</artifactId> <artifactId>easyexcel</artifactId>
<version>2.1.6</version> <version>2.1.6</version>
</dependency> </dependency>
<dependency>
<groupId>com.winsun.framework</groupId>
<artifactId>winsun-core-service</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
package com.winsun.controller;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.winsun.auth.core.common.model.ResponseData;
import com.winsun.bean.HhrUser;
import com.winsun.bean.School;
import com.winsun.bean.SysUser;
import com.winsun.item.core.shiro.ShiroKit;
import com.winsun.mapper.HhrUserMapper;
import com.winsun.mapper.SchoolMapper;
import com.winsun.mapper.SysUserMapper;
import com.winsun.utils.IDCardUtil;
import com.winsun.utils.PicturesUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.security.NoSuchAlgorithmException;
import java.util.List;
import java.util.Map;
/**
* @Author: hsl
* @Date: 2020/4/21 11:19
*/
@RequestMapping("mobileTerminalUser")
@RestController
@Slf4j
public class MobileTerminalUserController {
private static String PATHTYPE="idCard";
private static HhrUserMapper hhrUserMapper;
private static SysUserMapper sysUserMapper;
private static SchoolMapper schoolMapper;
@Autowired
public MobileTerminalUserController(HhrUserMapper hhrUserMapper,SysUserMapper sysUserMapper,SchoolMapper schoolMapper){
MobileTerminalUserController.hhrUserMapper=hhrUserMapper;
MobileTerminalUserController.sysUserMapper=sysUserMapper;
MobileTerminalUserController.schoolMapper=schoolMapper;
}
@RequestMapping("selectAddress")
public ResponseData<List<String>> selectAddress(){
return ResponseData.success(schoolMapper.selectAdress());
}
@RequestMapping("selectSchool")
public ResponseData<List<Map<String, Object>>> selectSchool(String subName){
Wrapper<School> wrapper = new EntityWrapper<>();
wrapper.eq("sub_name",subName);
wrapper.setSqlSelect("id","school_name");
List<Map<String, Object>> list = schoolMapper.selectMaps(wrapper);
return ResponseData.success(list);
}
@RequestMapping("registeredAccount")
public ResponseData<String> registeredAccount(@RequestParam("gender") String gender,@RequestParam("username") String username, @RequestParam("phone") String phone,
@RequestParam("idCard") String idCard, @RequestParam("stuCard") String stuCard, @RequestParam("idcardZ") String idcardZ,
@RequestParam("password") String password, @RequestParam("cpassword") String cpassword, @RequestParam("school") String school,
@RequestParam("classZ") String classZ, @RequestParam("substName") String substName, @RequestParam("account") String account) throws NoSuchAlgorithmException {
if(StringUtils.isBlank(gender)){
return ResponseData.error("性别不能为空!");
}
if(StringUtils.isBlank(username)){
return ResponseData.error("姓名不能为空!");
}
if(StringUtils.isBlank(phone)){
return ResponseData.error("电话不能为空!");
}
if(phone.length() != 11){
return ResponseData.error("手机号码有误!");
}
if(StringUtils.isBlank(idCard)){
return ResponseData.error("身份证号码不能为空!");
}
if(!IDCardUtil.IDCardValidate(idCard)){
return ResponseData.error("身份证号码有误!");
}
if(StringUtils.isBlank(stuCard)){
return ResponseData.error("请上传学生证!");
}
if(StringUtils.isBlank(idcardZ)){
return ResponseData.error("请上传身份证!");
}
if(StringUtils.isBlank(password)){
return ResponseData.error("密码不能为空!");
}
if(StringUtils.isBlank(cpassword)){
return ResponseData.error("原密码不能为空!");
}
if(!password.equals(cpassword)){
return ResponseData.error("密码和原密码不同!");
}
if(StringUtils.isBlank(school)){
return ResponseData.error("学校不能为空!");
}
if(StringUtils.isBlank(substName)){
return ResponseData.error("县分不能为空!");
}
if(StringUtils.isBlank(classZ)){
return ResponseData.error("年级不能为空!");
}
if(StringUtils.isBlank(account)){
return ResponseData.error("账号不能为空!");
}
String pattern = "^(?![A-Za-z]+$)(?![A-Z\\d]+$)(?![A-Z\\W]+$)(?![a-z\\d]+$)(?![a-z\\W]+$)(?![\\d\\W]+$)\\S{8,}$";
if (!password.matches(pattern)) {
return ResponseData.error( "密码强制等级低,必须要数字、小写英文字母、大写英文字母或特殊字符混合组成,长度至少8位!");
}
if (password.contains(account)) {
return ResponseData.error("密码与账号信息吻合,禁止使用!");
}
Wrapper<SysUser> wrapper = new EntityWrapper<>();
wrapper.eq("account",account);
List<SysUser> users = sysUserMapper.selectList(wrapper);
if(users.size() != 0){
return ResponseData.error("账号已被使用,请换一个账号!");
}
Wrapper<HhrUser> wrapper1 = new EntityWrapper<>();
wrapper1.eq("id_card",account);
List<HhrUser> hhrUsers = hhrUserMapper.selectList(wrapper1);
if(hhrUsers.size() != 0){
return ResponseData.error("一个身份证只能创建一个账号,请换一个身份证!");
}
int insert = 0;
SysUser sysUser = new SysUser();
sysUser.setSex(gender);
sysUser.setAccount(account);
sysUser.setName(username);
sysUser.setPhone(phone);
sysUser.setSalt(ShiroKit.getRandomSalt(5));
sysUser.setSubstName(substName);
sysUser.setPassword(ShiroKit.md5(password, sysUser.getSalt()));
insert =+ sysUserMapper.insert(sysUser);
insert =+ sysUserMapper.insertUserSchool(sysUser.getId(), school);
HhrUser hhrUser = new HhrUser();
hhrUser.setId(sysUser.getId());
hhrUser.setIdCard(idCard);
hhrUser.setIdcardImgUrl(PicturesUtil.uploadPictures(idcardZ, sysUser.getId(),PATHTYPE));
hhrUser.setStudentImgUrl(PicturesUtil.uploadPictures(stuCard, sysUser.getId(),PATHTYPE));
hhrUser.setGrade(classZ);
insert =+ hhrUserMapper.insert(hhrUser);
if (insert == 3){
return ResponseData.success("账号创建成功!");
}
if (insert == 0){
return ResponseData.error("账号创建失败!");
}
return ResponseData.error("账号创建异常,请联系管理员!");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment