Просмотр исходного кода

Merge remote-tracking branch 'origin/dev_20260131' into dev_20260131

donglang 3 месяцев назад
Родитель
Сommit
3e01b1c7fa

+ 31 - 3
sckw-auth/src/main/java/com/sckw/auth/model/vo/res/LoginResVo1.java

@@ -2,15 +2,12 @@ package com.sckw.auth.model.vo.res;
 
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.sckw.core.utils.LongToStringUtils;
-import com.sckw.system.api.model.dto.res.KwsRoleResDto;
 import com.sckw.system.api.model.dto.res.RoleInfoDto;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
-import javax.management.relation.RoleInfo;
 import java.io.Serial;
 import java.io.Serializable;
-import java.util.Date;
 import java.util.List;
 
 /**
@@ -158,4 +155,35 @@ public class LoginResVo1 implements Serializable {
     @Schema(description = "岗位角色列表")
     private List<RoleInfoDto> roleList;
 
+    /**
+     * APP端底部TabBar配置
+     */
+    private List<TabBarItem> tabBar;
+
+    @Data
+    public static class TabBarItem implements Serializable {
+        @Serial
+        private static final long serialVersionUID = 2168990757095988491L;
+        /**
+         * 菜单名称
+         */
+        private String text;
+        /**
+         * 未选中图标路径
+         */
+        private String iconPath;
+        /**
+         * 未选中图标路径
+         */
+        private String notSelectedIconPath;
+        /**
+         * 页面调整路径
+         */
+        private String pagePath;
+        /**
+         * 数量
+         */
+        private Integer count;
+    }
+
 }

+ 98 - 0
sckw-auth/src/main/java/com/sckw/auth/service/impl/AuthServiceImpl.java

@@ -76,6 +76,11 @@ public class AuthServiceImpl implements IAuthService {
 
         /*司机端*/
         if (loginBase.getSystemType() == SystemTypeEnum.DRIVER.getCode()) {
+            KwsUserResDto kwsUserResDto = systemService.queryByAccount(loginBase.getAccount());
+            if (Objects.nonNull(kwsUserResDto)) {
+                loginBase.setSystemType(SystemTypeEnum.COMPANY.getCode());
+                return this.commonAuth(loginBase);
+            }
             return this.driverAuth(loginBase);
         }
 
@@ -162,6 +167,10 @@ public class AuthServiceImpl implements IAuthService {
         loginRes.setClientType(loginBase.getClientType());
         loginRes.setSystemType(loginBase.getSystemType());
         loginRes.setToken(token);
+        List<LoginResVo1.TabBarItem> tabBar = buildAppTabBar(loginBase, null);
+        if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(tabBar)) {
+            loginRes.setTabBar(tabBar);
+        }
         loginRes.setRefreshToken(refreshToken);
         return HttpResult.ok(loginRes);
     }
@@ -226,6 +235,7 @@ public class AuthServiceImpl implements IAuthService {
         }
 
         /*数据组装**/
+
         LoginResVo1 loginRes = new LoginResVo1();
         loginRes.setId(user.getId());
         loginRes.setName(user.getName());
@@ -249,6 +259,10 @@ public class AuthServiceImpl implements IAuthService {
         loginRes.setRoleId(user.getRoleId());
         loginRes.setRoleName(user.getRoleName());
         loginRes.setRoleList(user.getRoleInfoDto());
+        List<LoginResVo1.TabBarItem> tabBar = buildAppTabBar(loginBase, user.getRoleName());
+        if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(tabBar)) {
+            loginRes.setTabBar(tabBar);
+        }
         if (user.getSystemType().equals(SystemTypeEnum.MANAGE.getCode())) {
             loginRes.setValid(true);
         } else {
@@ -785,6 +799,90 @@ public class AuthServiceImpl implements IAuthService {
         return loginRes;
     }
 
+    private boolean isAppLogin(LoginBase loginBase) {
+        String clientType = loginBase.getClientType();
+        return Objects.equals(clientType, ClientTypeEnum.app.getValue())
+                || Objects.equals(clientType, ClientTypeEnum.ios.getValue())
+                || Objects.equals(clientType, ClientTypeEnum.android.getValue())
+                || Objects.equals(clientType, ClientTypeEnum.mobile.getValue());
+    }
+
+    private List<LoginResVo1.TabBarItem> buildAppTabBar(LoginBase loginBase, String roleName) {
+        if (!isAppLogin(loginBase)) {
+            return List.of();
+        }
+        boolean isDoorKeeper = StringUtils.isNotBlank(roleName) && roleName.contains("门卫");
+        boolean isForkliftDriver = StringUtils.isNotBlank(roleName) && roleName.contains("铲车司机");
+        if (isDoorKeeper) {
+            return buildDoorKeeperTabBar();
+        }
+        if (isForkliftDriver) {
+            return buildForkliftDriverTabBar();
+        }
+        return buildDefaultDriverTabBar();
+    }
+
+    private List<LoginResVo1.TabBarItem> buildDoorKeeperTabBar() {
+        List<LoginResVo1.TabBarItem> items = new ArrayList<>();
+        items.add(buildTabBarItem(
+                "往来车辆",
+                "/static/tabbar/car_select.png",
+                "/static/tabbar/car.png",
+                "/pages/doorkeeper/index"
+        ));
+        items.add(buildTabBarItem(
+                "个人中心",
+                "/static/tabbar/my_select.png",
+                "/static/tabbar/my.png",
+                "/pages/doorkeeper/my"
+        ));
+        return items;
+    }
+
+    private List<LoginResVo1.TabBarItem> buildForkliftDriverTabBar() {
+        List<LoginResVo1.TabBarItem> items = new ArrayList<>();
+        items.add(buildTabBarItem(
+                "任务",
+                "/static/tabbar/task_select.png",
+                "/static/tabbar/task.png",
+                "/pages/forklift/index"
+        ));
+        items.add(buildTabBarItem(
+                "个人中心",
+                "/static/tabbar/my_select.png",
+                "/static/tabbar/my.png",
+                "/pages/forklift/my"
+        ));
+        return items;
+    }
+
+    private List<LoginResVo1.TabBarItem> buildDefaultDriverTabBar() {
+        List<LoginResVo1.TabBarItem> items = new ArrayList<>();
+        items.add(buildTabBarItem(
+                "任务",
+                "/static/tabbar/task_select.png",
+                "/static/tabbar/task.png",
+                "/pages/index/index"
+        ));
+        items.add(buildTabBarItem(
+                "管理",
+                "/static/tabbar/manage_select.png",
+                "/static/tabbar/manage.png",
+                "/pages/manage/index"
+        ));
+        return items;
+    }
+
+    private LoginResVo1.TabBarItem buildTabBarItem(String text, String iconPath, String notSelectedIconPath, String pagePath) {
+        LoginResVo1.TabBarItem item = new LoginResVo1.TabBarItem();
+        item.setText(text);
+        item.setIconPath(iconPath);
+        item.setNotSelectedIconPath(notSelectedIconPath);
+        item.setPagePath(pagePath);
+        item.setCount(0);
+        return item;
+    }
+
     static class AsyncProcess implements Runnable {
         private final LoginBase loginBase;
 

+ 2 - 0
sckw-modules-api/sckw-system-api/src/main/java/com/sckw/system/api/RemoteSystemService.java

@@ -308,4 +308,6 @@ public interface RemoteSystemService {
      * @param dto
      */
     Integer getActualDisPatch(ActualDisPatchDto dto);
+
+    KwsUserResDto queryByAccount(String account);
 }

+ 13 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/dubbo/RemoteSystemServiceImpl.java

@@ -26,6 +26,7 @@ import com.sckw.system.model.*;
 import com.sckw.system.model.vo.res.FindAreaTreeResVo;
 import com.sckw.system.model.vo.res.KwsUserResVo;
 import com.sckw.system.repository.KwsEntTypeRepository;
+import com.sckw.system.repository.KwsUserRepository;
 import com.sckw.system.service.KwsUserService;
 import com.sckw.system.service.SysAreaService;
 import jakarta.annotation.Resource;
@@ -63,6 +64,7 @@ public class RemoteSystemServiceImpl implements RemoteSystemService {
 
     private final KwsRoleDao kwsRoleDao;
     private final KwsEntTypeRepository kwsEntTypeRepository;
+    private final KwsUserRepository kwsUserRepository;
 
     /**
      * @param keys type#value,type#value
@@ -1085,6 +1087,17 @@ public class RemoteSystemServiceImpl implements RemoteSystemService {
         return actualVehicle;
     }
 
+    @Override
+    public KwsUserResDto queryByAccount(String account) {
+        KwsUser kwsUser = kwsUserRepository.queryByAccount( account);
+        if (kwsUser != null) {
+            KwsUserResDto kwsUserResDto = new KwsUserResDto();
+            BeanUtil.copyProperties(kwsUser, kwsUserResDto);
+            return kwsUserResDto;
+        }
+        return null;
+    }
+
     /**
      * 平台单趟耗时
      *

+ 8 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/repository/KwsUserRepository.java

@@ -24,4 +24,12 @@ public class KwsUserRepository extends ServiceImpl<KwsUserDao, KwsUser> {
                 .eq(BaseModel::getDelFlag,0)
                 .in(KwsUser::getId,userIds));
     }
+
+    public KwsUser queryByAccount(String account) {
+        return getOne(Wrappers.<KwsUser>lambdaQuery()
+                .eq(BaseModel::getDelFlag,0)
+                .eq(BaseModel::getStatus,0)
+                .eq(KwsUser::getAccount,account)
+                .last("limit 1"));
+    }
 }