renqianlong 1 år sedan
förälder
incheckning
cd4d87cca6
36 ändrade filer med 657 tillägg och 341 borttagningar
  1. 0 1
      zhongzheng-admin-business/src/main/java/com/zhongzheng/controller/staff/StaffController.java
  2. 1 0
      zhongzheng-admin-business/src/main/java/com/zhongzheng/controller/system/BsSysDictDataController.java
  3. 12 6
      zhongzheng-admin-business/src/main/java/com/zhongzheng/controller/system/BsSysLoginController.java
  4. 1 1
      zhongzheng-admin-business/src/main/resources/application.yml
  5. 12 0
      zhongzheng-common/src/main/java/com/zhongzheng/common/core/redis/RedisCache.java
  6. 5 0
      zhongzheng-framework/src/main/java/com/zhongzheng/framework/config/MybatisPlusConfig.java
  7. 17 19
      zhongzheng-framework/src/main/java/com/zhongzheng/framework/config/SecurityConfig.java
  8. 92 0
      zhongzheng-framework/src/main/java/com/zhongzheng/framework/mybatisplus/CustomCompanyLineHandler.java
  9. 20 8
      zhongzheng-framework/src/main/java/com/zhongzheng/framework/mybatisplus/CustomTenantLineHandler.java
  10. 29 31
      zhongzheng-framework/src/main/java/com/zhongzheng/framework/security/filter/JwtAuthenticationTokenFilter.java
  11. 0 18
      zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/BsSysLoginService.java
  12. 69 0
      zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/BsSysPermissionService.java
  13. 9 7
      zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/BsTokenService.java
  14. 57 0
      zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/BsUserDetailsServiceImpl.java
  15. 8 0
      zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/UserLoginKeyServiceImpl.java
  16. 1 2
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/company/service/impl/CompanyServiceImpl.java
  17. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/goods/bo/BsUserGoodsCollectionAddBo.java
  18. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/goods/bo/BsUserGoodsCollectionEditBo.java
  19. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/goods/bo/BsUserGoodsCollectionQueryBo.java
  20. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/goods/domain/BsUserGoodsCollection.java
  21. 7 5
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/goods/service/impl/BsUserGoodsCollectionServiceImpl.java
  22. 4 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/goods/vo/BsUserGoodsCollectionVo.java
  23. 0 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/system/domain/BsSysDictData.java
  24. 11 1
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/system/mapper/BsSysUserMapper.java
  25. 6 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/system/service/IBsSysUserService.java
  26. 1 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/system/service/impl/BsSysDictDataServiceImpl.java
  27. 12 11
      zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/system/service/impl/BsSysUserServiceImpl.java
  28. 1 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserLoginKeyAddBo.java
  29. 1 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/domain/UserLoginKey.java
  30. 4 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/mapper/UserLoginKeyMapper.java
  31. 2 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/mapper/UserMapper.java
  32. 7 0
      zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserLoginKeyService.java
  33. 43 1
      zhongzheng-system/src/main/resources/mapper/modules/bsSys/BsSysUserMapper.xml
  34. 1 0
      zhongzheng-system/src/main/resources/mapper/modules/goods/BsUserGoodsCollectionMapper.xml
  35. 5 1
      zhongzheng-system/src/main/resources/mapper/modules/user/UserLoginKeyMapper.xml
  36. 211 228
      zhongzheng-system/src/main/resources/mapper/modules/user/UserMapper.xml

+ 0 - 1
zhongzheng-admin-business/src/main/java/com/zhongzheng/controller/staff/StaffController.java

@@ -63,7 +63,6 @@ public class StaffController extends BaseController {
         startPage();
         bo.setCompanyId(bsTokenService.getLoginUser(ServletUtils.getRequest()).getUser().getCompanyId());
         List<StaffVo> list = iStaffService.getMatchGoods(bo);
-
         return getDataTable(list);
     }
 

+ 1 - 0
zhongzheng-admin-business/src/main/java/com/zhongzheng/controller/system/BsSysDictDataController.java

@@ -50,6 +50,7 @@ public class BsSysDictDataController extends BaseController {
     @GetMapping("/list")
     public TableDataInfo list(BsSysDictData dictData) {
         startPage();
+//        dictData.setTenantId(ServletUtils.getRequest().getHeader("TenantId"));
         List<BsSysDictData> list = dictDataService.selectDictDataList(dictData);
         return getDataTable(list);
     }

+ 12 - 6
zhongzheng-admin-business/src/main/java/com/zhongzheng/controller/system/BsSysLoginController.java

@@ -10,10 +10,13 @@ import com.zhongzheng.common.core.domain.model.LoginBody;
 import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.framework.web.service.*;
 import com.zhongzheng.modules.bs.company.entity.ClientBsLoginUser;
+import com.zhongzheng.modules.bs.system.domain.BsLoginBody;
 import com.zhongzheng.modules.bs.system.domain.BsSysMenu;
 import com.zhongzheng.modules.bs.system.domain.BsSysUser;
 import com.zhongzheng.modules.bs.system.service.IBsSysMenuService;
+import com.zhongzheng.modules.bs.system.service.IBsSysTenantService;
 import com.zhongzheng.modules.bs.system.service.IBsSysUserService;
+import com.zhongzheng.modules.bs.system.vo.BsSysTenantVo;
 import com.zhongzheng.modules.system.service.ISysTenantService;
 import com.zhongzheng.modules.system.vo.SysTenantVo;
 import io.swagger.annotations.Api;
@@ -44,13 +47,13 @@ public class BsSysLoginController
     private IBsSysMenuService menuService;
 
     @Autowired
-    private SysPermissionService permissionService;
+    private BsSysPermissionService permissionService;
 
     @Autowired
     private BsTokenService tokenService;
 
     @Autowired
-    private ISysTenantService iSysTenantService;
+    private IBsSysTenantService iSysTenantService;
     @Autowired
     private IBsSysUserService iSysUserService;
 
@@ -63,12 +66,15 @@ public class BsSysLoginController
      */
     @ApiOperation("登录")
     @PostMapping("/login")
-    public AjaxResult login(@RequestBody LoginBody loginBody)
+    public AjaxResult login(@RequestBody BsLoginBody loginBody)
     {
         AjaxResult ajax = AjaxResult.success();
         // 生成令牌
         String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
                 loginBody.getUuid(),loginBody.getSmsCode(),loginBody.getPhonenumber());
+        BsSysUser bsSysUser = iSysUserService.getUser(loginBody.getUsername());
+        ajax.put("TenantId",bsSysUser.getTenantId());
+        ajax.put("companyId",bsSysUser.getCompanyId());
         ajax.put(Constants.TOKEN, token);
         return ajax;
     }
@@ -86,12 +92,12 @@ public class BsSysLoginController
         BsSysUser user = iSysUserService.getOne(new LambdaQueryWrapper<BsSysUser>()
                 .eq(BsSysUser::getUserId, loginUser.getUser().getUserId()).last("limit 1"));
         // 角色集合
-        SysUser bean = BeanUtil.toBean(user, SysUser.class);
+        BsSysUser bean = BeanUtil.toBean(user, BsSysUser.class);
         Set<String> roles = permissionService.getRolePermission(bean);
         // 权限集合
-        Set<String> permissions = permissionService.getMenuPermission(bean);
+        Set<String> permissions = permissionService.getBsMenuPermission(bean);
         String tenantId = ServletUtils.getRequest().getHeader("TenantId");
-        SysTenantVo sysTenantVo = iSysTenantService.queryById(Long.parseLong(tenantId));
+        BsSysTenantVo sysTenantVo = iSysTenantService.queryById(Long.parseLong(tenantId));
         Map<String,Object> map = new HashMap<>();
         map.put("user", user);
         map.put("roles", roles);

+ 1 - 1
zhongzheng-admin-business/src/main/resources/application.yml

@@ -210,7 +210,7 @@ mybatis-plus:
       selectStrategy: NOT_EMPTY
   # 开启多租户
   tenant:
-    enabled-tenant: true
+    enabled-tenant: false
     bs-tenant: true
 # PageHelper分页插件
 pagehelper:

+ 12 - 0
zhongzheng-common/src/main/java/com/zhongzheng/common/core/redis/RedisCache.java

@@ -119,6 +119,18 @@ public class RedisCache
         }
         return operation.get(unionKey);
     }
+    /**
+     * 获得缓存的基本对象。
+     *
+     * @param key 缓存键值
+     * @return 缓存键值对应的数据
+     */
+    public <T> T getBsCacheObject(final String key)
+    {
+        ValueOperations<String, T> operation = redisTemplate.opsForValue();
+        String unionKey = key;
+        return operation.get(unionKey);
+    }
 
     /**
      * 获得缓存的基本对象。

+ 5 - 0
zhongzheng-framework/src/main/java/com/zhongzheng/framework/config/MybatisPlusConfig.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInt
 import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
 import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
 import com.zhongzheng.framework.mybatisplus.CreateAndUpdateMetaObjectHandler;
+import com.zhongzheng.framework.mybatisplus.CustomCompanyLineHandler;
 import com.zhongzheng.framework.mybatisplus.CustomTenantLineHandler;
 import com.zhongzheng.framework.mybatisplus.CustomTenantLineInnerInterceptor;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,10 +22,14 @@ public class MybatisPlusConfig {
 
 	@Autowired
 	private CustomTenantLineHandler customTenantLineHandler;
+	@Autowired
+	private CustomCompanyLineHandler customCompanyLineHandler;
 
 	@Bean
 	public MybatisPlusInterceptor mybatisPlusInterceptor() {
 		MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
+//		 多企业插件(注意:这个一定要放在最上面)
+		interceptor.addInnerInterceptor(new TenantLineInnerInterceptor(customCompanyLineHandler));
 		// 多租户插件(注意:这个一定要放在最上面)
 		interceptor.addInnerInterceptor(new TenantLineInnerInterceptor(customTenantLineHandler));
 		// 分页插件

+ 17 - 19
zhongzheng-framework/src/main/java/com/zhongzheng/framework/config/SecurityConfig.java

@@ -5,6 +5,7 @@ import com.zhongzheng.framework.security.handle.AuthenticationEntryPointImpl;
 import com.zhongzheng.framework.security.handle.BsLogoutSuccessHandlerImpl;
 import com.zhongzheng.framework.security.handle.LogoutSuccessHandlerImpl;
 import com.zhongzheng.framework.security.handle.TopLogoutSuccessHandlerImpl;
+import com.zhongzheng.framework.web.service.BsUserDetailsServiceImpl;
 import com.zhongzheng.framework.web.service.TopUserDetailsServiceImpl;
 import com.zhongzheng.framework.web.service.UserDetailsServiceImpl;
 import de.codecentric.boot.admin.server.config.AdminServerProperties;
@@ -30,8 +31,7 @@ import org.springframework.web.filter.CorsFilter;
  * @author zhongzheng
  */
 @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
-public class SecurityConfig extends WebSecurityConfigurerAdapter
-{
+public class SecurityConfig extends WebSecurityConfigurerAdapter {
     /**
      * 自定义用户认证逻辑
      */
@@ -40,6 +40,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
 
     @Autowired
     private TopUserDetailsServiceImpl topUserDetailsService;
+    @Autowired
+    private BsUserDetailsServiceImpl bsUserDetailsService;
 
     @Value("${mybatis-plus.tenant.enabled-tenant:false}")
     private boolean enabledTenant;
@@ -93,8 +95,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
      */
     @Bean
     @Override
-    public AuthenticationManager authenticationManagerBean() throws Exception
-    {
+    public AuthenticationManager authenticationManagerBean() throws Exception {
         return super.authenticationManagerBean();
     }
 
@@ -114,8 +115,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
      * authenticated       |   用户登录后可访问
      */
     @Override
-    protected void configure(HttpSecurity httpSecurity) throws Exception
-    {
+    protected void configure(HttpSecurity httpSecurity) throws Exception {
         httpSecurity
                 // CSRF禁用,因为不使用session
                 .csrf().disable()
@@ -126,7 +126,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                 // 过滤请求
                 .authorizeRequests()
                 // 对于登录login 验证码captchaImage 允许匿名访问
-                .antMatchers("/login","/old/login", "/captchaImage", "/testLogin","/wx/pay/callback","/gzh_login","/check_pc_login","/pc_login_url","/scan_code","/businessToken").anonymous()
+                .antMatchers("/login","/bs/login", "/old/login", "/captchaImage", "/testLogin", "/wx/pay/callback", "/gzh_login", "/check_pc_login", "/pc_login_url", "/scan_code", "/businessToken").anonymous()
                 .antMatchers("/aliyun/oss/callback").anonymous()
                 .antMatchers(
                         HttpMethod.GET,
@@ -185,14 +185,13 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                 .anyRequest().authenticated()
                 .and()
                 .headers().frameOptions().disable();
-        if(enabledTenant){
+        if (enabledTenant) {
             //开启多租户
             httpSecurity.logout().logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler);
-        }else{
-            httpSecurity.logout().logoutUrl("/logout").logoutSuccessHandler(topLogoutSuccessHandlerImpl);
-        }
-        if (bsTenant){
+        } else if (bsTenant) {
             httpSecurity.logout().logoutUrl("/logout").logoutSuccessHandler(bsLogoutSuccessHandler);
+        } else {
+            httpSecurity.logout().logoutUrl("/logout").logoutSuccessHandler(topLogoutSuccessHandlerImpl);
         }
         // 添加JWT filter
         httpSecurity.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
@@ -206,8 +205,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
      * 强散列哈希加密实现
      */
     @Bean
-    public BCryptPasswordEncoder bCryptPasswordEncoder()
-    {
+    public BCryptPasswordEncoder bCryptPasswordEncoder() {
         return new BCryptPasswordEncoder();
     }
 
@@ -215,14 +213,14 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
      * 身份认证接口
      */
     @Override
-    protected void configure(AuthenticationManagerBuilder auth) throws Exception
-    {
-        if(enabledTenant){
+    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
+        if (enabledTenant) {
             //开启多租户
             auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder());
-        }else{
+        } else if (bsTenant) {
+            auth.userDetailsService(bsUserDetailsService).passwordEncoder(bCryptPasswordEncoder());
+        } else {
             auth.userDetailsService(topUserDetailsService).passwordEncoder(bCryptPasswordEncoder());
         }
-
     }
 }

+ 92 - 0
zhongzheng-framework/src/main/java/com/zhongzheng/framework/mybatisplus/CustomCompanyLineHandler.java

@@ -0,0 +1,92 @@
+package com.zhongzheng.framework.mybatisplus;
+
+import cn.hutool.core.lang.Validator;
+import cn.hutool.http.HttpStatus;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
+import com.zhongzheng.common.core.domain.AjaxResult;
+import com.zhongzheng.common.utils.ServletUtils;
+import lombok.SneakyThrows;
+import net.sf.jsqlparser.expression.Expression;
+import net.sf.jsqlparser.expression.LongValue;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 多租户处理插件
+ *
+ * @author hjl
+ * @date 2021/07/30 13:37
+ */
+@Component
+public class CustomCompanyLineHandler implements TenantLineHandler {
+
+    /**
+     * 租户id字段名
+     */
+    public static final String COMPANY_ID_COLUMN = "company_id";
+
+    @Value("${mybatis-plus.tenant.bs-tenant}")
+    private boolean bsTenant;
+
+    /**
+     * 忽略添加租户ID的表
+     */
+    private final static List<String> IGNORE_TABLE_NAMES = new ArrayList<String>() {{
+        add("sys_tenant");
+        add("tables");
+        add("columns");
+        add("sys_logininfor");
+        add("sys_old_org");
+        add("top_sys_tenant_register");
+        add("user_login_key");
+    }};
+
+    /**
+     * 获取租户ID值表达式(可从cookie、token、缓存中取)
+     *
+     * @return
+     */
+    @SneakyThrows
+    @Override
+    public Expression getTenantId() {
+        String companyId = ServletUtils.getResponse().getHeader("companyId");
+        if (Validator.isEmpty(companyId)) {
+            companyId = ServletUtils.getRequest().getHeader("companyId");
+            if (!bsTenant) {
+                int code = HttpStatus.HTTP_UNAVAILABLE;
+                String msg = "企业非法访问";
+                ServletUtils.renderString(ServletUtils.getResponse(), JSON.toJSONString(AjaxResult.error(code, msg)));
+                ServletUtils.getResponse().getWriter().flush();
+                ServletUtils.getResponse().getWriter().close();
+            }
+        }
+        return new LongValue(companyId);
+}
+
+/**
+ * 获取租户字段名(数据库的租户ID字段名)
+ *
+ * @return
+ */
+@Override
+public String getTenantIdColumn() {
+    return COMPANY_ID_COLUMN;
+}
+
+
+    /**
+     * 根据表名判断是否忽略拼接多租户条件
+     *
+     * @param tableName
+     * @return
+     */
+    @Override
+    public boolean ignoreTable(String tableName) {
+       Boolean flag = IGNORE_TABLE_NAMES.contains(tableName) || !tableName.contains("bs_");
+        return flag;
+    }
+}

+ 20 - 8
zhongzheng-framework/src/main/java/com/zhongzheng/framework/mybatisplus/CustomTenantLineHandler.java

@@ -29,15 +29,17 @@ public class CustomTenantLineHandler implements TenantLineHandler {
      */
     public static final String TENANT_ID_COLUMN = "tenant_id";
 
-  //  public static  String TENANT_ID = null;
+    //  public static  String TENANT_ID = null;
 
-    @Value("${mybatis-plus.tenant.enabled-tenant:true}")
+    @Value("${mybatis-plus.tenant.enabled-tenant}")
     private boolean enabledTenant;
+    @Value("${mybatis-plus.tenant.bs-tenant}")
+    private boolean bsTenant;
 
     /**
      * 忽略添加租户ID的表
      */
-    private final static List<String> IGNORE_TABLE_NAMES = new ArrayList<String>(){{
+    private final static List<String> IGNORE_TABLE_NAMES = new ArrayList<String>() {{
         add("sys_tenant");
         add("tables");
         add("columns");
@@ -55,13 +57,21 @@ public class CustomTenantLineHandler implements TenantLineHandler {
     @Override
     public Expression getTenantId() {
         String TenantId = ServletUtils.getResponse().getHeader("TenantId");
-        if(Validator.isEmpty(TenantId)){
+        if (Validator.isEmpty(TenantId)) {
             TenantId = ServletUtils.getRequest().getHeader("TenantId");
-            if(enabledTenant){
-                if(Validator.isEmpty(TenantId)){
+            if (enabledTenant) {
+                if (Validator.isEmpty(TenantId)) {
                     int code = HttpStatus.HTTP_UNAVAILABLE;
                     String msg = "企业非法访问";
-                    ServletUtils.renderString( ServletUtils.getResponse(), JSON.toJSONString(AjaxResult.error(code, msg)));
+                    ServletUtils.renderString(ServletUtils.getResponse(), JSON.toJSONString(AjaxResult.error(code, msg)));
+                    ServletUtils.getResponse().getWriter().flush();
+                    ServletUtils.getResponse().getWriter().close();
+                }
+            } else if (!bsTenant) {
+                if (Validator.isEmpty(TenantId)) {
+                    int code = HttpStatus.HTTP_UNAVAILABLE;
+                    String msg = "企业非法访问";
+                    ServletUtils.renderString(ServletUtils.getResponse(), JSON.toJSONString(AjaxResult.error(code, msg)));
                     ServletUtils.getResponse().getWriter().flush();
                     ServletUtils.getResponse().getWriter().close();
                 }
@@ -88,7 +98,9 @@ public class CustomTenantLineHandler implements TenantLineHandler {
      */
     @Override
     public boolean ignoreTable(String tableName) {
-        if (!enabledTenant || tableName.contains("top_")){
+        if (bsTenant) {
+            return IGNORE_TABLE_NAMES.contains(tableName);
+        }else if (!enabledTenant || tableName.contains("top_")) {
             //总平台忽略tenantId
             return true;
         }

+ 29 - 31
zhongzheng-framework/src/main/java/com/zhongzheng/framework/security/filter/JwtAuthenticationTokenFilter.java

@@ -18,6 +18,7 @@ import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
 import org.springframework.stereotype.Component;
 import org.springframework.web.filter.OncePerRequestFilter;
+
 import javax.servlet.FilterChain;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
@@ -30,8 +31,7 @@ import java.io.IOException;
  * @author zhongzheng
  */
 @Component
-public class JwtAuthenticationTokenFilter extends OncePerRequestFilter
-{
+public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
     @Autowired
     private TokenService tokenService;
 
@@ -46,66 +46,64 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter
 
     @Value("${mybatis-plus.tenant.enabled-tenant:true}")
     private boolean enabledTenant;
+    @Value("${mybatis-plus.tenant.bs-tenant:true}")
+    private boolean bsTenant;
 
     @Override
     protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
-            throws ServletException, IOException
-    {
-        try{
+            throws ServletException, IOException {
+        try {
             String wxToken = wxTokenService.getToken(request);
-            if(StringUtils.isNoneEmpty(wxToken)){
+            if (StringUtils.isNoneEmpty(wxToken)) {
                 ClientLoginUser clientLoginUser = wxTokenService.getLoginUser(request);
-                if(clientLoginUser!=null){
-                    if(Validator.isNull(clientLoginUser.getUser())){
+                if (clientLoginUser != null) {
+                    if (Validator.isNull(clientLoginUser.getUser())) {
                         request.getRequestDispatcher("/app/common/token_offline").forward(request, response);
                         return;
-                    }else{
+                    } else {
                         wxTokenService.verifyToken(clientLoginUser);
-                        UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(clientLoginUser, null,null);
+                        UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(clientLoginUser, null, null);
                         authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
                         SecurityContextHolder.getContext().setAuthentication(authenticationToken);
                     }
                 }
-            }else{
-                if(!enabledTenant){
-                    //SAAS管理员
-                    TopLoginUser top_loginUser = topTokenService.getLoginUser(request);
-                    if (Validator.isNotNull(top_loginUser) && Validator.isNull(SecurityUtils.getAuthentication()))
-                    {
-                        topTokenService.verifyToken(top_loginUser);
-                        UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(top_loginUser, null, top_loginUser.getAuthorities());
-                        authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
-                        SecurityContextHolder.getContext().setAuthentication(authenticationToken);
-                    }
-                }else{
+            } else {
+                if (bsTenant) {
                     String bsToken = bsTokenService.getToken(request);
-                    if(Validator.isNotEmpty(bsToken)){
+                    if (Validator.isNotEmpty(bsToken)) {
                         ClientBsLoginUser clientBsLoginUser = bsTokenService.getLoginUser(request);
-                        if (Validator.isNotNull(clientBsLoginUser) && Validator.isNull(SecurityUtils.getAuthentication()))
-                        {
+                        if (Validator.isNotNull(clientBsLoginUser) && Validator.isNull(SecurityUtils.getAuthentication())) {
                             bsTokenService.verifyToken(clientBsLoginUser);
                             UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(clientBsLoginUser, null, null);
                             authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
-                            SecurityContextHolder.getContext().setAuthentication(authenticationToken);}
+                            SecurityContextHolder.getContext().setAuthentication(authenticationToken);
+                        }
 
-                    }else{
+                    } else {
                         //子系统
                         LoginUser loginUser = null;
 
                         loginUser = tokenService.getLoginUser(request);
 
-                        if (Validator.isNotNull(loginUser) && Validator.isNull(SecurityUtils.getAuthentication()))
-                        {
+                        if (Validator.isNotNull(loginUser) && Validator.isNull(SecurityUtils.getAuthentication())) {
                             tokenService.verifyToken(loginUser);
                             UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginUser, null, loginUser.getAuthorities());
                             authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
                             SecurityContextHolder.getContext().setAuthentication(authenticationToken);
                         }
                     }
-
+                } else if (!enabledTenant) {
+                    //SAAS管理员
+                    TopLoginUser top_loginUser = topTokenService.getLoginUser(request);
+                    if (Validator.isNotNull(top_loginUser) && Validator.isNull(SecurityUtils.getAuthentication())) {
+                        topTokenService.verifyToken(top_loginUser);
+                        UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(top_loginUser, null, top_loginUser.getAuthorities());
+                        authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
+                        SecurityContextHolder.getContext().setAuthentication(authenticationToken);
+                    }
                 }
             }
-        }catch (Exception e){
+        } catch (Exception e) {
             request.getRequestDispatcher("/filter/token_auth_fail").forward(request, response);
             return;
         }

+ 0 - 18
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/BsSysLoginService.java

@@ -57,7 +57,6 @@ public class BsSysLoginService
 {
     @Autowired
     private BsTokenService tokenService;
-
     @Resource
     private AuthenticationManager authenticationManager;
 
@@ -133,23 +132,6 @@ public class BsSysLoginService
         AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
         ClientBsLoginUser loginUser = (ClientBsLoginUser) authentication.getPrincipal();
         BsSysUser user = iSysUserService.updateLoginTimeIp(loginUser.getUser().getUserId());
-        String dualAuth = configService.selectConfigByKey("login.dual.auth");
-        if(Validator.isNotEmpty(dualAuth)&&dualAuth.equals("1")){
-            if(Validator.isEmpty(tel)){
-                throw new CustomException("手机号码不能为空");
-            }
-            String key = Constants.LOGIN_SMS + tel;
-            String localSmsCode =  redisCache.getCacheObject(key);
-            if(smsCode==null){
-                throw new CustomException("验证码不能为空");
-            }
-            if(!localSmsCode.equals(smsCode)){
-                throw new CustomException("验证码错误");
-            }
-            if(!tel.equals(user.getPhonenumber())){
-                throw new CustomException("手机号码和登录账号不匹配");
-            }
-        }
         loginUser.setUser(user);
         // 生成token
         return tokenService.createToken(loginUser);

+ 69 - 0
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/BsSysPermissionService.java

@@ -0,0 +1,69 @@
+package com.zhongzheng.framework.web.service;
+
+import com.zhongzheng.common.core.domain.entity.SysUser;
+import com.zhongzheng.modules.bs.system.domain.BsSysUser;
+import com.zhongzheng.modules.bs.system.service.IBsSysMenuService;
+import com.zhongzheng.modules.bs.system.service.IBsSysRoleService;
+import com.zhongzheng.modules.system.service.ISysMenuService;
+import com.zhongzheng.modules.system.service.ISysRoleService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * 用户权限处理
+ *
+ * @author zhongzheng
+ */
+@Component
+public class BsSysPermissionService
+{
+    @Autowired
+    private IBsSysRoleService roleService;
+
+    @Autowired
+    private IBsSysMenuService iBsSysMenuService;
+    /**
+     * 获取角色数据权限
+     *
+     * @param user 用户信息
+     * @return 角色权限信息
+     */
+    public Set<String> getRolePermission(BsSysUser user)
+    {
+        Set<String> roles = new HashSet<String>();
+        // 管理员拥有所有权限
+        if (user.isAdmin())
+        {
+            roles.add("admin");
+        }
+        else
+        {
+            roles.addAll(roleService.selectRolePermissionByUserId(user.getUserId()));
+        }
+        return roles;
+    }
+
+    /**
+     * 企业b端获取菜单数据权限
+     *
+     * @param user 用户信息
+     * @return 菜单权限信息
+     */
+    public Set<String> getBsMenuPermission(BsSysUser user)
+    {
+        Set<String> perms = new HashSet<String>();
+        // 管理员拥有所有权限
+        if (user.isAdmin())
+        {
+            perms.add("*:*:*");
+        }
+        else
+        {
+            perms.addAll(iBsSysMenuService.selectMenuPermsByUserId(user.getUserId()));
+        }
+        return perms;
+    }
+}

+ 9 - 7
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/BsTokenService.java

@@ -54,6 +54,7 @@ public class BsTokenService
 
     @Autowired
     private RedisCache redisCache;
+//    private TokenService redisCache;
 
 
     @Autowired
@@ -85,7 +86,7 @@ public class BsTokenService
                 return errorUser;
             }
             String userKey = getTokenKey(uuid);
-            ClientBsLoginUser user = redisCache.getCacheObject(userKey);
+            ClientBsLoginUser user = redisCache.getBsCacheObject(userKey);
             return user;
         }
         return null;
@@ -127,21 +128,22 @@ public class BsTokenService
      */
     public String createToken(ClientBsLoginUser loginUser)
     {
-        String token = IdUtil.simpleUUID();
-        loginUser.setToken(token);
+        String key = IdUtil.simpleUUID();
+        loginUser.setToken(key);
         setUserAgent(loginUser);
         refreshToken(loginUser);
         Map<String, Object> claims = new HashMap<>();
-        claims.put(Constants.BS_LOGIN_USER_KEY, token);
+        claims.put(Constants.BS_LOGIN_USER_KEY, key);
         String secret = createToken(claims);
-        if(Validator.isNotEmpty(token)){
+        if(Validator.isNotEmpty(key)){
             UserLoginKeyAddBo addBo = new UserLoginKeyAddBo();
             addBo.setUserId(loginUser.getUser().getUserId());
-            addBo.setUserKey(token);
+            addBo.setTenantId(loginUser.getUser().getTenantId());
+            addBo.setUserKey(key);
             addBo.setIp(loginUser.getIpaddr());
             addBo.setBrowser(loginUser.getBrowser());
             addBo.setSecret(secret);
-            iUserLoginKeyService.insertByAddBo(addBo);
+            iUserLoginKeyService.insertByBo(addBo);
         }
         return secret;
     }

+ 57 - 0
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/BsUserDetailsServiceImpl.java

@@ -0,0 +1,57 @@
+package com.zhongzheng.framework.web.service;
+
+import cn.hutool.core.lang.Validator;
+import com.zhongzheng.common.enums.UserStatus;
+import com.zhongzheng.common.exception.BaseException;
+import com.zhongzheng.modules.bs.company.entity.ClientBsLoginUser;
+import com.zhongzheng.modules.bs.system.domain.BsSysUser;
+import com.zhongzheng.modules.bs.system.service.IBsSysUserService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+import org.springframework.stereotype.Service;
+
+/**
+ * 用户验证处理
+ *
+ * @author zhongzheng
+ */
+@Service
+public class BsUserDetailsServiceImpl implements UserDetailsService {
+    private static final Logger log = LoggerFactory.getLogger(BsUserDetailsServiceImpl.class);
+
+    @Autowired
+    private IBsSysUserService userService;
+
+    @Autowired
+    private BsSysPermissionService permissionService;
+
+
+    @Override
+    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
+        //普通系统用户
+        BsSysUser user = userService.getUser(username);
+        if (Validator.isNull(user)) {
+            log.info("登录用户:{} 不存在.", username);
+            throw new UsernameNotFoundException("登录用户:" + username + " 不存在");
+        } else if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
+            log.info("登录用户:{} 已被删除.", username);
+            throw new BaseException("对不起,您的账号:" + username + " 已被删除");
+        } else if (user.getStatus().longValue() == 0L) {
+            log.info("登录用户:{} 已被停用.", username);
+            throw new BaseException("对不起,您的账号:" + username + " 已停用");
+        }
+
+        return createLoginUser(user);
+    }
+
+    public UserDetails createLoginUser(BsSysUser user) {
+
+        return new ClientBsLoginUser(user, permissionService.getBsMenuPermission(user));
+    }
+
+
+}

+ 8 - 0
zhongzheng-framework/src/main/java/com/zhongzheng/framework/web/service/UserLoginKeyServiceImpl.java

@@ -92,6 +92,14 @@ public class UserLoginKeyServiceImpl extends ServiceImpl<UserLoginKeyMapper, Use
         add.setUpdateTime(DateUtils.getNowTime());
         return this.save(add);
     }
+    @Override
+    public Boolean insertByBo(UserLoginKeyAddBo bo) {
+        UserLoginKey add = BeanUtil.toBean(bo, UserLoginKey.class);
+        validEntityBeforeSave(add);
+        add.setCreateTime(DateUtils.getNowTime());
+        add.setUpdateTime(DateUtils.getNowTime());
+        return baseMapper.insertByBo(add);
+    }
 
     @Override
     public Boolean updateByEditBo(UserLoginKeyEditBo bo) {

+ 1 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/company/service/impl/CompanyServiceImpl.java

@@ -197,10 +197,9 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
                 companyIdList.add(companyId);
             }
             //筛选公司以及部门中包含参数姓名
-            List<CompanyVo> filteredCompanyVos = companyVos.stream()
+            companyVos = companyVos.stream()
                     .filter(companyVo -> companyIdList.contains(companyVo.getCompanyId()))
                     .collect(Collectors.toList());
-            return filteredCompanyVos;
         }
         return companyVos;
     }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/goods/bo/BsUserGoodsCollectionAddBo.java

@@ -28,6 +28,8 @@ public class BsUserGoodsCollectionAddBo {
     /** 商品id */
     @ApiModelProperty("商品包配置id")
     private Long configId;
+    /** 教育类型 */
+    private Long companyId;
     /** 类型 */
     @ApiModelProperty("类型")
     private Long type;

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/goods/bo/BsUserGoodsCollectionEditBo.java

@@ -24,6 +24,8 @@ public class BsUserGoodsCollectionEditBo {
     /** 商品id */
     @ApiModelProperty("商品id")
     private Long goodsId;
+    /** 教育类型 */
+    private Long companyId;
     @ApiModelProperty("商品包配置id")
     private Long configId;
     /** 类型 */

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/goods/bo/BsUserGoodsCollectionQueryBo.java

@@ -44,6 +44,8 @@ public class BsUserGoodsCollectionQueryBo extends BaseEntity {
 	/** 教育类型 */
 	private Long educationType;
 	/** 教育类型 */
+	private Long companyId;
+	/** 教育类型 */
 	private String educationName;
 	/** 项目id */
 	private Long projectId;

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/goods/domain/BsUserGoodsCollection.java

@@ -35,6 +35,8 @@ private static final long serialVersionUID=1L;
     /** 商品名称 */
     private String goodsName;
     /** 教育类型 */
+    private Long companyId;
+    /** 教育类型 */
     private Long educationType;
     /** 教育类型名称 */
     private String educationName;

+ 7 - 5
zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/goods/service/impl/BsUserGoodsCollectionServiceImpl.java

@@ -98,6 +98,7 @@ public class BsUserGoodsCollectionServiceImpl extends ServiceImpl<BsUserGoodsCol
         lqw.eq(bo.getUserId() != null, BsUserGoodsCollection::getUserId, bo.getUserId());
         lqw.eq(bo.getStatus() != null, BsUserGoodsCollection::getStatus, bo.getStatus());
         lqw.eq(bo.getConfigId() != null, BsUserGoodsCollection::getConfigId, bo.getConfigId());
+        lqw.eq(bo.getCompanyId() != null, BsUserGoodsCollection::getCompanyId, bo.getCompanyId());
         lqw.eq( BsUserGoodsCollection::getCollectStatus,1);
         List<BsUserGoodsCollectionVo> bsUserGoodsCollectionVos = entity2Vo(this.list(lqw));
         bsUserGoodsCollectionVos.forEach(item -> {
@@ -105,8 +106,9 @@ public class BsUserGoodsCollectionServiceImpl extends ServiceImpl<BsUserGoodsCol
                 item.setTypeName(getTypeName(item.getType()));
                 OrderBusinessConfigGoodsQueryBo orderBusinessConfigGoodsQueryBo = new OrderBusinessConfigGoodsQueryBo();
                 orderBusinessConfigGoodsQueryBo.setConfigId(item.getConfigId());
+                orderBusinessConfigGoodsQueryBo.setStatus(1);
                 List<CompanyOrderBusinessConfigGoodsVo> companyOrderBusinessConfigGoodsVos = iOrderBusinessConfigGoodsService.selectCompanyMergeList(orderBusinessConfigGoodsQueryBo);
-                if (Validator.isNotEmpty(companyOrderBusinessConfigGoodsVos)) {
+                if (!companyOrderBusinessConfigGoodsVos.isEmpty()) {
                     CompanyOrderBusinessConfigGoodsVo companyOrderBusinessConfigGoodsVo = companyOrderBusinessConfigGoodsVos.get(0);
                     item.setMainImg(companyOrderBusinessConfigGoodsVo.getMainImg());
                     String goodsIds = companyOrderBusinessConfigGoodsVo.getGoodsIds();
@@ -115,7 +117,7 @@ public class BsUserGoodsCollectionServiceImpl extends ServiceImpl<BsUserGoodsCol
                     GoodsQueryBo goodsQueryBo = new GoodsQueryBo();
                     goodsQueryBo.setGoodsIds(collect);
                     List<CompanyGoodsVo> companyGoodsVos = iGoodsService.selectBsGoodList(goodsQueryBo);
-                    if (Validator.isNotEmpty(companyGoodsVos)) {
+                    if (!companyGoodsVos.isEmpty()) {
                         int size = companyGoodsVos.size();
                         if (size > 2) {
                             List<String> strings = new ArrayList<>();
@@ -128,7 +130,7 @@ public class BsUserGoodsCollectionServiceImpl extends ServiceImpl<BsUserGoodsCol
                             item.setGoods(getReplace(collect2));
                         }
                         List<String> subjectNames = companyGoodsVos.stream().map(CompanyGoodsVo::getSubjectNames).distinct().collect(Collectors.toList());
-                        if (Validator.isNotEmpty(subjectNames) && subjectNames.size() > 2) {
+                        if (!subjectNames.isEmpty() && subjectNames.size() > 2) {
                             List<String> strings = new ArrayList<>();
                             strings.add(subjectNames.get(0));
                             strings.add(subjectNames.get(1));
@@ -139,7 +141,7 @@ public class BsUserGoodsCollectionServiceImpl extends ServiceImpl<BsUserGoodsCol
                         }
                         List<Long> years = companyGoodsVos.stream().map(CompanyGoodsVo::getYear).collect(Collectors.toList());
                         List<String> yearList = years.stream().map(String::valueOf).collect(Collectors.toList());
-                        if (Validator.isNotEmpty(yearList)&&yearList.size()>2){
+                        if (!yearList.isEmpty() &&yearList.size()>2){
                             List<String> strings = new ArrayList<>();
                             strings.add(yearList.get(0));
                             strings.add(yearList.get(1));
@@ -150,7 +152,7 @@ public class BsUserGoodsCollectionServiceImpl extends ServiceImpl<BsUserGoodsCol
                         }
                         List<BigDecimal> prices = companyGoodsVos.stream().map(CompanyGoodsVo::getStandPrice).collect(Collectors.toList());
                         List<String> priecsList = prices.stream().map(String::valueOf).collect(Collectors.toList());
-                        if (Validator.isNotEmpty(priecsList)&&priecsList.size()>2){
+                        if (!priecsList.isEmpty()&&priecsList.size()>2){
                             List<String> strings = new ArrayList<>();
                             strings.add(priecsList.get(0));
                             strings.add(priecsList.get(1));

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/goods/vo/BsUserGoodsCollectionVo.java

@@ -30,6 +30,10 @@ public class BsUserGoodsCollectionVo {
 	@Excel(name = "商品包配置id")
 	@ApiModelProperty("商品包配置id")
 	private Long configId;
+	/** 企业id */
+	@Excel(name = "企业id")
+	@ApiModelProperty("企业id")
+	private Long companyId;
 	/** 类型 */
 	@ApiModelProperty("类型")
 	private Long type;

+ 0 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/system/domain/BsSysDictData.java

@@ -73,7 +73,6 @@ public class BsSysDictData implements Serializable
     /** 表格字典样式 */
     private String listClass;
 
-    @TableField(value = "tenant_id")
     private String tenantId;
 
     /** 是否默认(Y是 N否) */

+ 11 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/system/mapper/BsSysUserMapper.java

@@ -37,8 +37,16 @@ public interface BsSysUserMapper extends BaseMapper<BsSysUser> {
      * @param userId 用户ID
      * @return 用户对象信息
      */
+    @InterceptorIgnore(tenantLine = "true")
     public BsSysUser selectUserById(Long userId);
-
+    @InterceptorIgnore(tenantLine = "true")
+    public Integer checkUserName(String userName);
+    @InterceptorIgnore(tenantLine = "true")
+    public BsSysUser checkPhone(BsSysUser user);
+    @InterceptorIgnore(tenantLine = "true")
+    public BsSysUser checkEmail(BsSysUser user);
+    @InterceptorIgnore(tenantLine = "true")
+    public BsSysUser getUser(String userName);
     @InterceptorIgnore(tenantLine = "true")
     public BsSysUser selectUserByTenant(@Param("userName") String userName,@Param("tenantId") Long tenantId);
 
@@ -50,4 +58,6 @@ public interface BsSysUserMapper extends BaseMapper<BsSysUser> {
 
     @InterceptorIgnore(tenantLine = "true")
     BsSysUser getOneIdCardByTenant(@Param("encrypt") String encrypt);
+    @InterceptorIgnore(tenantLine = "true")
+    Boolean updateTime(BsSysUser user);
 }

+ 6 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/system/service/IBsSysUserService.java

@@ -84,6 +84,12 @@ public interface IBsSysUserService extends IService<BsSysUser> {
      * @param user 用户信息
      */
     public void checkUserAllowed(BsSysUser user);
+    /**
+     * 忽略商户id 企业id 根据用户姓名查询
+     *
+     * @param userName 用户姓名
+     */
+    public BsSysUser getUser(String userName);
 
     /**
      * 新增用户信息

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/system/service/impl/BsSysDictDataServiceImpl.java

@@ -36,6 +36,7 @@ public class BsSysDictDataServiceImpl extends ServiceImpl<BsSysDictDataMapper, B
                 .eq(StrUtil.isNotBlank(dictData.getStatus()), BsSysDictData::getStatus, dictData.getStatus())
                 .in(dictData.getStatusArray()!=null, BsSysDictData::getStatus, dictData.getStatusArray())
                 .eq(dictData.getDictTypeId()!=null, BsSysDictData::getDictTypeId, dictData.getDictTypeId())
+                .eq(dictData.getTenantId()!=null, BsSysDictData::getTenantId, dictData.getTenantId())
                 .orderByAsc(BsSysDictData::getDictSort));
     }
 

+ 12 - 11
zhongzheng-system/src/main/java/com/zhongzheng/modules/bs/system/service/impl/BsSysUserServiceImpl.java

@@ -151,8 +151,8 @@ public class BsSysUserServiceImpl extends ServiceImpl<BsSysUserMapper, BsSysUser
      */
     @Override
     public String checkUserNameUnique(String userName) {
-        int count = count(new LambdaQueryWrapper<BsSysUser>().eq(BsSysUser::getUserName, userName).ne(BsSysUser::getStatus, -1).last("limit 1"));
-        if (count > 0) {
+        Integer i = this.baseMapper.checkUserName(userName);
+        if (i > 0) {
             return UserConstants.NOT_UNIQUE;
         }
         return UserConstants.UNIQUE;
@@ -167,10 +167,8 @@ public class BsSysUserServiceImpl extends ServiceImpl<BsSysUserMapper, BsSysUser
     @Override
     public String checkPhoneUnique(BsSysUser user) {
         Long userId = Validator.isNull(user.getUserId()) ? -1L : user.getUserId();
-        BsSysUser info = getOne(new LambdaQueryWrapper<BsSysUser>()
-                .select(BsSysUser::getUserId, BsSysUser::getPhonenumber)
-                .eq(BsSysUser::getPhonenumber, user.getPhonenumber()).last("limit 1"));
-        if (Validator.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
+        BsSysUser bsSysUser = this.baseMapper.checkPhone(user);
+        if (Validator.isNotNull(bsSysUser) && bsSysUser.getUserId().longValue() != userId.longValue()) {
             return UserConstants.NOT_UNIQUE;
         }
         return UserConstants.UNIQUE;
@@ -185,10 +183,8 @@ public class BsSysUserServiceImpl extends ServiceImpl<BsSysUserMapper, BsSysUser
     @Override
     public String checkEmailUnique(BsSysUser user) {
         Long userId = Validator.isNull(user.getUserId()) ? -1L : user.getUserId();
-        BsSysUser info = getOne(new LambdaQueryWrapper<BsSysUser>()
-                .select(BsSysUser::getUserId, BsSysUser::getEmail)
-                .eq(BsSysUser::getEmail, user.getEmail()).last("limit 1"));
-        if (Validator.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
+        BsSysUser bsSysUser = this.baseMapper.checkEmail(user);
+        if (Validator.isNotNull(bsSysUser) && bsSysUser.getUserId().longValue() != userId.longValue()) {
             return UserConstants.NOT_UNIQUE;
         }
         return UserConstants.UNIQUE;
@@ -206,6 +202,11 @@ public class BsSysUserServiceImpl extends ServiceImpl<BsSysUserMapper, BsSysUser
         }
     }
 
+    @Override
+    public BsSysUser getUser(String userName) {
+        return this.baseMapper.getUser(userName);
+    }
+
     /**
      * 新增保存用户信息
      *
@@ -473,7 +474,7 @@ public class BsSysUserServiceImpl extends ServiceImpl<BsSysUserMapper, BsSysUser
     public BsSysUser updateLoginTimeIp(Long userId) {
         BsSysUser user = selectUserById(userId);
         user.setUpdateTime(DateUtils.getNowTime());
-        baseMapper.updateById(user);
+        baseMapper.updateTime(user);
         return user;
     }
 

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserLoginKeyAddBo.java

@@ -40,4 +40,5 @@ public class UserLoginKeyAddBo {
     @ApiModelProperty("浏览器")
     private String browser;
     private String secret;
+    private Long tenantId;
 }

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/domain/UserLoginKey.java

@@ -43,4 +43,5 @@ private static final long serialVersionUID=1L;
     /** 浏览器 */
     private String browser;
     private String secret;
+    private Long tenantId;
 }

+ 4 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/mapper/UserLoginKeyMapper.java

@@ -1,6 +1,8 @@
 package com.zhongzheng.modules.user.mapper;
 
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zhongzheng.modules.user.bo.UserLoginKeyAddBo;
 import com.zhongzheng.modules.user.domain.UserLoginKey;
 
 /**
@@ -11,4 +13,6 @@ import com.zhongzheng.modules.user.domain.UserLoginKey;
  */
 public interface UserLoginKeyMapper extends BaseMapper<UserLoginKey> {
 
+    @InterceptorIgnore(tenantLine = "true")
+    Boolean insertByBo(UserLoginKey bo);
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/mapper/UserMapper.java

@@ -2,6 +2,7 @@ package com.zhongzheng.modules.user.mapper;
 
 import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zhongzheng.modules.bs.system.domain.BsSysUser;
 import com.zhongzheng.modules.user.bo.RanKingUserQuery;
 import com.zhongzheng.modules.user.bo.UserQueryBo;
 import com.zhongzheng.modules.user.bo.UserStudyRecordQueryBo;
@@ -86,4 +87,5 @@ public interface UserMapper extends BaseMapper<User> {
 
     @InterceptorIgnore(tenantLine = "true")
     User getByCardNoTenant(String idCard);
+
 }

+ 7 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/service/IUserLoginKeyService.java

@@ -1,5 +1,6 @@
 package com.zhongzheng.modules.user.service;
 
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.zhongzheng.modules.user.bo.UserLoginKeyAddBo;
 import com.zhongzheng.modules.user.bo.UserLoginKeyEditBo;
@@ -36,6 +37,12 @@ public interface IUserLoginKeyService extends IService<UserLoginKey> {
 	 * @return
 	 */
 	Boolean insertByAddBo(UserLoginKeyAddBo bo);
+	/**
+	 * 根据新增业务对象插入用户登录KEY
+	 * @param bo 用户登录KEY新增业务对象
+	 * @return
+	 */
+	Boolean insertByBo(UserLoginKeyAddBo bo);
 
 	/**
 	 * 根据编辑业务对象修改用户登录KEY

+ 43 - 1
zhongzheng-system/src/main/resources/mapper/modules/bsSys/BsSysUserMapper.xml

@@ -124,6 +124,44 @@
         where u.user_id = #{userId} and u.status=1
     </select>
 
+    <select id="checkUserName" parameterType="String" resultType="Integer">
+        select count(1) from bs_sys_user u
+        where u.status=1
+        <if test="userName != null and userName != ''">
+            AND u.user_name like concat('%', #{userName}, '%')
+        </if>
+    </select>
+    <select id="checkPhone" parameterType="com.zhongzheng.modules.bs.system.domain.BsSysUser" resultMap="SysUserResult">
+        select * from bs_sys_user u
+        where u.status=1
+        <if test="userId != null and userId != ''">
+            AND u.user_id =#{userId}
+        </if>
+        <if test="phonenumber != null and phonenumber != ''">
+            AND u.phonenumber like concat('%', #{phonenumber}, '%')
+        </if>
+        limit 1
+    </select>
+    <select id="checkEmail" parameterType="com.zhongzheng.modules.bs.system.domain.BsSysUser" resultMap="SysUserResult">
+        select * from bs_sys_user u
+        where u.status=1
+        <if test="userId != null and userId != ''">
+            AND u.user_id =#{userId}
+        </if>
+        <if test="email != null and email != ''">
+            AND u.email =#{email}
+        </if>
+        limit 1
+    </select>
+    <select id="getUser" parameterType="String" resultMap="SysUserResult">
+        select * from bs_sys_user u
+        where u.status=1
+        <if test="userName != null and userName != ''">
+            AND u.user_name =#{userName}
+        </if>
+        limit 1
+    </select>
+
     <select id="selectUserByTenant" parameterType="map" resultMap="SysUserResult">
         <include refid="selectUserVo"/>
         where u.user_name = #{userName} and u.`status` != -1 and u.tenant_id = #{tenantId}
@@ -147,5 +185,9 @@
     <select id="getOneIdCardByTenant" parameterType="java.lang.String" resultType="com.zhongzheng.modules.bs.system.domain.BsSysUser">
         SELECT * FROM bs_sys_user WHERE `status` = 1 AND id_card = #{encrypt}
     </select>
-
+    <update id="updateTime" parameterType="com.zhongzheng.modules.user.domain.User">
+        update bs_sys_user
+        set update_time=#{updateTime}
+        where user_id = #{userId}
+    </update>
 </mapper>

+ 1 - 0
zhongzheng-system/src/main/resources/mapper/modules/goods/BsUserGoodsCollectionMapper.xml

@@ -10,6 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="userId" column="user_id"/>
         <result property="status" column="status"/>
         <result property="collectStatus" column="collect_status"/>
+        <result property="companyId" column="company_id"/>
         <result property="createTime" column="create_time"/>
         <result property="updateTime" column="update_time"/>
         <result property="goodsName" column="goods_name"/>

+ 5 - 1
zhongzheng-system/src/main/resources/mapper/modules/user/UserLoginKeyMapper.xml

@@ -12,8 +12,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="createTime" column="create_time"/>
         <result property="updateTime" column="update_time"/>
         <result property="ip" column="ip"/>
+        <result property="tenantId" column="tenant_id"/>
         <result property="browser" column="browser"/>
     </resultMap>
-
+    <insert id="insertByBo" parameterType="com.zhongzheng.modules.user.domain.UserLoginKey">
+        INSERT INTO user_login_key (user_id, user_key, create_time, update_time, ip, browser, secret,tenant_id)
+        VALUES (#{userId}, #{userKey}, #{createTime}, #{updateTime}, #{ip}, #{browser},#{secret},#{tenantId})
+    </insert>
 
 </mapper>

+ 211 - 228
zhongzheng-system/src/main/resources/mapper/modules/user/UserMapper.xml

@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.zhongzheng.modules.user.mapper.UserMapper">
 
     <resultMap type="com.zhongzheng.modules.user.domain.User" id="UserResult">
@@ -85,10 +85,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
 
-
-    <select id="selectByRank" parameterType="com.zhongzheng.modules.user.bo.RanKingUserQuery" resultMap="RanKingUserResult">
-        SELECT sum(s.study_duration) AS sum_study,u.nickname,u.avatar   FROM `user` u
-            LEFT JOIN user_study_record s ON u.user_id=s.user_id where 1=1
+    <select id="selectByRank" parameterType="com.zhongzheng.modules.user.bo.RanKingUserQuery"
+            resultMap="RanKingUserResult">
+        SELECT sum(s.study_duration) AS sum_study,u.nickname,u.avatar FROM `user` u
+        LEFT JOIN user_study_record s ON u.user_id=s.user_id where 1=1
         <if test="userId != null and userId != ''">
             AND u.user_id = #{userId}
         </if>
@@ -98,44 +98,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         GROUP BY u.user_id
     </select>
 
-    <select id="selectByRanks" parameterType="com.zhongzheng.modules.user.bo.RanKingUserQuery" resultMap="RanKingUserResult">
+    <select id="selectByRanks" parameterType="com.zhongzheng.modules.user.bo.RanKingUserQuery"
+            resultMap="RanKingUserResult">
         SELECT A.*
         FROM
-            (
-            SELECT sum(s.study_duration) AS sum_study,u.nickname,u.avatar  FROM `user` u
-            LEFT JOIN user_study_record s ON u.user_id=s.user_id where 1=1
+        (
+        SELECT sum(s.study_duration) AS sum_study,u.nickname,u.avatar FROM `user` u
+        LEFT JOIN user_study_record s ON u.user_id=s.user_id where 1=1
         <if test="startTime != null and startTime != ''">
             AND s.create_time BETWEEN #{startTime} and #{endTime}
         </if>
-            GROUP BY u.user_id ORDER BY sum_study desc LIMIT 20
-            ) A where
+        GROUP BY u.user_id ORDER BY sum_study desc LIMIT 20
+        ) A where
         A.sum_study >0
     </select>
 
     <select id="selectByRankOne" parameterType="integer" resultType="int">
-        SELECT
-            COUNT(s.sum_study)
-        FROM
-            (SELECT sum( s.study_duration ) AS sum_study FROM user_study_record s  WHERE 1 = 1 GROUP BY s.user_id) s
+        SELECT COUNT(s.sum_study)
+        FROM (SELECT sum(s.study_duration) AS sum_study FROM user_study_record s WHERE 1 = 1 GROUP BY s.user_id) s
         WHERE s.sum_study >= #{hourse}
     </select>
 
     <select id="selectByRankOneByTime" parameterType="map" resultType="int">
         SELECT
-            COUNT(s.sum_study)
+        COUNT(s.sum_study)
         FROM
-            (SELECT sum( s.study_duration ) AS sum_study FROM user_study_record s  WHERE 1 = 1
+        (SELECT sum( s.study_duration ) AS sum_study FROM user_study_record s WHERE 1 = 1
         <if test="startTime != null and startTime != ''">
             and s.create_time BETWEEN #{startTime} and #{endTime}
         </if>
-            GROUP BY s.user_id) s
+        GROUP BY s.user_id) s
         WHERE s.sum_study >= #{hourse}
 
     </select>
 
 
-    <select id="selectByOneRank" parameterType="com.zhongzheng.modules.user.bo.RanKingUserQuery" resultMap="RanKingUserResult">
-        SELECT u.nickname,u.avatar   FROM `user` u
+    <select id="selectByOneRank" parameterType="com.zhongzheng.modules.user.bo.RanKingUserQuery"
+            resultMap="RanKingUserResult">
+        SELECT u.nickname,u.avatar FROM `user` u
         where 1=1
         <if test="userId != null and userId != ''">
             AND u.user_id = #{userId}
@@ -143,24 +143,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         GROUP BY u.user_id
     </select>
     <select id="selectUserNum" parameterType="integer" resultType="int">
-        SELECT
-            COUNT(user_id)
-        FROM
-            `user`
-        WHERE 1=1 and user_level = #{grade}
+        SELECT COUNT(user_id)
+        FROM `user`
+        WHERE 1 = 1
+          and user_level = #{grade}
     </select>
 
     <select id="selectListByBo" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo" resultMap="UserResult">
         SELECT DISTINCT
         u.*,
         (case WHEN u.union_id is null then 0 ELSE 1 end) as user_bind_wx
-        <if test="getOrderNum != null and getOrderNum == 1" >
-        ,ou.goods_course_num,ou.goods_bank_num,ou.goods_live_num
+        <if test="getOrderNum != null and getOrderNum == 1">
+            ,ou.goods_course_num,ou.goods_bank_num,ou.goods_live_num
         </if>
         FROM
         `user` u
 
-        <if test="getOrderNum != null and getOrderNum == 1" >
+        <if test="getOrderNum != null and getOrderNum == 1">
             LEFT JOIN (
             SELECT
             sum( CASE WHEN g.goods_type = 1 THEN 1 ELSE 0 END ) AS goods_course_num,
@@ -203,31 +202,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="endTime != null and endTime != ''">
             AND u.create_time &lt; #{endTime}
         </if>
-        <if test="userKerWord != null and userKerWord != ''" >
-            AND (u.realname like concat('%', #{userKerWord}, '%') OR u.telphone like concat('%', #{userKerWord,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%') OR u.id_card like concat('%', #{userKerWord,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
+        <if test="userKerWord != null and userKerWord != ''">
+            AND (u.realname like concat('%', #{userKerWord}, '%') OR u.telphone like concat('%',
+            #{userKerWord,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%') OR u.id_card like concat('%',
+            #{userKerWord,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
         </if>
-        <if test="nickname != null and nickname != ''" >
+        <if test="nickname != null and nickname != ''">
             AND u.nickname like concat('%', #{nickname}, '%')
         </if>
-        <if test="telphone != null and telphone != ''" >
+        <if test="telphone != null and telphone != ''">
             AND u.telphone like concat('%', #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
         </if>
-        <if test="idCard != null and idCard != ''" >
+        <if test="idCard != null and idCard != ''">
             AND u.id_card like concat('%', #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
         </if>
-        <if test="realname != null and realname != ''" >
+        <if test="realname != null and realname != ''">
             AND u.realname like concat('%', #{realname}, '%')
         </if>
-        <if test="companyName != null and companyName != ''" >
+        <if test="companyName != null and companyName != ''">
             AND u.company_name like concat('%', #{companyName}, '%')
         </if>
-        <if test="userId != null and userId != ''" >
+        <if test="userId != null and userId != ''">
             AND u.user_id = #{userId}
         </if>
-        <if test="empty != null and empty != ''" >
-           and u.realname is NOT NULL
+        <if test="empty != null and empty != ''">
+            and u.realname is NOT NULL
         </if>
-        <if test="goodsSearchKey != null and goodsSearchKey != ''" >
+        <if test="goodsSearchKey != null and goodsSearchKey != ''">
             and ( SELECT
             count(og.order_goods_id)
             FROM
@@ -238,26 +239,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             and og.`status` = 1
             and og.refund_status in (0,1,3)
             and og.pay_status in (2,3,4)
-            and (g.goods_name like concat('%', #{goodsSearchKey}, '%') or g.code like concat('%', #{goodsSearchKey}, '%'))
+            and (g.goods_name like concat('%', #{goodsSearchKey}, '%') or g.code like concat('%', #{goodsSearchKey},
+            '%'))
             and o.user_id = u.user_id)>0
         </if>
-        <if test="gradePoint != null and gradePoint == 1" >
-            AND (SELECT COUNT(u.user_id) FROM class_grade_user cgu where 1=1 AND u.status in (1) and cgu.user_id= u.user_id) > 0
+        <if test="gradePoint != null and gradePoint == 1">
+            AND (SELECT COUNT(u.user_id) FROM class_grade_user cgu where 1=1 AND u.status in (1) and cgu.user_id=
+            u.user_id) > 0
         </if>
-        <if test="gradePoint != null and gradePoint == 2" >
-            AND (SELECT COUNT(u.user_id) FROM class_grade_user cgu where 1=1 AND u.status in (1) and cgu.user_id= u.user_id) = 0
+        <if test="gradePoint != null and gradePoint == 2">
+            AND (SELECT COUNT(u.user_id) FROM class_grade_user cgu where 1=1 AND u.status in (1) and cgu.user_id=
+            u.user_id) = 0
         </if>
         <if test="searchKey != null and searchKey != '' and searchType == 0 ">
-            and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
+            and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%',
+            #{searchKey,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
         </if>
-        <if test="idCards != null and idCards.size()!=0 and searchType == 0" >
+        <if test="idCards != null and idCards.size()!=0 and searchType == 0">
             AND u.id_card in
             <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
                 #{item,typeHandler=com.zhongzheng.common.type.EncryptHandler}
             </foreach>
         </if>
-        <if test="searchType == 1" >
-            and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%') or
+        <if test="searchType == 1">
+            and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%',
+            #{searchKey,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%') or
             u.id_card in
             <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
                 #{item,typeHandler=com.zhongzheng.common.type.EncryptHandler}
@@ -272,12 +278,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="visitStartTime != null and visitStartTime !=''">
             and (SELECT
             count(*)
-            FROM user_visit_log where user_id = u.user_id and create_time>= #{visitStartTime}  and #{visitEndTime} >= create_time)>0
+            FROM user_visit_log where user_id = u.user_id and create_time>= #{visitStartTime} and #{visitEndTime} >=
+            create_time)>0
         </if>
         <if test="studyStartTime != null and studyStartTime !=''">
             and (SELECT
             count(*)
-            FROM user_study_log where user_id = u.user_id and create_time>= #{studyStartTime}  and #{studyEndTime} >= create_time)>0
+            FROM user_study_log where user_id = u.user_id and create_time>= #{studyStartTime} and #{studyEndTime} >=
+            create_time)>0
         </if>
         <if test="gradeName != null and gradeName != ''">
             and ( SELECT
@@ -299,14 +307,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectListNoTenant" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo" resultMap="UserResult">
         SELECT DISTINCT
         u.*
-    /*    ,(case WHEN u.union_id is null then 0 ELSE 1 end) as user_bind_wx */
-        <if test="getOrderNum != null and getOrderNum == 1" >
+        /* ,(case WHEN u.union_id is null then 0 ELSE 1 end) as user_bind_wx */
+        <if test="getOrderNum != null and getOrderNum == 1">
             ,ou.goods_course_num,ou.goods_bank_num,ou.goods_live_num
         </if>
         FROM
         `user` u
 
-        <if test="getOrderNum != null and getOrderNum == 1" >
+        <if test="getOrderNum != null and getOrderNum == 1">
             LEFT JOIN (
             SELECT
             sum( CASE WHEN g.goods_type = 1 THEN 1 ELSE 0 END ) AS goods_course_num,
@@ -349,31 +357,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="endTime != null and endTime != ''">
             AND u.create_time &lt; #{endTime}
         </if>
-        <if test="userKerWord != null and userKerWord != ''" >
-            AND (u.realname like concat('%', #{userKerWord}, '%') OR u.telphone like concat('%', #{userKerWord,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%') OR u.id_card like concat('%', #{userKerWord,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
+        <if test="userKerWord != null and userKerWord != ''">
+            AND (u.realname like concat('%', #{userKerWord}, '%') OR u.telphone like concat('%',
+            #{userKerWord,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%') OR u.id_card like concat('%',
+            #{userKerWord,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
         </if>
-        <if test="nickname != null and nickname != ''" >
+        <if test="nickname != null and nickname != ''">
             AND u.nickname like concat('%', #{nickname}, '%')
         </if>
-        <if test="telphone != null and telphone != ''" >
+        <if test="telphone != null and telphone != ''">
             AND u.telphone like concat('%', #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
         </if>
-        <if test="idCard != null and idCard != ''" >
+        <if test="idCard != null and idCard != ''">
             AND u.id_card like concat('%', #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
         </if>
-        <if test="realname != null and realname != ''" >
+        <if test="realname != null and realname != ''">
             AND u.realname like concat('%', #{realname}, '%')
         </if>
-        <if test="companyName != null and companyName != ''" >
+        <if test="companyName != null and companyName != ''">
             AND u.company_name like concat('%', #{companyName}, '%')
         </if>
-        <if test="userId != null and userId != ''" >
+        <if test="userId != null and userId != ''">
             AND u.user_id = #{userId}
         </if>
-        <if test="empty != null and empty != ''" >
+        <if test="empty != null and empty != ''">
             and u.realname is NOT NULL
         </if>
-        <if test="goodsSearchKey != null and goodsSearchKey != ''" >
+        <if test="goodsSearchKey != null and goodsSearchKey != ''">
             and ( SELECT
             count(og.order_goods_id)
             FROM
@@ -384,26 +394,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             and og.`status` = 1
             and og.refund_status in (0,1,3)
             and og.pay_status in (2,3,4)
-            and (g.goods_name like concat('%', #{goodsSearchKey}, '%') or g.code like concat('%', #{goodsSearchKey}, '%'))
+            and (g.goods_name like concat('%', #{goodsSearchKey}, '%') or g.code like concat('%', #{goodsSearchKey},
+            '%'))
             and o.user_id = u.user_id)>0
         </if>
-        <if test="gradePoint != null and gradePoint == 1" >
-            AND (SELECT COUNT(u.user_id) FROM class_grade_user cgu where 1=1 AND u.status in (1) and cgu.user_id= u.user_id) > 0
+        <if test="gradePoint != null and gradePoint == 1">
+            AND (SELECT COUNT(u.user_id) FROM class_grade_user cgu where 1=1 AND u.status in (1) and cgu.user_id=
+            u.user_id) > 0
         </if>
-        <if test="gradePoint != null and gradePoint == 2" >
-            AND (SELECT COUNT(u.user_id) FROM class_grade_user cgu where 1=1 AND u.status in (1) and cgu.user_id= u.user_id) = 0
+        <if test="gradePoint != null and gradePoint == 2">
+            AND (SELECT COUNT(u.user_id) FROM class_grade_user cgu where 1=1 AND u.status in (1) and cgu.user_id=
+            u.user_id) = 0
         </if>
         <if test="searchKey != null and searchKey != '' and searchType == 0 ">
-            and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
+            and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%',
+            #{searchKey,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%'))
         </if>
-        <if test="idCards != null and idCards.size()!=0 and searchType == 0" >
+        <if test="idCards != null and idCards.size()!=0 and searchType == 0">
             AND u.id_card in
             <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
                 #{item,typeHandler=com.zhongzheng.common.type.EncryptHandler}
             </foreach>
         </if>
-        <if test="searchType == 1" >
-            and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%', #{searchKey,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%') or
+        <if test="searchType == 1">
+            and (u.realname like concat('%', #{searchKey}, '%') or u.id_card like concat('%',
+            #{searchKey,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%') or
             u.id_card in
             <foreach collection="idCards" item="item" index="index" open="(" close=")" separator=",">
                 #{item,typeHandler=com.zhongzheng.common.type.EncryptHandler}
@@ -418,12 +433,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="visitStartTime != null and visitStartTime !=''">
             and (SELECT
             count(*)
-            FROM user_visit_log where user_id = u.user_id and create_time>= #{visitStartTime}  and #{visitEndTime} >= create_time)>0
+            FROM user_visit_log where user_id = u.user_id and create_time>= #{visitStartTime} and #{visitEndTime} >=
+            create_time)>0
         </if>
         <if test="studyStartTime != null and studyStartTime !=''">
             and (SELECT
             count(*)
-            FROM user_study_log where user_id = u.user_id and create_time>= #{studyStartTime}  and #{studyEndTime} >= create_time)>0
+            FROM user_study_log where user_id = u.user_id and create_time>= #{studyStartTime} and #{studyEndTime} >=
+            create_time)>0
         </if>
         <if test="gradeName != null and gradeName != ''">
             and ( SELECT
@@ -445,145 +462,122 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectStudyRecordList" resultMap="StudyRecordResult">
         SELECT
-            usr.study_duration,
-            c.course_name,
-            pv.title,
-            usr.start_time,
-            usr.end_time,
-            u.realname,
-            u.telphone
+        usr.study_duration,
+        c.course_name,
+        pv.title,
+        usr.start_time,
+        usr.end_time,
+        u.realname,
+        u.telphone
         FROM
-            user_study_record usr
-                LEFT JOIN course c ON usr.course_id = c.course_id
-                LEFT JOIN course_section cs ON usr.section_id = cs.section_id
-                LEFT JOIN polyv_video pv ON cs.polyv_id = pv.polyv_id
-                LEFT JOIN `user` u ON usr.user_id = u.user_id
+        user_study_record usr
+        LEFT JOIN course c ON usr.course_id = c.course_id
+        LEFT JOIN course_section cs ON usr.section_id = cs.section_id
+        LEFT JOIN polyv_video pv ON cs.polyv_id = pv.polyv_id
+        LEFT JOIN `user` u ON usr.user_id = u.user_id
         WHERE 1=1
-        <if test="userId != null and userId != ''" >
+        <if test="userId != null and userId != ''">
             AND usr.user_id = #{userId}
         </if>
-        <if test="courseName != null and courseName != ''" >
+        <if test="courseName != null and courseName != ''">
             AND c.course_name like concat('%', #{courseName}, '%')
         </if>
-        <if test="title != null and title != ''" >
+        <if test="title != null and title != ''">
             AND pv.title like concat('%', #{title}, '%')
         </if>
-        <if test="startTime1 != null and startTime1 != ''" >
+        <if test="startTime1 != null and startTime1 != ''">
             AND usr.start_time > #{startTime1}
         </if>
-        <if test="startTime2 != null and startTime2 != ''" >
+        <if test="startTime2 != null and startTime2 != ''">
             AND #{startTime2} > usr.start_time
         </if>
-        <if test="endTime1 != null and endTime1 != ''" >
+        <if test="endTime1 != null and endTime1 != ''">
             AND usr.end_time > #{endTime1}
         </if>
-        <if test="endTime2 != null and endTime2 != ''" >
+        <if test="endTime2 != null and endTime2 != ''">
             AND #{endTime2} > usr.end_time
         </if>
         ORDER BY
-            usr.record_id DESC
+        usr.record_id DESC
     </select>
 
 
     <select id="selectLookNum" parameterType="Long" resultType="integer">
-        SELECT
-            COUNT( user_id )
-        FROM
-            recruit_interview_message
-        WHERE
-            1 = 1
+        SELECT COUNT(user_id)
+        FROM recruit_interview_message
+        WHERE 1 = 1
           AND user_id = #{userId}
           AND look_status = 0
     </select>
 
     <select id="periodSum" parameterType="Long" resultType="Long">
-        SELECT
-            COUNT(1)
-        FROM
-            user_period up
-                LEFT JOIN user_period_status ups ON ups.period_id = up.id
-                LEFT JOIN class_grade_user cgu on up.grade_id = cgu.grade_id and up.user_id = cgu.user_id
-        WHERE
-            up.user_id = #{userId}
-          and ups.period_status =1
+        SELECT COUNT(1)
+        FROM user_period up
+                 LEFT JOIN user_period_status ups ON ups.period_id = up.id
+                 LEFT JOIN class_grade_user cgu on up.grade_id = cgu.grade_id and up.user_id = cgu.user_id
+        WHERE up.user_id = #{userId}
+          and ups.period_status = 1
           and cgu.change_grade = 0
-          and ups.`status` in (0,3)
+          and ups.`status` in (0, 3)
     </select>
     <select id="subscribeSum" parameterType="Long" resultType="Long">
-        SELECT
-            COUNT(1)
-        FROM
-            user_subscribe us
-        WHERE
-            us.user_id = #{userId}
+        SELECT COUNT(1)
+        FROM user_subscribe us
+        WHERE us.user_id = #{userId}
           AND us.subscribe_status = 1
-          and (us.exam_expend  is null or us.exam_expend = 0)
+          and (us.exam_expend is null or us.exam_expend = 0)
     </select>
 
     <select id="informSum" parameterType="Long" resultType="Long">
-        SELECT
-            COUNT(1)
-        FROM
-            inform_user iu
-        WHERE
-            iu.user_id = #{userId}
+        SELECT COUNT(1)
+        FROM inform_user iu
+        WHERE iu.user_id = #{userId}
           and iu.receipt_status = 0
-        and iu.system_status in (1,2)
+          and iu.system_status in (1, 2)
     </select>
 
     <select id="orderSum" parameterType="Long" resultType="Long">
-        SELECT
-            COUNT( 1 )
-        FROM
-            `order`
-        WHERE
-            user_id = #{userId}
-          AND order_status =0
+        SELECT COUNT(1)
+        FROM `order`
+        WHERE user_id = #{userId}
+          AND order_status = 0
     </select>
 
     <select id="queryUserByTelphoneTenant" parameterType="map" resultMap="UserResult">
-        SELECT
-            *
-        FROM
-            `user`
-        WHERE
-            telphone = #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}
-          AND status = 1 AND tenant_id = #{tenantId}
+        SELECT *
+        FROM `user`
+        WHERE telphone = #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}
+          AND status = 1
+          AND tenant_id = #{tenantId}
     </select>
 
-    <select id="getUserByTelNotTenant" parameterType="java.lang.String" resultType="com.zhongzheng.modules.user.domain.User">
-        SELECT
-            *
-        FROM
-            `user`
-        WHERE
-            telphone = #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler} AND status = 1
+    <select id="getUserByTelNotTenant" parameterType="java.lang.String"
+            resultType="com.zhongzheng.modules.user.domain.User">
+        SELECT *
+        FROM `user`
+        WHERE telphone = #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}
+          AND status = 1
     </select>
 
-    <select id="getUserByIdNumNotTenant" parameterType="java.lang.String" resultType="com.zhongzheng.modules.user.domain.User">
-        SELECT
-            *
-        FROM
-            `user`
-        WHERE
-            id_card = #{idNum,typeHandler=com.zhongzheng.common.type.EncryptHandler} AND status = 1
+    <select id="getUserByIdNumNotTenant" parameterType="java.lang.String"
+            resultType="com.zhongzheng.modules.user.domain.User">
+        SELECT *
+        FROM `user`
+        WHERE id_card = #{idNum,typeHandler=com.zhongzheng.common.type.EncryptHandler}
+          AND status = 1
     </select>
 
     <select id="queryUserByIdNumTenant" parameterType="map" resultMap="UserResult">
-        SELECT
-            *
-        FROM
-            `user`
-        WHERE
-            id_card = #{idNum,typeHandler=com.zhongzheng.common.type.EncryptHandler}
-          AND status = 1 AND tenant_id = #{tenantId}
+        SELECT *
+        FROM `user`
+        WHERE id_card = #{idNum,typeHandler=com.zhongzheng.common.type.EncryptHandler}
+          AND status = 1
+          AND tenant_id = #{tenantId}
     </select>
 
     <select id="selectAllUserList" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo" resultMap="UserResult">
-        SELECT
-            *
-        FROM
-            `user`
+        SELECT *
+        FROM `user`
     </select>
 
     <select id="editUserInfo" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo">
@@ -597,76 +591,63 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             </if>
         </trim>
         WHERE
-            user_id = #{userId}
+        user_id = #{userId}
     </select>
 
     <select id="getUserByTel" parameterType="java.lang.String" resultType="com.zhongzheng.modules.user.domain.User">
-        SELECT
-            *
-        FROM
-            `user`
-        WHERE
-            status = 1
-            AND(id_card = #{account,typeHandler=com.zhongzheng.common.type.EncryptHandler}
+        SELECT *
+        FROM `user`
+        WHERE status = 1
+          AND (id_card = #{account,typeHandler=com.zhongzheng.common.type.EncryptHandler}
             OR telphone = #{account,typeHandler=com.zhongzheng.common.type.EncryptHandler})
     </select>
 
     <select id="getUserByAccount" parameterType="java.lang.String" resultType="com.zhongzheng.modules.user.domain.User">
-        SELECT
-            *
-        FROM
-            `user`
-        WHERE
-            status = 1
+        SELECT *
+        FROM `user`
+        WHERE status = 1
           AND user_account = #{userAccount}
     </select>
 
     <select id="listByIdsNotTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.user.domain.User">
         SELECT
-            *
+        *
         FROM
-            `user`
+        `user`
         WHERE
-            status = 1 AND user_id IN
-            <foreach collection="userIds" item="item" index="index" open="(" close=")" separator=",">
-                #{item}
-            </foreach>
+        status = 1 AND user_id IN
+        <foreach collection="userIds" item="item" index="index" open="(" close=")" separator=",">
+            #{item}
+        </foreach>
     </select>
 
     <select id="getByIdNoTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.user.domain.User">
-        SELECT
-        *
-        FROM
-        `user`
-        WHERE
-        status = 1 AND user_id = #{userId}
+        SELECT *
+        FROM `user`
+        WHERE status = 1
+          AND user_id = #{userId}
     </select>
 
-    <select id="getByCardNoTenant" parameterType="java.lang.String" resultType="com.zhongzheng.modules.user.domain.User">
-        SELECT
-            *
-        FROM
-            `user`
-        WHERE
-            status = 1 AND id_card = #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}
-            LIMIT 1
+    <select id="getByCardNoTenant" parameterType="java.lang.String"
+            resultType="com.zhongzheng.modules.user.domain.User">
+        SELECT *
+        FROM `user`
+        WHERE status = 1
+          AND id_card = #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler} LIMIT 1
     </select>
 
     <select id="getUserOrderCount" parameterType="map" resultType="java.lang.Long">
-        SELECT
-            COUNT(o.order_sn)
-        FROM
-            `order` o
-                INNER JOIN order_goods og ON o.order_sn = og.order_sn
-                AND og.tenant_id = #{tenantId}
-                INNER JOIN goods g ON og.goods_id = g.goods_id
-                AND g.tenant_id = #{tenantId}
-        WHERE
-            o.`status` = 1
-            AND o.user_id = #{userId}
-            AND g.`code` = #{code}
-            AND g.goods_name = #{goodsName}
-            AND og.refund_status != 2
+        SELECT COUNT(o.order_sn)
+        FROM `order` o
+                 INNER JOIN order_goods og ON o.order_sn = og.order_sn
+            AND og.tenant_id = #{tenantId}
+                 INNER JOIN goods g ON og.goods_id = g.goods_id
+            AND g.tenant_id = #{tenantId}
+        WHERE o.`status` = 1
+          AND o.user_id = #{userId}
+          AND g.`code` = #{code}
+          AND g.goods_name = #{goodsName}
+          AND og.refund_status != 2
 	        AND og.pay_status IN ( 2, 3, 4 )
 	        AND g.`status` = 1
 	        AND og.`status` = 1
@@ -674,51 +655,53 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="dangAnList" parameterType="com.zhongzheng.modules.user.bo.UserQueryBo" resultMap="UserResult">
-        SELECT u.* from `user` u where  1=1
-        <if test="telphone != null and telphone != ''" >
+        SELECT u.* from `user` u where 1=1
+        <if test="telphone != null and telphone != ''">
             AND u.telphone like concat('%', #{telphone,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
         </if>
-        <if test="idCard != null and idCard != ''" >
+        <if test="idCard != null and idCard != ''">
             AND u.id_card like concat('%', #{idCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}, '%')
         </if>
-        <if test="realname != null and realname != ''" >
+        <if test="realname != null and realname != ''">
             AND u.realname like concat('%', #{realname}, '%')
         </if>
-        <if test="companyName != null and companyName != ''" >
+        <if test="companyName != null and companyName != ''">
             AND u.company_name like concat('%', #{companyName}, '%')
         </if>
-        <if test="majorId != null and majorId != ''" >
+        <if test="majorId != null and majorId != ''">
             AND (SELECT count(*) FROM `order` o
             LEFT JOIN order_goods og ON o.order_sn = og.order_sn
-            LEFT JOIN goods g ON og.goods_id = g.goods_id WHERE o.`status` = 1 AND o.user_id = u.user_id AND og.pay_status IN ( 2, 3, 4 )  AND og.refund_status != 2 AND g.major_id = #{majorId})>0
+            LEFT JOIN goods g ON og.goods_id = g.goods_id WHERE o.`status` = 1 AND o.user_id = u.user_id AND
+            og.pay_status IN ( 2, 3, 4 ) AND og.refund_status != 2 AND g.major_id = #{majorId})>0
         </if>
-        <if test="educationTypeId != null and educationTypeId != ''" >
+        <if test="educationTypeId != null and educationTypeId != ''">
             AND (SELECT count(*) FROM `order` o
             LEFT JOIN order_goods og ON o.order_sn = og.order_sn
-            LEFT JOIN goods g ON og.goods_id = g.goods_id WHERE o.`status` = 1 AND o.user_id = u.user_id AND og.pay_status IN ( 2, 3, 4 )  AND og.refund_status != 2 AND g.education_type_id = #{educationTypeId})>0
+            LEFT JOIN goods g ON og.goods_id = g.goods_id WHERE o.`status` = 1 AND o.user_id = u.user_id AND
+            og.pay_status IN ( 2, 3, 4 ) AND og.refund_status != 2 AND g.education_type_id = #{educationTypeId})>0
         </if>
-        <if test="businessId != null and businessId != ''" >
+        <if test="businessId != null and businessId != ''">
             AND (SELECT count(*) FROM `order` o
             LEFT JOIN order_goods og ON o.order_sn = og.order_sn
-            LEFT JOIN goods g ON og.goods_id = g.goods_id WHERE o.`status` = 1 AND o.user_id = u.user_id AND og.pay_status IN ( 2, 3, 4 )  AND og.refund_status != 2 AND g.business_id = #{businessId})>0
+            LEFT JOIN goods g ON og.goods_id = g.goods_id WHERE o.`status` = 1 AND o.user_id = u.user_id AND
+            og.pay_status IN ( 2, 3, 4 ) AND og.refund_status != 2 AND g.business_id = #{businessId})>0
         </if>
-        <if test="promiseUploadSign != null and promiseUploadSign == 1" >
+        <if test="promiseUploadSign != null and promiseUploadSign == 1">
             AND (SELECT COUNT(up.id) FROM user_profile up WHERE up.user_id = u.user_id AND up.current_status = 1
             AND INSTR(up.key_value,'"fieldKey":"commitment_seal","value":"oss/images/avatar')) &gt; 0
         </if>
-        <if test="promiseUploadSign != null and promiseUploadSign == 0" >
+        <if test="promiseUploadSign != null and promiseUploadSign == 0">
             AND (SELECT COUNT(up.id) FROM user_profile up WHERE up.user_id = u.user_id AND up.current_status = 1
             AND INSTR(up.key_value,'"fieldKey":"commitment_seal","value":"oss/images/avatar')) = 0
         </if>
-        <if test="promiseSign != null and promiseSign == 1" >
+        <if test="promiseSign != null and promiseSign == 1">
             AND (SELECT COUNT(up.id) FROM user_profile up WHERE up.user_id = u.user_id AND up.current_status = 1
             AND INSTR(up.key_value,'"fieldKey":"commitment_electr_signature","value":"oss/images/avatar')) &gt; 0
         </if>
-        <if test="promiseSign != null and promiseSign == 0" >
+        <if test="promiseSign != null and promiseSign == 0">
             AND (SELECT COUNT(up.id) FROM user_profile up WHERE up.user_id = u.user_id AND up.current_status = 1
             AND INSTR(up.key_value,'"fieldKey":"commitment_electr_signature","value":"oss/images/avatar')) = 0
         </if>
         order by u.user_id desc
     </select>
-
 </mapper>