Conflicts:
	src/main/resources/application-prod.properties
master
yangjie 4 years ago
commit bcd9dd4148
  1. 2
      pom.xml
  2. 16
      src/main/java/com/yipin/liuwanr/controller/PetController.java
  3. 24
      src/main/java/com/yipin/liuwanr/controller/UserController.java
  4. 52
      src/main/java/com/yipin/liuwanr/controller/UserInfoController.java
  5. 27
      src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java
  6. 4
      src/main/java/com/yipin/liuwanr/mapper/UserMapper.java
  7. 88
      src/main/java/com/yipin/liuwanr/service/UserInfoService.java
  8. 14
      src/main/java/com/yipin/liuwanr/service/UserService.java
  9. 65
      src/main/resources/application-dev.properties
  10. 54
      src/main/resources/application-test.properties

@ -273,7 +273,7 @@
</dependency>
</dependencies>
<build>
<finalName>ROOT</finalName>
<finalName>root</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>

@ -1,20 +1,12 @@
package com.yipin.liuwanr.controller;
import java.util.HashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.yipin.liuwanr.entity.Pet;
import com.yipin.liuwanr.entity.Response;
import com.yipin.liuwanr.service.PetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
@RestController
@RequestMapping("/pet")

@ -556,4 +556,28 @@ public class UserController {
}
return resp;
}
/**
* 查询邮箱是否存在
*/
@GetMapping("/queryEmail")
Response queryEmail(@RequestParam String email) {
Response resp = new Response();
if (email==null||email=="") {//前台传来的值是否为空
resp.setStatus(300);
resp.setErrmessage("邮箱为空!查询失败!");
}else {
HashMap<String, Object> ret = userService.queryEmail(email);
int status = (int) ret.get("retcode");
if (200 == status) {
resp.setStatus(status);
resp.setMessage(ret.get("retvalue"));
} else {
resp.setStatus(status);
resp.setErrmessage(ret.get("retvalue").toString());
}
}
return resp;
}
}

@ -305,10 +305,9 @@ public class UserInfoController {
* 登陆查询学校/电子科大
*/
@GetMapping("/loginSchoolClient")
Response loginSchoolClient(@RequestParam("account") String account, @RequestParam("password") String password, @RequestParam("schoolId") Integer schoolId , HttpServletRequest req, HttpServletResponse res) {
Response loginSchoolClient(@RequestParam("account") String account, @RequestParam("password") String password, @RequestParam("schoolId") Integer schoolId ,
@RequestParam("source") Integer source, HttpServletRequest req, HttpServletResponse res) {
Response resp = new Response();
UserInfo userInfo = new UserInfo();
userInfo.setSchoolId(schoolId);//暂定学校id
if (account == null || account=="") {
resp.setStatus(300);
resp.setErrmessage("用户账号为空,登录失败!");
@ -316,9 +315,7 @@ public class UserInfoController {
resp.setStatus(300);
resp.setErrmessage("用户密码为空,登录失败!");
}else{
userInfo.setAccount(account);
userInfo.setPassword(password);
HashMap<String, Object> ret = userInfoService.loginSchoolClient(userInfo);
HashMap<String, Object> ret = userInfoService.loginSchoolClient(account,password,schoolId,source);
int status = (int) ret.get("retcode");
if (200 == status) {
resp.setStatus(status);
@ -331,43 +328,20 @@ public class UserInfoController {
return resp;
}
/**
* 登陆查询学校/职战
*/
@GetMapping("/zzLoginSchoolClient")
Response zzLoginSchoolClient(@RequestParam("account") String account, @RequestParam("password") String password , HttpServletRequest req, HttpServletResponse res) {
Response resp = new Response();
UserInfo userInfo = new UserInfo();
userInfo.setSchoolId(2105);//暂定学校id
if (account == null || account=="") {
resp.setStatus(300);
resp.setErrmessage("用户账号为空,登录失败!");
}else if(password ==null || password=="") {
resp.setStatus(300);
resp.setErrmessage("用户密码为空,登录失败!");
}else{
userInfo.setAccount(account);
userInfo.setPassword(password);
HashMap<String, Object> ret = userInfoService.loginSchoolClient(userInfo);
int status = (int) ret.get("retcode");
if (200 == status) {
resp.setStatus(status);
resp.setMessage(ret.get("retvalue"));
} else {
resp.setStatus(status);
resp.setErrmessage(ret.get("retvalue").toString());
}
}
return resp;
}
/**
* 服务端登陆
*
* @param account source是0就是用户账号1则是手机号或邮箱
* @param password 密码
* @param source 来源区分
*/
@GetMapping("/adminLogins")
Response adminLogins(@RequestParam("account") String account, @RequestParam("password") String password,HttpServletRequest req, HttpServletResponse res) {
Response adminLogins(@RequestParam("account") String account, @RequestParam("password") String password,
@RequestParam("source") Integer source, HttpServletRequest req, HttpServletResponse res) {
Response resp = new Response();
UserInfo userInfo = new UserInfo();
HashMap<String, Object> map = new HashMap<>();
if (account == null) {
resp.setStatus(300);
@ -376,9 +350,7 @@ public class UserInfoController {
resp.setStatus(300);
resp.setErrmessage("用户密码为空,登录失败!");
} else{
userInfo.setAccount(account);
userInfo.setPassword(password);
HashMap<String, Object> ret = userInfoService.adminLogins(userInfo);
HashMap<String, Object> ret = userInfoService.adminLogins(account,password,source);
int status = (int) ret.get("retcode");
if (200 == status) {

@ -129,11 +129,23 @@ public interface UserInfoMapper {
UserInfo logins(UserInfo userInfo);
//登陆
@Select("SELECT token,userId,userName,roleId,userAvatars,password from hr_user_info where isdel=0 and (account = #{account} or phone = #{account}) and password = #{password}")
@Select({"<script> " +
"SELECT token,userId,userName,roleId,userAvatars,password from hr_user_info where isdel=0" +
"<if test='account!=null'>and account = #{account} </if>" +
"<if test='phone!=null'>and phone = #{phone} </if>" +
"<if test='email!=null'>and email = #{email} </if>" +
"and password = #{password}" +
"</script>"})
UserInfo adminLogins(UserInfo userInfo);
//登陆账号密码
@Select("SELECT hui.schoolId,hui.account,hui.cityId,hui.countries,hui.creationTime,hui.dateBirth,hui.documentType,hui.educationDegree,hui.email,hui.iDNumber,hui.logInNumber,hui.phone,hui.provinceId,hui.sex,hui.uniqueIdentificationAccount,hui.userAvatars,hui.userId,hui.userName,hui.weChatID,hui.password from hr_user_info hui where hui.isdel=0 and (hui.account = #{account} or hui.phone = #{account}) and password = #{password} ")
@Select({"<script> " +
"SELECT hui.schoolId,hui.account,hui.cityId,hui.countries,hui.creationTime,hui.dateBirth,hui.documentType,hui.educationDegree,hui.email,hui.iDNumber,hui.logInNumber,hui.phone,hui.provinceId,hui.sex,hui.uniqueIdentificationAccount,hui.userAvatars,hui.userId,hui.userName,hui.weChatID,hui.password from hr_user_info hui where hui.isdel=0 " +
"<if test='account!=null'>and account = #{account} </if>" +
"<if test='phone!=null'>and phone = #{phone} </if>" +
"<if test='email!=null'>and email = #{email} </if>" +
"and password = #{password} " +
"</script>"})
UserInfo loginsAP(UserInfo userInfo);
//查询用户角色
@ -274,7 +286,7 @@ public interface UserInfoMapper {
void updateStaffLogInNumber(UserInfo user);
//查询账号是否存在
@Select("SELECT account,email,userName,userId,uniqueIdentificationAccount,phone from hr_user_info where isdel = 0 and account = #{account}")
@Select("SELECT account,email,userName,userId,uniqueIdentificationAccount,phone,roleId from hr_user_info where isdel = 0 and account = #{account}")
List<UserInfo> queryAccountIsExist(String account);
//查询账号是否存在
@ -338,7 +350,14 @@ public interface UserInfoMapper {
"</script>"})
void deleteOrganizationRelationship(Integer userId);
@Select("SELECT disableAccount FROM hr_user_info u LEFT JOIN student s ON u.userId = s.userId WHERE s.schoolId = #{schoolId} AND (account = #{account} OR phone = #{account}) AND u.isdel = 0 AND s.isdel = 0")
@Select({"<script> " +
"SELECT disableAccount FROM hr_user_info u LEFT JOIN student s ON u.userId = s.userId " +
"WHERE s.schoolId = #{schoolId} " +
"<if test='account!=null'> AND account = #{account} </if> " +
"<if test='phone!=null'> AND phone = #{phone} </if>" +
"<if test='email!=null'> AND email = #{email} </if>" +
"AND u.isdel = 0 AND s.isdel = 0" +
"</script>"})
Integer queryDisableAccount(UserInfo userInfo);
@Select("select roleId from hr_user_info where userId = #{userId}")

@ -286,4 +286,8 @@ public interface UserMapper {
@Update("update user set lastTimeOfLanding=#{time},logInNumber=#{logInNumber} where userId=#{userId}")
void updateUserQ(@Param("time")String time,@Param("logInNumber") Integer logInNumber,@Param("userId") Integer userId);
//查询用户邮箱
@Select("SELECT u.email,u.userId from hr_user_info u where isdel = 0 and email = #{email}")
List<UserInfo> queryEmail(String email);
}

@ -28,6 +28,8 @@ import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Service
@ -392,10 +394,28 @@ public class UserInfoService {
return resp;
}
//登陆获取学校/电子科大
public HashMap<String, Object> loginSchoolClient(UserInfo userInfo){
public HashMap<String, Object> loginSchoolClient(String account,String password,Integer schoolId,Integer source){
HashMap<String, Object> resp = new HashMap<String, Object>();
HashMap<String, Object> obj = new HashMap<String, Object>();
Integer schoolId = userInfo.getSchoolId();
UserInfo userInfo = new UserInfo();
userInfo.setPassword(password);
userInfo.setSchoolId(schoolId);
if (source == 0){
//账号
userInfo.setAccount(account);
}else if(source == 1){
if (checkPhone(account)){
//手机号
userInfo.setPhone(account);
}else if (checkEmail(account)){
//邮箱
userInfo.setEmail(account);
}else {
//防止邮箱,手机号格式错误 sql能正确执行
userInfo.setAccount("!@#$%^&*()_+");
}
}
Integer state = userInfoMapper.queryDisableAccount(userInfo);
if (state==null){
resp.put("retcode",300);
@ -406,7 +426,7 @@ public class UserInfoService {
//区分密码大小写
boolean num = false;
if (user != null){
num = userInfo.getPassword().equals(user.getPassword());
num = password.equals(user.getPassword());
}
if(user!=null && num == true) {
@ -475,14 +495,31 @@ public class UserInfoService {
}
//登陆
public HashMap<String, Object> adminLogins(UserInfo userInfo){
public HashMap<String, Object> adminLogins(String account,String password,Integer source){
HashMap<String, Object> resp = new HashMap<String, Object>();
UserInfo user = new UserInfo();
user.setPassword(password);
try {
UserInfo user=userInfoMapper.adminLogins(userInfo);
if (source == 0){
user.setAccount(account);
}else if (source == 1){
if (checkPhone(account)){
//手机号
user.setPhone(account);
}else if (checkEmail(account)){
//邮箱
user.setEmail(account);
}else {
//防止邮箱,手机号格式错误 sql能正确执行
user.setAccount("!@#$%^&*()_+");
}
}
user = userInfoMapper.adminLogins(user);
//区分密码大小写
boolean num = false;
if (user != null){
num = userInfo.getPassword().equals(user.getPassword());
num = password.equals(user.getPassword());
user.setPassword(null);
}
if(user != null){
@ -504,8 +541,8 @@ public class UserInfoService {
userInfoMapper.updateLogInNumber(user);
String token = user.getToken();
ValueOperations<String, String> redis = stringRedisTemplate.opsForValue();
redis.set(token,lastLoginTime, 24, TimeUnit.HOURS);
user.setDataTime(lastLoginTime);
//redis.set(token,lastLoginTime, 24, TimeUnit.HOURS);
//user.setDataTime(lastLoginTime);
resp.put("retvalue",user);
resp.put("retcode", 200);
}
@ -827,4 +864,39 @@ public class UserInfoService {
}
return resp;
}
/**
* 验证邮箱
* @param email
* @return
*/
public boolean checkEmail(String email){
boolean flag = false;
try{
Pattern regex = Pattern.compile("^([a-zA-Z]|[0-9])(\\w|\\-)+@[a-zA-Z0-9]+\\.([a-zA-Z]{2,4})$");
Matcher matcher = regex.matcher(email);
flag = matcher.matches();
}catch(Exception e){
flag = false;
}
return flag;
}
/**
* 验证手机号码
* @param phone
* @return
*/
public boolean checkPhone(String phone){
boolean flag = false;
try{
Pattern regex = Pattern.compile("^1[3456789]\\d{9}$");
Matcher matcher = regex.matcher(phone);
flag = matcher.matches();
}catch(Exception e){
flag = false;
}
return flag;
}
}

@ -423,4 +423,18 @@ public class UserService {
}
return resp;
}
public HashMap<String, Object> queryEmail(String email) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
resp.put("retvalue", userMapper.queryEmail(email));
resp.put("retcode", 200);
} catch (RuntimeException e) {
logger.error(e.getMessage());
resp.put("retcode", 500);
resp.put("retvalue", "查询手机号失败!");
return resp;
}
return resp;
}
}

@ -1,63 +1,2 @@
# See http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
spring.thymeleaf.cache=false
spring.main.show-banner=false
logging.level.jdbc=OFF
logging.level.jdbc.sqltiming=DEBUG
logging.level.jdbc.resultsettable=DEBUG
logging.level.com.yipin.liuwar.mapper=DEBUG
#易品测试liuwanr服务器 -职站项目
#spring.datasource.url=jdbc:mysql://rm-wz9y13wf7u8q8610fwo.mysql.rds.aliyuncs.com:3306/huoran?useUnicode=true&characterEncoding=utf8&useSSL=false&allowMultiQueries=true
#spring.datasource.username=super
#spring.datasource.password=huoran888
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#或然正式服务器 -科大项目
spring.datasource.url=jdbc:mysql://rm-wz9y13wf7u8q8610fwo.mysql.rds.aliyuncs.com:3306/keda?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
spring.datasource.username=super
spring.datasource.password=huoran888
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.mina.port=9123
spring.mina.buffersize=2048
spring.mina.idletime=15
spring.redis.database=0
spring.redis.host=127.0.0.1
spring.redis.password=
spring.redis.port=6379
spring.redis.timeout=3000
spring.redis.jedis.pool.max-idle=500
spring.redis.jedis.pool.min-idle=50
spring.redis.jedis.pool.max-active=2000
spring.redis.jedis.pool.max-wait=1000
#spring.redis.pool.max-idle=500
#spring.redis.pool.min-idle=50
#spring.redis.pool.max-active=2000
#spring.redis.pool.max-wait=1000
spring.elasticsearch.rest.uris=http://es-cn-v641e944a0006xtwy.elasticsearch.aliyuncs.com:9200
spring.elasticsearch.rest.username=elastic
spring.elasticsearch.rest.password=1qaz@WSX
pagehelper.reasonable=false
# maxFileSize \u5355\u4E2A\u6570\u636E\u5927\u5C0F
spring.servlet.multipart.maxFileSize = 1024MB
# maxRequestSize \u662F\u603B\u6570\u636E\u5927\u5C0F
spring.servlet.multipart.maxRequestSize=10240MB
logging.level.com.yipin.liuwanr.mapper=debug
#redis-cluster
redis.cluster.maxTotal=200
redis.cluster.maxIdle=8
redis.cluster.minIdle=3
redis.cluster.nodes=192.168.136.191:8000,192.168.136.191:8001,192.168.136.191:8002
server.port=8090
server.servlet.context-path= /liuwanr
#\u9009\u62E9\u6307\u5B9A\u73AF\u5883,\u76EE\u524D\u53EA\u6709\u6D4B\u8BD5\u548C\u6B63\u5F0F\u73AF\u5883
spring.profiles.active=prod

@ -1,53 +1,49 @@
# See http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
spring.thymeleaf.cache=false
spring.main.show-banner=false
logging.level.jdbc=OFF
logging.level.jdbc.sqltiming=DEBUG
logging.level.jdbc.resultsettable=DEBUG
logging.level.com.yipin.liuwar.mapper=DEBUG
server.port=8090
server.servlet.context-path=/liuwanr
spring.datasource.url=jdbc:mysql://rm-wz9y13wf7u8q8610fwo.mysql.rds.aliyuncs.com:3306/keda?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
#\u6D4B\u8BD5\u6570\u636E\u5E93\u8FDE\u63A5
spring.datasource.url=jdbc:mysql://rm-wz9y13wf7u8q8610fwo.mysql.rds.aliyuncs.com:3306/huoran?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
spring.datasource.username=super
spring.datasource.password=huoran888
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.mina.port=9123
spring.mina.buffersize=2048
spring.mina.idletime=15
#redis\u914D\u7F6E
spring.redis.database=0
spring.redis.host=127.0.0.1
spring.redis.password=msdw@2021
spring.redis.password=
spring.redis.port=6379
spring.redis.timeout=3000
spring.redis.jedis.pool.max-idle=500
spring.redis.jedis.pool.min-idle=50
spring.redis.jedis.pool.max-active=2000
spring.redis.jedis.pool.max-wait=1000
#spring.redis.pool.max-idle=500
#spring.redis.pool.min-idle=50
#spring.redis.pool.max-active=2000
#spring.redis.pool.max-wait=1000
#redis-cluster
redis.cluster.maxTotal=200
redis.cluster.maxIdle=8
redis.cluster.minIdle=3
redis.cluster.nodes=192.168.136.191:8000,192.168.136.191:8001,192.168.136.191:8002
spring.mina.port=9123
spring.mina.buffersize=2048
spring.mina.idletime=15
spring.main.show-banner=false
#\u65E5\u5FD7\u7EA7\u522B
logging.level.jdbc=OFF
logging.level.jdbc.sqltiming=DEBUG
logging.level.jdbc.resultsettable=DEBUG
logging.level.com.yipin.liuwar.mapper=DEBUG
logging.level.com.yipin.liuwanr.mapper=DEBUG
spring.elasticsearch.rest.uris=http://es-cn-v641e944a0006xtwy.elasticsearch.aliyuncs.com:9200
spring.elasticsearch.rest.username=elastic
spring.elasticsearch.rest.password=1qaz@WSX
pagehelper.reasonable=false
# maxFileSize \u5355\u4E2A\u6570\u636E\u5927\u5C0F
spring.servlet.multipart.maxFileSize = 1024MB
# maxRequestSize \u662F\u603B\u6570\u636E\u5927\u5C0F
spring.servlet.multipart.maxRequestSize=10240MB
logging.level.com.yipin.liuwanr.mapper=debug
#redis-cluster
redis.cluster.maxTotal=200
redis.cluster.maxIdle=8
redis.cluster.minIdle=3
redis.cluster.nodes=192.168.136.191:8000,192.168.136.191:8001,192.168.136.191:8002
pagehelper.reasonable=false
server.port=8090
server.servlet.context-path= /liuwanr
Loading…
Cancel
Save