Browse Source

0818_1.0

master
zy_Java 5 years ago
parent
commit
86314532d6
  1. 9
      game/src/main/java/com/ccsens/game/api/ScreenController.java
  2. 2
      game/src/main/resources/application-dev.yml
  3. 4
      game/src/main/resources/application-test.yml
  4. 4
      game/src/main/resources/application.yml
  5. 107
      tall/src/main/java/com/ccsens/tall/service/UserService.java
  6. 5
      tall/src/main/java/com/ccsens/tall/util/TallConstant.java
  7. 4
      tall/src/main/resources/application.yml

9
game/src/main/java/com/ccsens/game/api/ScreenController.java

@ -7,7 +7,10 @@ import com.ccsens.game.bean.vo.ScreenVo;
import com.ccsens.game.service.IScreenService;
import com.ccsens.util.JsonResponse;
import com.ccsens.util.bean.dto.QueryDto;
import io.swagger.annotations.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
@ -16,8 +19,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
@Slf4j
@Api(tags = "大屏相关api" , description = "ScreenController")
@RestController
@ -76,4 +77,6 @@ public class ScreenController {
return JsonResponse.newInstance().ok(url);
}
}

2
game/src/main/resources/application-dev.yml

@ -8,7 +8,7 @@ spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
rabbitmq:
host: 81.70.54.64
host: 192.168.0.99
password: 111111
port: 5672
username: admin

4
game/src/main/resources/application-test.yml

@ -8,13 +8,13 @@ spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
rabbitmq:
host: 81.70.54.64
host: 127.0.0.1
password: 111111
port: 5672
username: admin
redis:
database: 0
host: 192.168.0.99
host: 127.0.0.1
jedis:
pool:
max-active: 200

4
game/src/main/resources/application.yml

@ -1,4 +1,4 @@
spring:
profiles:
active: test
include: common, util-test
active: dev
include: common, util-dev

107
tall/src/main/java/com/ccsens/tall/service/UserService.java

@ -14,6 +14,7 @@ import com.ccsens.tall.bean.po.*;
import com.ccsens.tall.bean.vo.UserVo;
import com.ccsens.tall.exception.SmsException;
import com.ccsens.tall.persist.dao.*;
import com.ccsens.tall.util.TallConstant;
import com.ccsens.util.*;
import com.ccsens.util.bean.wx.po.WxOauth2UserInfo;
import com.ccsens.util.enterprisewx.WeiXinConstant;
@ -201,15 +202,15 @@ public class UserService implements IUserService {
theAuth.setIdentifier(wxOauth2UserInfo.getOpenId());
theAuth.setCredential(wxOauth2UserInfo.getUnionId());
authDao.insertSelective(theAuth);
//自动添加账号密码
String accountName = RandomStringUtils.random(8, WebConstant.RANDOM_STR);
SysAuth accountAuth = new SysAuth();
accountAuth.setId(snowflake.nextId());
accountAuth.setUserId(user.getId());
accountAuth.setIdentifyType((byte) WebConstant.IDENTIFY_TYPE.Account.value);
accountAuth.setIdentifier("USER_" + accountName);
accountAuth.setCredential("123456");
authDao.insertSelective(accountAuth);
// //自动添加账号密码
// String accountName = RandomStringUtils.random(8, WebConstant.RANDOM_STR);
// SysAuth accountAuth = new SysAuth();
// accountAuth.setId(snowflake.nextId());
// accountAuth.setUserId(user.getId());
// accountAuth.setIdentifyType((byte) WebConstant.IDENTIFY_TYPE.Account.value);
// accountAuth.setIdentifier("USER_" + accountName);
// accountAuth.setCredential("123456");
// authDao.insertSelective(accountAuth);
}
}
} else {
@ -281,17 +282,17 @@ public class UserService implements IUserService {
theAuth.setIdentifier(wxOauth2UserInfo.getOpenId());
theAuth.setCredential(wxOauth2UserInfo.getUnionId());
authDao.insertSelective(theAuth);
//自动添加账号密码
String accountName = RandomStringUtils.random(8, WebConstant.RANDOM_STR);
SysAuth accountAuth = new SysAuth();
accountAuth.setId(snowflake.nextId());
accountAuth.setUserId(user.getId());
accountAuth.setIdentifyType((byte) WebConstant.IDENTIFY_TYPE.Account.value);
accountAuth.setIdentifier("USER_" + accountName);
accountAuth.setSalt(ShiroKit.getRandomSalt(6));
accountAuth.setCredential(ShiroKit.md5("123456", accountAuth.getSalt()));
authDao.insertSelective(accountAuth);
log.info("新建用户:{},新建auth:{}", user,theAuth);
// //自动添加账号密码
// String accountName = RandomStringUtils.random(8, WebConstant.RANDOM_STR);
// SysAuth accountAuth = new SysAuth();
// accountAuth.setId(snowflake.nextId());
// accountAuth.setUserId(user.getId());
// accountAuth.setIdentifyType((byte) WebConstant.IDENTIFY_TYPE.Account.value);
// accountAuth.setIdentifier("USER_" + accountName);
// accountAuth.setSalt(ShiroKit.getRandomSalt(6));
// accountAuth.setCredential(ShiroKit.md5("123456", accountAuth.getSalt()));
// authDao.insertSelective(accountAuth);
// log.info("新建用户:{},新建auth:{}", user,theAuth);
}
}
} else {
@ -408,14 +409,21 @@ public class UserService implements IUserService {
private UserVo.UserSign getUserSign(String openId, String unionId,
byte identifyType, String redirect) {
UserVo.UserSign userSignVo;
List<SysAuth> authList = null;
SysAuth theAuth = null;
if (ObjectUtil.isNotNull(openId)) {
SysAuthExample authExample = new SysAuthExample();
authExample.createCriteria().andIdentifyTypeEqualTo(identifyType)
.andIdentifierEqualTo(openId);
authList = authDao.selectByExample(authExample);
List<SysAuth> authList;
SysAuth theAuth;
if (ObjectUtil.isNull(openId)) {
return null;
}
String key = openId + TallConstant.LOGIN + identifyType;
Object o = redisUtil.get(key);
if(ObjectUtil.isNotNull(o)){
return (UserVo.UserSign)o;
}
SysAuthExample authExample = new SysAuthExample();
authExample.createCriteria().andIdentifierEqualTo(openId).andIdentifyTypeEqualTo(identifyType);
authList = authDao.selectByExample(authExample);
if (CollectionUtil.isEmpty(authList)) {
List<SysAuth> sysAuthList = null;
if (ObjectUtil.isNotNull(unionId) && identifyType == WebConstant.IDENTIFY_TYPE.Wxmp.value) {
@ -448,16 +456,16 @@ public class UserService implements IUserService {
theAuth.setIdentifier(openId);
theAuth.setCredential(unionId);
authDao.insertSelective(theAuth);
//自动添加账号密码
String accountName = RandomStringUtils.random(8, WebConstant.RANDOM_STR);
SysAuth accountAuth = new SysAuth();
accountAuth.setId(snowflake.nextId());
accountAuth.setUserId(user.getId());
accountAuth.setIdentifyType((byte) WebConstant.IDENTIFY_TYPE.Account.value);
accountAuth.setIdentifier("USER_" + accountName);
accountAuth.setSalt(ShiroKit.getRandomSalt(6));
accountAuth.setCredential(ShiroKit.md5("123456", accountAuth.getSalt()));
authDao.insertSelective(accountAuth);
// //自动添加账号密码
// String accountName = RandomStringUtils.random(8, WebConstant.RANDOM_STR);
// SysAuth accountAuth = new SysAuth();
// accountAuth.setId(snowflake.nextId());
// accountAuth.setUserId(user.getId());
// accountAuth.setIdentifyType((byte) WebConstant.IDENTIFY_TYPE.Account.value);
// accountAuth.setIdentifier("USER_" + accountName);
// accountAuth.setSalt(ShiroKit.getRandomSalt(6));
// accountAuth.setCredential(ShiroKit.md5("123456", accountAuth.getSalt()));
// authDao.insertSelective(accountAuth);
}
// theAuth = wxRegist(openid, unionId,WebConstant.IDENTIFY_TYPE.Wxmp);
} else {
@ -468,6 +476,8 @@ public class UserService implements IUserService {
userSignVo = new UserVo.UserSign();
userSignVo.setUserId(theAuth.getUserId());
userSignVo.setAuthId(theAuth.getId());
//存入redis
redisUtil.set(key,userSignVo,TallConstant.LOGIN_TIME);
return userSignVo;
}
@ -518,16 +528,16 @@ public class UserService implements IUserService {
auth.setIdentifier(identifier);
auth.setCredential(credential);
authDao.insertSelective(auth);
//自动添加账号密码
String accountName = RandomStringUtils.random(8, WebConstant.RANDOM_STR);
SysAuth accountAuth = new SysAuth();
accountAuth.setId(snowflake.nextId());
accountAuth.setUserId(user.getId());
accountAuth.setIdentifyType((byte) WebConstant.IDENTIFY_TYPE.Account.value);
accountAuth.setIdentifier("USER_" + accountName);
accountAuth.setSalt(ShiroKit.getRandomSalt(6));
accountAuth.setCredential(ShiroKit.md5("123456", accountAuth.getSalt()));
authDao.insertSelective(accountAuth);
// //自动添加账号密码
// String accountName = RandomStringUtils.random(8, WebConstant.RANDOM_STR);
// SysAuth accountAuth = new SysAuth();
// accountAuth.setId(snowflake.nextId());
// accountAuth.setUserId(user.getId());
// accountAuth.setIdentifyType((byte) WebConstant.IDENTIFY_TYPE.Account.value);
// accountAuth.setIdentifier("USER_" + accountName);
// accountAuth.setSalt(ShiroKit.getRandomSalt(6));
// accountAuth.setCredential(ShiroKit.md5("123456", accountAuth.getSalt()));
// authDao.insertSelective(accountAuth);
return auth;
}
@ -1146,6 +1156,9 @@ public class UserService implements IUserService {
String phone = getPhoneByRegisterType(userSignVo.getUserId(),identifyType);
//获取账号
String account = selectAccountByUserId(userSignVo.getUserId());
if(StrUtil.isEmpty(account)){
account = WebConstant.DEFAULT_NICKNAME;
}
//获取用户的基本信息、
UserVo.WxInfo wxInfo = null;
SysUser user = userDao.selectByPrimaryKey(userSignVo.getUserId());

5
tall/src/main/java/com/ccsens/tall/util/TallConstant.java

@ -9,6 +9,11 @@ public class TallConstant {
public static final String UPDATE_ACCOUNT = "update_account_";
/*** redis key: 修改账号*/
public static final String UPDATE_NICKNAME = "update_nickname_";
/*** redis key: 查找登陆用户 格式 identifier_login_identifyType 有效期一天*/
public static final String LOGIN = "_login_";
/***一天 */
public static final long LOGIN_TIME = 60 * 24;
/**
* 接口发送的信息模板

4
tall/src/main/resources/application.yml

@ -1,4 +1,4 @@
spring:
profiles:
active: test
include: util-test,common
active: dev
include: util-dev,common

Loading…
Cancel
Save