Commit 55f92ef4 by guojuxing

商品资源权限控制

parent 02c3708b
......@@ -43,12 +43,13 @@ public interface MenuApiService {
/**
* 获取登陆用户的菜单(页面)
* @param enterpriseId
* @param userId
* @param currentMenu
* @param versionCode 商户服务订购的版本
* @return
*/
ServiceResponse<List<MenuDTO>> getUserMenuOfGic(Integer userId, Integer currentMenu, String versionCode);
ServiceResponse<List<MenuDTO>> getUserMenuOfGic(Integer enterpriseId, Integer userId, Integer currentMenu, String versionCode);
/**
* 根据用户ID查询没拥有的gic操作项
......
......@@ -56,4 +56,6 @@ public interface TabSysBusinessFrontResMapper {
List<TabSysBusinessFrontRes> listByParam(@Param("search") String search,
@Param("resourceType") Integer resourceType);
List<TabSysBusinessFrontRes> listByCode(@Param("code") String code, @Param("resourceType") Integer resourceType);
}
\ No newline at end of file
......@@ -14,5 +14,13 @@ public interface BusinessFrontResService {
List<TabSysBusinessFrontRes> listByParam(String search, Integer resourceType);
/**
* 根据code查询页面
* @param code
* @param resourceType
* @return
*/
List<TabSysBusinessFrontRes> listByCode(String code, Integer resourceType);
TabSysBusinessFrontRes getByResourceId(Integer resourceId);
}
......@@ -48,6 +48,11 @@ public class BusinessFrontResServiceImpl implements BusinessFrontResService{
}
@Override
public List<TabSysBusinessFrontRes> listByCode(String code, Integer resourceType) {
return tabSysBusinessFrontResMapper.listByCode(code, resourceType);
}
@Override
public TabSysBusinessFrontRes getByResourceId(Integer resourceId) {
return tabSysBusinessFrontResMapper.selectByPrimaryKey(resourceId);
}
......
......@@ -2,6 +2,8 @@ package com.gic.auth.service.outer.impl;
import java.util.*;
import com.gic.auth.entity.TabSysBusinessFrontRes;
import com.gic.enterprise.dto.EnterpriseDTO;
import com.gic.enterprise.service.EnterpriseApiService;
import com.gic.open.api.dto.*;
import com.gic.open.api.service.ServeApiService;
......@@ -55,6 +57,8 @@ public class MenuApiServiceImpl implements MenuApiService {
private ServeApiService serveApiService;
@Autowired
private EnterpriseApiService enterpriseApiService;
@Autowired
private BusinessFrontResService businessFrontResService;
@Override
public ServiceResponse<List<MenuDTO>> listByMenuIdList(List<Integer> menuIdList) {
......@@ -101,8 +105,8 @@ public class MenuApiServiceImpl implements MenuApiService {
}
@Override
public ServiceResponse<List<MenuDTO>> getUserMenuOfGic(Integer userId, Integer currentMenu, String versionCode) {
return getUserLoginMenu(userId, currentMenu, true, versionCode);
public ServiceResponse<List<MenuDTO>> getUserMenuOfGic(Integer enterpriseId, Integer userId, Integer currentMenu, String versionCode) {
return getUserLoginMenu(enterpriseId, userId, currentMenu, true, versionCode);
}
@Override
......@@ -118,7 +122,7 @@ public class MenuApiServiceImpl implements MenuApiService {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "没有超级管理员,数据错误");
}
String versionCode = enterpriseApiService.getEnterpriseById(enterpriseId).getResult().getVersionCode();
return this.getUserMenuOfGic(tabSysUser.getUserId(), null, versionCode);
return this.getUserMenuOfGic(enterpriseId, tabSysUser.getUserId(), null, versionCode);
}
@Override
......@@ -848,12 +852,13 @@ public class MenuApiServiceImpl implements MenuApiService {
* @Title: getUserLoginMenu

* @Description:

 * @author guojuxing
* @param enterpriseId
* @param userId
* @param currentMenu
* @param isGic
 是否是gic项目
* @return com.gic.api.base.commons.ServiceResponse<java.util.List<com.gic.auth.dto.MenuDTO>>


 */
private ServiceResponse<List<MenuDTO>> getUserLoginMenu(Integer userId, Integer currentMenu, boolean isGic,
private ServiceResponse<List<MenuDTO>> getUserLoginMenu(Integer enterpriseId, Integer userId, Integer currentMenu, boolean isGic,
String versionCode) {
TabSysUser tabSysUser = userService.getUserById(userId);
if (tabSysUser == null) {
......@@ -903,7 +908,34 @@ public class MenuApiServiceImpl implements MenuApiService {
parentId = currentMenu;
level = menu.getLevel() + 1;
}
return ServiceResponse.success(this.treeMenu(resultList, level, parentId));
Map<String, Object> resourcePage = new HashMap<>(16);
//过滤商品资源页面
ServiceResponse<EnterpriseDTO> enterpriseResult = enterpriseApiService.getEnterpriseById(enterpriseId);
if (enterpriseResult.isSuccess()) {
Integer goodsResource = enterpriseResult.getResult().getGoodsResource();
if (goodsResource == null || goodsResource.intValue() != 1) {
//如果没有开启商品资源开关,需要过滤一些菜单
//查询配置页面
List<TabSysBusinessFrontRes> resourceList = businessFrontResService.listByParam(null, 1);
if (CollectionUtils.isNotEmpty(resourceList)) {
for (TabSysBusinessFrontRes resource : resourceList) {
resourcePage.put(resource.getResourceCode(), 1);
}
}
}
}
List<TabSysMenu> tempList = new ArrayList<>();
for (TabSysMenu menu : resultList) {
if (resourcePage.containsKey(menu.getMenuCode())) {
//如果包含了,则过滤掉
continue;
}
tempList.add(menu);
}
return ServiceResponse.success(this.treeMenu(tempList, level, parentId));
}
/**
......
......@@ -163,4 +163,12 @@
and resource_type = #{resourceType}
</if>
</select>
<select id="listByCode" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from tab_sys_business_front_res
where status = 1
and resource_type = #{resourceType}
and resource_code = #{code}
</select>
</mapper>
\ No newline at end of file
......@@ -35,7 +35,8 @@ public class MenuController {
@RequestMapping("login-user-menu")
public RestResponse loginUserMenu(Integer currentMenu) {
Integer userId = UserDetailUtils.getUserDetail().getUserId();
ServiceResponse<List<MenuDTO>> userMenu = this.menuApiService.getUserMenuOfGic(userId, currentMenu,
Integer enterpriseId = UserDetailUtils.getUserDetail().getEnterpriseId();
ServiceResponse<List<MenuDTO>> userMenu = this.menuApiService.getUserMenuOfGic(enterpriseId, userId, currentMenu,
UserDetailUtils.getUserDetail().getEnterpriseInfo().getVersionCode());
if (userMenu.isSuccess()) {
return RestResponse.success(userMenu.getResult());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment