Commit 9edf0a74 by guojuxing

应用菜单权限优化:根据菜单code获取对应的菜单

parent 7e95ee25
......@@ -350,4 +350,14 @@ public interface MenuApiService {
* @return com.gic.api.base.commons.ServiceResponse<java.util.Map<java.lang.String,java.lang.String>>


 */
ServiceResponse<Map<String, String>> getGicDefaultVersion();
/**
* 根据code查询,因为code唯一
* @Title: getMenuByMenuCode

* @Description:

* @author guojuxing
* @param menuCode

* @return com.gic.api.base.commons.ServiceResponse<com.gic.auth.dto.MenuDTO>


*/
ServiceResponse<MenuDTO> getMenuByMenuCode(String menuCode);
}
......@@ -179,6 +179,8 @@ public interface TabSysMenuMapper {

 */
int countByMenuCode(@Param("menuCode") String menuCode, @Param("menuId") Integer menuId);
TabSysMenu getMenuByMenuCode(String menuCode);
/**
* 批量更新子集的父级code数据,根据父级ID
* @Title: updateParentCodeByParentId

......
......@@ -158,6 +158,9 @@ public interface MenuService {

 */
boolean isRepeatMenuCode(String code, Integer menuId);
TabSysMenu getMenuByMenuCode(String menuCode);
/**
* 批量更新子集的父级code数据,根据父级ID
* @Title: updateParentCodeByParentId

......
......@@ -157,6 +157,11 @@ public class MenuServiceImpl implements MenuService {
}
@Override
public TabSysMenu getMenuByMenuCode(String menuCode) {
return tabSysMenuMapper.getMenuByMenuCode(menuCode);
}
@Override
public void updateParentCodeByParentId(Integer parentId, String parentCode) {
tabSysMenuMapper.updateParentCodeByParentId(parentId, parentCode);
}
......
......@@ -518,6 +518,15 @@ public class MenuApiServiceImpl implements MenuApiService {
return ServiceResponse.success(map);
}
@Override
public ServiceResponse<MenuDTO> getMenuByMenuCode(String menuCode) {
TabSysMenu record = menuService.getMenuByMenuCode(menuCode);
if (record == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "菜单code错误,无数据");
}
return ServiceResponse.success(EntityUtil.changeEntityNew(MenuDTO.class, record));
}
private ServiceResponse<Void> savePage(MenuDTO menuDTO, Class clazz) {
ServiceResponse paramsValid = ValidParamsUtils.allCheckValidate(menuDTO, clazz);
if (!paramsValid.isSuccess()) {
......
......@@ -491,6 +491,14 @@
</if>
</select>
<select id="getMenuByMenuCode" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from tab_sys_menu
where status = 1
and menu_code = #{menuCode}
limit 1
</select>
<update id="updateParentCodeByParentId">
update tab_sys_menu set parent_code = #{parentCode}
......
......@@ -9,6 +9,7 @@ import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.ano.IgnoreLogin;
import com.gic.enterprise.utils.UserDetail;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -69,9 +70,18 @@ public class MenuController {
* @return com.gic.commons.webapi.reponse.RestResponse


*/
@RequestMapping("login-user-menu-of-app")
public RestResponse loginUserMenu(Integer currentMenu, String appId) {
public RestResponse loginUserMenu(Integer currentMenu, String appId, String menuCode) {
LOGGER.info("查询登录用户的应用的菜单参数:{}-{}-{}", currentMenu, appId, menuCode);
Integer userId = UserDetailUtils.getUserDetail().getUserId();
Integer enterpriseId = UserDetailUtils.getUserDetail().getEnterpriseId();
if (StringUtils.isBlank(appId)) {
//根据menuCode去查询对应的appId
ServiceResponse<MenuDTO> menuDTOServiceResponse = menuApiService.getMenuByMenuCode(menuCode);
if (menuDTOServiceResponse.isSuccess()) {
MenuDTO tempDTO = menuDTOServiceResponse.getResult();
appId = tempDTO.getProject();
}
}
ServiceResponse<List<MenuDTO>> userMenu = this.menuApiService.getUserMenuOfApp(enterpriseId, userId,
currentMenu, appId);
if (userMenu.isSuccess()) {
......
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