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. 105
      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.game.service.IScreenService;
import com.ccsens.util.JsonResponse; import com.ccsens.util.JsonResponse;
import com.ccsens.util.bean.dto.QueryDto; 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 lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; 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.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
@Slf4j @Slf4j
@Api(tags = "大屏相关api" , description = "ScreenController") @Api(tags = "大屏相关api" , description = "ScreenController")
@RestController @RestController
@ -76,4 +77,6 @@ public class ScreenController {
return JsonResponse.newInstance().ok(url); return JsonResponse.newInstance().ok(url);
} }
} }

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

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

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

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

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

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

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

Loading…
Cancel
Save