Преглед изворни кода

fixed 后台菜单管理功能优化更新

fushengqian пре 4 месеци
родитељ
комит
9c6a4227e4

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/service/AccountService.java

@@ -76,7 +76,7 @@ public interface AccountService extends IService<TAccount> {
      * @param accountId 账户
      * @return 角色ID集合
      */
-    List<Long> getDutyIdsByAccountId(long accountId);
+    List<Integer> getDutyIdsByAccountId(Integer accountId);
 
     /**
      * 更新账户信息

+ 3 - 1
fuint-application/src/main/java/com/fuint/common/service/SourceService.java

@@ -80,8 +80,10 @@ public interface SourceService extends IService<TSource> {
      * 添加菜单
      *
      * @param tSource
+     * @param accountId
+     * @retur
      */
-    void addSource(TSource tSource);
+    void addSource(TSource tSource, Integer accountId);
 
     /**
      * 修改菜单

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/service/impl/AccountServiceImpl.java

@@ -288,7 +288,7 @@ public class AccountServiceImpl extends ServiceImpl<TAccountMapper, TAccount> im
      * @return 角色ID集合
      */
     @Override
-    public List<Long> getDutyIdsByAccountId(long accountId) {
+    public List<Integer> getDutyIdsByAccountId(Integer accountId) {
         return tAccountDutyMapper.getDutyIdsByAccountId(accountId);
     }
 

+ 1 - 2
fuint-application/src/main/java/com/fuint/common/service/impl/DutyServiceImpl.java

@@ -80,8 +80,7 @@ public class DutyServiceImpl extends ServiceImpl<TDutyMapper, TDuty> implements
      */
     @Override
     public TDuty getRoleById(Long roleId) {
-        TDuty htDuty = tDutyMapper.selectById(roleId);
-        return htDuty;
+        return tDutyMapper.selectById(roleId);
     }
 
     /**

+ 25 - 3
fuint-application/src/main/java/com/fuint/common/service/impl/SourceServiceImpl.java

@@ -3,11 +3,14 @@ package com.fuint.common.service.impl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fuint.common.domain.TreeSelect;
 import com.fuint.common.enums.StatusEnum;
+import com.fuint.common.service.AccountService;
 import com.fuint.common.service.SourceService;
 import com.fuint.common.vo.MetaVo;
 import com.fuint.common.vo.RouterVo;
 import com.fuint.framework.annoation.OperationServiceLog;
+import com.fuint.repository.mapper.TDutySourceMapper;
 import com.fuint.repository.mapper.TSourceMapper;
+import com.fuint.repository.model.TDutySource;
 import com.fuint.repository.model.TSource;
 import com.fuint.common.domain.TreeNode;
 import com.fuint.framework.exception.BusinessCheckException;
@@ -31,6 +34,13 @@ public class SourceServiceImpl extends ServiceImpl<TSourceMapper, TSource> imple
 
     private TSourceMapper tSourceMapper;
 
+    private TDutySourceMapper tDutySourceMapper;
+
+    /**
+     * 后台账户服务接口
+     */
+    private AccountService accountService;
+
     /**
      * 获取有效的菜单集合
      *
@@ -192,19 +202,31 @@ public class SourceServiceImpl extends ServiceImpl<TSourceMapper, TSource> imple
     }
 
     /**
-     * 添加菜单
+     * 新增后台菜单
      *
      * @param tSource
+     * @param accountId
+     * @return
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
     @OperationServiceLog(description = "新增后台菜单")
-    public void addSource(TSource tSource) {
+    public void addSource(TSource tSource, Integer accountId) {
         this.save(tSource);
+        // 赋访问权限
+        List<Integer> dutyIds = accountService.getDutyIdsByAccountId(accountId);
+        if (dutyIds != null && dutyIds.size() > 0) {
+            for (Integer dutyId : dutyIds) {
+                 TDutySource dutySource = new TDutySource();
+                 dutySource.setDutyId(dutyId);
+                 dutySource.setSourceId(tSource.getSourceId());
+                 tDutySourceMapper.insert(dutySource);
+            }
+        }
     }
 
     /**
-     * 修改菜单
+     * 修改后台菜单
      *
      * @param source
      */

+ 16 - 16
fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendSourceController.java

@@ -114,36 +114,36 @@ public class BackendSourceController extends BaseController {
         String sort = param.get("sort").toString();
         Integer isMenu = param.get("isMenu") == null ? 1 : Integer.parseInt(param.get("isMenu").toString());
 
-        TSource addSource = new TSource();
-        addSource.setSourceName(name);
-        addSource.setMerchantId(accountInfo.getMerchantId());
-        addSource.setStatus(status);
-        addSource.setNewIcon(icon);
-        addSource.setIsLog(1);
-        addSource.setPath(path);
-        addSource.setSourceStyle(sort);
-        addSource.setIsMenu(isMenu);
-        addSource.setSourceCode(path);
+        TSource tSource = new TSource();
+        tSource.setSourceName(name);
+        tSource.setMerchantId(accountInfo.getMerchantId());
+        tSource.setStatus(status);
+        tSource.setNewIcon(icon);
+        tSource.setIsLog(1);
+        tSource.setPath(path);
+        tSource.setSourceStyle(sort);
+        tSource.setIsMenu(isMenu);
+        tSource.setSourceCode(path);
 
         String eName = "";
         String[] paths = path.split("/");
         for (int i = 0; i < paths.length; i++) {
              eName = eName + CommonUtil.firstLetterToUpperCase(paths[i]);
         }
-        addSource.setEname(eName);
+        tSource.setEname(eName);
 
         if (StringUtil.isNotBlank(parentId)) {
             if (Integer.parseInt(parentId) > 0) {
                 TSource parentSource = sourceService.getById(parentId);
-                addSource.setParentId(parentSource.getSourceId());
-                addSource.setSourceLevel(parentSource.getSourceLevel() + 1);
+                tSource.setParentId(parentSource.getSourceId());
+                tSource.setSourceLevel(parentSource.getSourceLevel() + 1);
             } else {
-                addSource.setSourceLevel(1);
+                tSource.setSourceLevel(1);
             }
         } else {
-            addSource.setSourceLevel(1);
+            tSource.setSourceLevel(1);
         }
-        sourceService.addSource(addSource);
+        sourceService.addSource(tSource, accountInfo.getId());
         return getSuccessResult(true);
     }
 

+ 1 - 1
fuint-repository/src/main/java/com/fuint/repository/mapper/TAccountDutyMapper.java

@@ -13,7 +13,7 @@ import java.util.List;
  */
 public interface TAccountDutyMapper extends BaseMapper<TAccountDuty> {
 
-   List<Long> getDutyIdsByAccountId(long accountId);
+   List<Integer> getDutyIdsByAccountId(Integer accountId);
 
    void deleteDutiesByAccountId(long accountId);
 

+ 1 - 2
fuint-repository/src/main/java/com/fuint/repository/model/TDutySource.java

@@ -5,13 +5,12 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import java.io.Serializable;
 import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
 import lombok.Setter;
 
 /**
  * <p>
- * 
+ *
  * </p>
  *
  * Created by FSQ

+ 1 - 1
fuint-repository/src/main/resources/mapper/TAccountDutyMapper.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">
 <mapper namespace="com.fuint.repository.mapper.TAccountDutyMapper">
-    <select id="getDutyIdsByAccountId" resultType="java.lang.Long">
+    <select id="getDutyIdsByAccountId" resultType="java.lang.Integer">
         select distinct duty_id from t_account_duty t where t.acct_id = #{accountId}
     </select>