diff --git a/dq-financial-crms/src/main/java/com/daqing/financial/crms/config/IPageConfig.java b/dq-financial-crms/src/main/java/com/daqing/financial/crms/config/IPageConfig.java index a48778d6..6001a7e0 100644 --- a/dq-financial-crms/src/main/java/com/daqing/financial/crms/config/IPageConfig.java +++ b/dq-financial-crms/src/main/java/com/daqing/financial/crms/config/IPageConfig.java @@ -1,13 +1,13 @@ -//package com.daqing.financial.crms.config; -// -//import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; -//import org.springframework.context.annotation.Bean; -//import org.springframework.context.annotation.Configuration; -// -//@Configuration -//public class IPageConfig { -// @Bean -// public PaginationInterceptor paginationInterceptor() { -// return new PaginationInterceptor(); -// } -//} +package com.daqing.financial.crms.config; + +import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class IPageConfig { + @Bean + public PaginationInterceptor paginationInterceptor() { + return new PaginationInterceptor(); + } +} diff --git a/dq-financial-crms/src/main/resources/bootstrap.properties b/dq-financial-crms/src/main/resources/bootstrap.properties index 6cccc927..9bb75d5f 100644 --- a/dq-financial-crms/src/main/resources/bootstrap.properties +++ b/dq-financial-crms/src/main/resources/bootstrap.properties @@ -1,59 +1,59 @@ # 开发和测试环境(dev) #服务名称 -spring.application.name=dq-financial-crms -#配置中心地址 -spring.cloud.nacos.config.server-addr=192.168.31.142:8848 -spring.cloud.nacos.config.namespace=1f69d47e-0aeb-4a1e-8ab4-0e84dfb86354 -#spring.cloud.nacos.config.group=prod - -spring.cloud.nacos.config.ext-config[0].data-id=datasource.yml -spring.cloud.nacos.config.ext-config[0].group=dev -spring.cloud.nacos.config.ext-config[0].refresh=true - -spring.cloud.nacos.config.ext-config[1].data-id=mybatis.yml -spring.cloud.nacos.config.ext-config[1].group=dev -spring.cloud.nacos.config.ext-config[1].refresh=true - -spring.cloud.nacos.config.ext-config[2].data-id=other.yml -spring.cloud.nacos.config.ext-config[2].group=dev -spring.cloud.nacos.config.ext-config[2].refresh=true - -spring.redis.host=127.0.0.1 -spring.redis.port=6379 -spring.redis.password=123456 -spring.redis.database=0 -spring.redis.timeout=30000 -spring.redis.jedis.pool.max-active=8 -spring.redis.jedis.pool.max-wait=-1 -spring.redis.jedis.pool.max-idle=8 -spring.redis.jedis.pool.min-idle=0 - -# 正式环境(prod) -#服务名称 #spring.application.name=dq-financial-crms ##配置中心地址 -#spring.cloud.nacos.config.server-addr=120.78.127.12:8848 -#spring.cloud.nacos.config.namespace=25ce05e2-a0eb-4842-92e4-d8b550a489dd +#spring.cloud.nacos.config.server-addr=192.168.31.142:8848 +#spring.cloud.nacos.config.namespace=1f69d47e-0aeb-4a1e-8ab4-0e84dfb86354 ##spring.cloud.nacos.config.group=prod # #spring.cloud.nacos.config.ext-config[0].data-id=datasource.yml -#spring.cloud.nacos.config.ext-config[0].group=prod +#spring.cloud.nacos.config.ext-config[0].group=dev #spring.cloud.nacos.config.ext-config[0].refresh=true # #spring.cloud.nacos.config.ext-config[1].data-id=mybatis.yml -#spring.cloud.nacos.config.ext-config[1].group=prod +#spring.cloud.nacos.config.ext-config[1].group=dev #spring.cloud.nacos.config.ext-config[1].refresh=true # #spring.cloud.nacos.config.ext-config[2].data-id=other.yml -#spring.cloud.nacos.config.ext-config[2].group=prod +#spring.cloud.nacos.config.ext-config[2].group=dev #spring.cloud.nacos.config.ext-config[2].refresh=true # #spring.redis.host=127.0.0.1 #spring.redis.port=6379 -#spring.redis.password=dq123456 +#spring.redis.password=123456 #spring.redis.database=0 #spring.redis.timeout=30000 #spring.redis.jedis.pool.max-active=8 #spring.redis.jedis.pool.max-wait=-1 #spring.redis.jedis.pool.max-idle=8 -#spring.redis.jedis.pool.min-idle=0 \ No newline at end of file +#spring.redis.jedis.pool.min-idle=0 + +# 正式环境(prod) +#服务名称 +spring.application.name=dq-financial-crms +#配置中心地址 +spring.cloud.nacos.config.server-addr=120.78.127.12:8848 +spring.cloud.nacos.config.namespace=25ce05e2-a0eb-4842-92e4-d8b550a489dd +#spring.cloud.nacos.config.group=prod + +spring.cloud.nacos.config.ext-config[0].data-id=datasource.yml +spring.cloud.nacos.config.ext-config[0].group=prod +spring.cloud.nacos.config.ext-config[0].refresh=true + +spring.cloud.nacos.config.ext-config[1].data-id=mybatis.yml +spring.cloud.nacos.config.ext-config[1].group=prod +spring.cloud.nacos.config.ext-config[1].refresh=true + +spring.cloud.nacos.config.ext-config[2].data-id=other.yml +spring.cloud.nacos.config.ext-config[2].group=prod +spring.cloud.nacos.config.ext-config[2].refresh=true + +spring.redis.host=127.0.0.1 +spring.redis.port=6379 +spring.redis.password=dq123456 +spring.redis.database=0 +spring.redis.timeout=30000 +spring.redis.jedis.pool.max-active=8 +spring.redis.jedis.pool.max-wait=-1 +spring.redis.jedis.pool.max-idle=8 +spring.redis.jedis.pool.min-idle=0 \ No newline at end of file diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/UserLoginController.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/UserLoginController.java index 671647bc..34a35d54 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/UserLoginController.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/controller/UserLoginController.java @@ -134,7 +134,7 @@ public class UserLoginController implements UserLoginControllerApi { //response.sendRedirect(state+"?token="+token+"&head_img="+user.getHeadImg()+"&name="+URLEncoder.encode(user.getName(),"UTF-8")); } }else { - userService.weChatBinding(code,response); + userService.weChatBinding(code,response,state); } } @@ -168,15 +168,6 @@ public class UserLoginController implements UserLoginControllerApi { return result ? ResponseResult.SUCCESS("短信发送成功") : ResponseResult.FAIL(55001,"短信发送失败"); } - /** - * 获取WeChatConfig配置类值的接口 - */ - @GetMapping("/getWeChatConfig") - public ResponseResult getWeChatConfig(){ - - return new ResponseResult().SUCCESS(userLoginService.getWeChatConfig()); - } - /** * 判断手机号是否存在 * @param mobile diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/UserLoginDao.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/UserLoginDao.java index b2b0b921..32b115ec 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/UserLoginDao.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/dao/UserLoginDao.java @@ -6,6 +6,8 @@ import com.daqing.framework.domain.hrms.request.LoginRequest; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.Date; + /** * @auther River * @date 2020/9/22 14:55 @@ -23,4 +25,8 @@ public interface UserLoginDao extends BaseMapper { int updateOpenIdByPhoneAccount(@Param("phoneAccount") String phoneAccount, @Param("wechatId") String wechatId); Boolean updateWeChat(@Param("id") Long id, @Param("weChatId") String weChatId); + + String getTokenByUserId(Long userId); + + Boolean updateUserLogin(@Param("userId") Long userId, @Param("date") Date date); } diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/UserLoginService.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/UserLoginService.java index 14640159..15c77e90 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/UserLoginService.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/UserLoginService.java @@ -21,7 +21,5 @@ public interface UserLoginService extends IService { boolean bindPhoneAndOpenId(BindOpenIdRequest bindOpenIdRequest); - WeChatConfig getWeChatConfig(); - int isPhoneExist(String mobile); } diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/UserService.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/UserService.java index 3e3365da..9841f0a4 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/UserService.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/UserService.java @@ -13,5 +13,5 @@ public interface UserService extends IService { UserEntity saveWeChatUser(String code, HttpServletResponse response); - Boolean weChatBinding(String code,HttpServletResponse response); + Boolean weChatBinding(String code,HttpServletResponse response,String state); } diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java index 7ce4a9cd..01369f4d 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserLoginServiceImpl.java @@ -169,6 +169,8 @@ public class UserLoginServiceImpl extends ServiceImpl loginLog.setNewestTime(new Date()); loginLogService.updateById(loginLog); } + // 更新用户登录信息 + this.getBaseMapper().updateUserLogin(userEntity.getId(),new Date()); //返回用户信息 LoginResponse loginResponse = new LoginResponse(); @@ -233,18 +235,6 @@ public class UserLoginServiceImpl extends ServiceImpl return count>0; } - /** - * 获取WeChatConfig - */ - @Override - public WeChatConfig getWeChatConfig() { - - WeChatConfig weChatConfigResponse = new WeChatConfig(); - weChatConfigResponse.setOpenAppid(weChatConfig.getOpenAppid()); - weChatConfigResponse.setOpenAppsecret(weChatConfig.getOpenAppsecret()); - weChatConfigResponse.setOpenRedirectUrl(weChatConfig.getOpenRedirectUrl()); - return weChatConfigResponse; - } @Override public int isPhoneExist(String mobile) { return userLoginDao.selectCount(mobile); diff --git a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserServiceImpl.java b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserServiceImpl.java index 752fa20b..4b35ead3 100644 --- a/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserServiceImpl.java +++ b/dq-financial-hrms-auth/src/main/java/com/daqing/financial/hrauth/service/impl/UserServiceImpl.java @@ -71,10 +71,10 @@ public class UserServiceImpl extends ServiceImpl imple ResponseResult login = userLoginService.login(loginRequest); LoginResponse data = (LoginResponse) login.getData(); - SecurityUser userInfo = (SecurityUser) userDetailsService.loadUserByUsername(dbUser.getPhoneAccount()); - - userInfo.getCurrentUserInfo().setToken(data.getToken()); - new UsernamePasswordAuthenticationToken(userInfo, null, userInfo.getAuthorities()); +// SecurityUser userInfo = (SecurityUser) userDetailsService.loadUserByUsername(dbUser.getPhoneAccount()); +// +// userInfo.getCurrentUserInfo().setToken(data.getToken()); +// new UsernamePasswordAuthenticationToken(userInfo, null, userInfo.getAuthorities()); return dbUser; } @@ -126,7 +126,7 @@ public class UserServiceImpl extends ServiceImpl imple * 绑定微信的回调 */ @Override - public Boolean weChatBinding(String code, HttpServletResponse response) { + public Boolean weChatBinding(String code, HttpServletResponse response,String state) { String accessTokenUrl = String.format(weChatConfig.getOPEN_ACCESS_TOKEN_URL(),weChatConfig.getOpenAppid(),weChatConfig.getOpenAppsecret(),code); @@ -136,17 +136,17 @@ public class UserServiceImpl extends ServiceImpl imple return false; } String openId = (String) baseMap.get("openid"); - HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); - String token = request.getHeader("token"); - String userId = RedisUtil.get("dq:token:"+token); - Boolean result = this.getBaseMapper().updateWeChat(Long.parseLong(userId), openId); + Boolean result = this.getBaseMapper().updateWeChat(Long.parseLong(state), openId); log.info("绑定成功---------------------------------------"); if (result){ - try { - log.info("转发成功---------------------------------------"); - response.sendRedirect("https://www.baidu.com?openId="+openId); - }catch (IOException e){ - e.printStackTrace(); + String token = this.getBaseMapper().getTokenByUserId(Long.parseLong(state)); + if (token != null){ + try { + log.info("转发成功---------------------------------------"); + response.sendRedirect("http://www.huorantech.cn/dq/index.html#/workbench-manpower?token="+token); + }catch (IOException e){ + e.printStackTrace(); + } } } return false; diff --git a/dq-financial-hrms-auth/src/main/resources/bootstrap.properties b/dq-financial-hrms-auth/src/main/resources/bootstrap.properties index e601142a..537460dc 100644 --- a/dq-financial-hrms-auth/src/main/resources/bootstrap.properties +++ b/dq-financial-hrms-auth/src/main/resources/bootstrap.properties @@ -1,58 +1,58 @@ # 开发和测试环境(dev) -spring.application.name=dq-financial-hrms-auth - -spring.cloud.nacos.config.server-addr=192.168.31.142:8848 -spring.cloud.nacos.config.namespace=7632bdaa-3381-4669-b3f9-2fc73be451e8 -#spring.cloud.nacos.config.group=prod - -spring.cloud.nacos.config.ext-config[0].data-id=datasource.yml -spring.cloud.nacos.config.ext-config[0].group=dev -spring.cloud.nacos.config.ext-config[0].refresh=true - -spring.cloud.nacos.config.ext-config[1].data-id=mybatis.yml -spring.cloud.nacos.config.ext-config[1].group=dev -spring.cloud.nacos.config.ext-config[1].refresh=true - -spring.cloud.nacos.config.ext-config[2].data-id=other.yml -spring.cloud.nacos.config.ext-config[2].group=dev -spring.cloud.nacos.config.ext-config[2].refresh=true - -spring.redis.host=127.0.0.1 -spring.redis.port=6379 -spring.redis.password=123456 -spring.redis.database=0 -spring.redis.timeout=30000 -spring.redis.jedis.pool.max-active=8 -spring.redis.jedis.pool.max-wait=-1 -spring.redis.jedis.pool.max-idle=8 -spring.redis.jedis.pool.min-idle=0 - -# -##正式环境(prod) #spring.application.name=dq-financial-hrms-auth # -#spring.cloud.nacos.config.server-addr=120.78.127.12:8848 -#spring.cloud.nacos.config.namespace=b590c830-7ada-44b7-968f-e8d0c81990c4 +#spring.cloud.nacos.config.server-addr=192.168.31.142:8848 +#spring.cloud.nacos.config.namespace=7632bdaa-3381-4669-b3f9-2fc73be451e8 ##spring.cloud.nacos.config.group=prod # #spring.cloud.nacos.config.ext-config[0].data-id=datasource.yml -#spring.cloud.nacos.config.ext-config[0].group=prod +#spring.cloud.nacos.config.ext-config[0].group=dev #spring.cloud.nacos.config.ext-config[0].refresh=true # #spring.cloud.nacos.config.ext-config[1].data-id=mybatis.yml -#spring.cloud.nacos.config.ext-config[1].group=prod +#spring.cloud.nacos.config.ext-config[1].group=dev #spring.cloud.nacos.config.ext-config[1].refresh=true # #spring.cloud.nacos.config.ext-config[2].data-id=other.yml -#spring.cloud.nacos.config.ext-config[2].group=prod +#spring.cloud.nacos.config.ext-config[2].group=dev #spring.cloud.nacos.config.ext-config[2].refresh=true # #spring.redis.host=127.0.0.1 #spring.redis.port=6379 -#spring.redis.password=dq123456 +#spring.redis.password=123456 #spring.redis.database=0 #spring.redis.timeout=30000 #spring.redis.jedis.pool.max-active=8 #spring.redis.jedis.pool.max-wait=-1 #spring.redis.jedis.pool.max-idle=8 -#spring.redis.jedis.pool.min-idle=0 \ No newline at end of file +#spring.redis.jedis.pool.min-idle=0 + + +#正式环境(prod) +spring.application.name=dq-financial-hrms-auth + +spring.cloud.nacos.config.server-addr=120.78.127.12:8848 +spring.cloud.nacos.config.namespace=b590c830-7ada-44b7-968f-e8d0c81990c4 +#spring.cloud.nacos.config.group=prod + +spring.cloud.nacos.config.ext-config[0].data-id=datasource.yml +spring.cloud.nacos.config.ext-config[0].group=prod +spring.cloud.nacos.config.ext-config[0].refresh=true + +spring.cloud.nacos.config.ext-config[1].data-id=mybatis.yml +spring.cloud.nacos.config.ext-config[1].group=prod +spring.cloud.nacos.config.ext-config[1].refresh=true + +spring.cloud.nacos.config.ext-config[2].data-id=other.yml +spring.cloud.nacos.config.ext-config[2].group=prod +spring.cloud.nacos.config.ext-config[2].refresh=true + +spring.redis.host=127.0.0.1 +spring.redis.port=6379 +spring.redis.password=dq123456 +spring.redis.database=0 +spring.redis.timeout=30000 +spring.redis.jedis.pool.max-active=8 +spring.redis.jedis.pool.max-wait=-1 +spring.redis.jedis.pool.max-idle=8 +spring.redis.jedis.pool.min-idle=0 \ No newline at end of file diff --git a/dq-financial-hrms-auth/src/main/resources/mapper/hrauth/UserLoginMapper.xml b/dq-financial-hrms-auth/src/main/resources/mapper/hrauth/UserLoginMapper.xml index b5ed1710..c7ea5f93 100644 --- a/dq-financial-hrms-auth/src/main/resources/mapper/hrauth/UserLoginMapper.xml +++ b/dq-financial-hrms-auth/src/main/resources/mapper/hrauth/UserLoginMapper.xml @@ -50,4 +50,12 @@ UPDATE hrms_user SET wechat_id = #{weChatId} WHERE id = #{id} + + + + UPDATE hrms_user SET login_num = login_num + 1,lasttime = #{date} WHERE id = #{userId} + + \ No newline at end of file diff --git a/dq-financial-hrms/pom.xml b/dq-financial-hrms/pom.xml index 78803cb8..c01409a1 100644 --- a/dq-financial-hrms/pom.xml +++ b/dq-financial-hrms/pom.xml @@ -26,21 +26,21 @@ 0.0.1-SNAPSHOT compile - + - +