From 28215e381131b0919567ec5c3f236b29ebd3ad5c Mon Sep 17 00:00:00 2001
From: ZhuDongming <773644075@qq.com>
Date: Tue, 22 Oct 2019 16:02:18 +0800
Subject: [PATCH] update
---
src/main/java/com/moral/controller/RoleController.java | 10 -
src/main/java/com/moral/service/impl/AccountServiceImpl.java | 82 +++++++++++++
src/main/java/com/moral/service/impl/RoleServiceImpl.java | 1
src/main/resources/mapper/RoleMapper.xml | 20 --
src/main/resources/mapper/AccountMapper.xml | 132 ++++++++++++++++++---
src/main/java/com/moral/controller/AccountController.java | 1
src/main/java/com/moral/mapper/AccountMapper.java | 10 +
src/main/java/com/moral/security/auth/login/LoginAuthenticationProvider.java | 10 +
src/main/java/com/moral/security/endpoint/RefreshTokenEndpoint.java | 10 +
src/main/java/com/moral/entity/Role.java | 6 -
src/main/resources/mapper/MenuMapper.xml | 3
src/main/java/com/moral/service/impl/MenuServiceImpl.java | 4
src/main/java/com/moral/controller/MenuController.java | 12 ++
src/main/java/com/moral/service/AccountService.java | 5
14 files changed, 240 insertions(+), 66 deletions(-)
diff --git a/src/main/java/com/moral/controller/AccountController.java b/src/main/java/com/moral/controller/AccountController.java
index 3799f3d..5d6424e 100644
--- a/src/main/java/com/moral/controller/AccountController.java
+++ b/src/main/java/com/moral/controller/AccountController.java
@@ -51,4 +51,5 @@
Integer result = accountService.getAccountCountByAccountName(accountName);
return new ResultBean<Integer>(result);
}
+
}
diff --git a/src/main/java/com/moral/controller/MenuController.java b/src/main/java/com/moral/controller/MenuController.java
index 4e32495..b15b7fa 100644
--- a/src/main/java/com/moral/controller/MenuController.java
+++ b/src/main/java/com/moral/controller/MenuController.java
@@ -1,5 +1,7 @@
package com.moral.controller;
+import java.util.Map;
+
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.CrossOrigin;
@@ -12,6 +14,7 @@
import com.moral.common.bean.PageBean;
import com.moral.common.bean.ResultBean;
import com.moral.entity.Menu;
+import com.moral.service.AccountService;
import com.moral.service.ChannelService;
import com.moral.service.MenuService;
@@ -24,6 +27,9 @@
@Resource
ChannelService channelService;
+
+ @Resource
+ AccountService accountService;
@GetMapping("count-by-example")
public ResultBean<Integer> countByExample(PageBean pageBean) {
@@ -67,4 +73,10 @@
ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
return resultBean;
}
+
+ @GetMapping("menu-by-account")
+ public Map<String,Object> getMenuListsByAccountName(String accountName) {
+ Map<String,Object> mapResult = accountService.getMenuListsByAccountName(accountName);
+ return mapResult;
+ }
}
diff --git a/src/main/java/com/moral/controller/RoleController.java b/src/main/java/com/moral/controller/RoleController.java
index 893fed6..1d5c462 100644
--- a/src/main/java/com/moral/controller/RoleController.java
+++ b/src/main/java/com/moral/controller/RoleController.java
@@ -22,9 +22,6 @@
@Autowired
RoleService roleService;
- @Autowired
- ChannelService channelService;
-
@GetMapping("count-by-example")
public ResultBean<Integer> countByExample(PageBean pageBean){
return new ResultBean<Integer>(roleService.countByExample(pageBean));
@@ -33,13 +30,6 @@
@GetMapping("role-list")
public PageBean getRoleList(PageBean pageBean) {
return roleService.getRoleList(pageBean);
- }
-
- @GetMapping("channel-list")
- public ResultBean getChannelList(String channelName) {
- ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
- resultBean.setData(channelService.getChannelList(channelName));
- return resultBean;
}
@PostMapping("add-or-modify")
diff --git a/src/main/java/com/moral/entity/Role.java b/src/main/java/com/moral/entity/Role.java
index 76bcfe5..7ba2ef6 100644
--- a/src/main/java/com/moral/entity/Role.java
+++ b/src/main/java/com/moral/entity/Role.java
@@ -3,7 +3,6 @@
import java.util.Date;
import javax.persistence.Id;
-import javax.persistence.Transient;
import lombok.Data;
@@ -16,8 +15,6 @@
private String roleName;
- private Integer channelId;
-
private String isDelete;
private String roleRemark;
@@ -29,8 +26,5 @@
private Date updateTime;
private String updateUser;
-
- @Transient
- private Channel channel;
}
diff --git a/src/main/java/com/moral/mapper/AccountMapper.java b/src/main/java/com/moral/mapper/AccountMapper.java
index 9a85a32..bdd0b89 100644
--- a/src/main/java/com/moral/mapper/AccountMapper.java
+++ b/src/main/java/com/moral/mapper/AccountMapper.java
@@ -7,6 +7,8 @@
import com.moral.common.mapper.BaseMapper;
import com.moral.entity.Account;
+import com.moral.entity.Menu;
+import com.moral.entity.Role;
public interface AccountMapper extends BaseMapper<Account> {
@@ -18,4 +20,12 @@
List<Account> getAccountList(@Param("accountName") String accountName);
+ List<Role> getRolesByAccountName(@Param("accountName") String accountName);
+
+ List<Menu> getParentMenuListsByAccountName(@Param("accountName") String accountName);
+
+ String getEmailByAccountName(@Param("accountName") String accountName);
+
+ List<Menu> getChildMenuIdsByAccountName(@Param("accountName") String accountName, @Param("id") Integer id);
+
}
\ No newline at end of file
diff --git a/src/main/java/com/moral/security/auth/login/LoginAuthenticationProvider.java b/src/main/java/com/moral/security/auth/login/LoginAuthenticationProvider.java
index 4047ded..999813a 100644
--- a/src/main/java/com/moral/security/auth/login/LoginAuthenticationProvider.java
+++ b/src/main/java/com/moral/security/auth/login/LoginAuthenticationProvider.java
@@ -1,9 +1,11 @@
package com.moral.security.auth.login;
import com.moral.entity.Account;
+import com.moral.entity.Role;
import com.moral.security.exceptions.AccountExpiredBadCredentialsException;
import com.moral.security.model.UserContext;
import com.moral.service.AccountService;
+
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationProvider;
import org.springframework.security.authentication.BadCredentialsException;
@@ -17,6 +19,7 @@
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
+import org.springframework.util.CollectionUtils;
import java.util.Date;
import java.util.List;
@@ -54,6 +57,7 @@
String password = (String) authentication.getCredentials();
LoginMode mode = (LoginMode) authentication.getDetails();
Account account = accountService.queryAccountByName(accountName).orElseThrow(() -> new UsernameNotFoundException("User not found: " + accountName));
+ List<Role> roleList = accountService.getRolesByAccountName(accountName);
Date expireTime = Optional.ofNullable(account.getExpireTime())
.orElseThrow(
()-> new AccountExpiredBadCredentialsException("Authentication Failed. Account has expired.")
@@ -66,10 +70,10 @@
throw new BadCredentialsException("Authentication Failed. Username or Password not valid.");
}
- if (account.getRoles() == null) {
- throw new InsufficientAuthenticationException("User has no roles assigned");
+ if (CollectionUtils.isEmpty(roleList)) {
+ throw new InsufficientAuthenticationException("Authentication Failed. User has no roles assigned");
}
- List<GrantedAuthority> authorities = account.getRoles().stream()
+ List<GrantedAuthority> authorities = roleList.stream()
.map(authority -> new SimpleGrantedAuthority(authority.getRoleName()))
.collect(Collectors.toList());
diff --git a/src/main/java/com/moral/security/endpoint/RefreshTokenEndpoint.java b/src/main/java/com/moral/security/endpoint/RefreshTokenEndpoint.java
index 1cf15d2..7a1be18 100644
--- a/src/main/java/com/moral/security/endpoint/RefreshTokenEndpoint.java
+++ b/src/main/java/com/moral/security/endpoint/RefreshTokenEndpoint.java
@@ -1,7 +1,7 @@
package com.moral.security.endpoint;
import com.moral.entity.Account;
-import com.moral.security.auth.JwtAuthenticationToken;
+import com.moral.entity.Role;
import com.moral.security.auth.login.LoginMode;
import com.moral.security.model.token.JwtTokenFactory;
import com.moral.security.auth.jwt.extractor.TokenExtractor;
@@ -14,6 +14,8 @@
import com.moral.security.model.token.RawAccessJwtToken;
import com.moral.security.model.token.RefreshToken;
import com.moral.service.AccountService;
+
+import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.MediaType;
@@ -69,9 +71,9 @@
// ���refresh token��� ������������������
LoginMode mode = LoginMode.valueOf(refreshToken.getClaims().getBody().get("mode").toString());
Account account = accountService.queryAccountByName(subject).orElseThrow(() -> new UsernameNotFoundException("User not found: " + subject));
-
- if (account.getRoles() == null) throw new InsufficientAuthenticationException("User has no roles assigned");
- List<GrantedAuthority> authorities = account.getRoles().stream()
+ List<Role> roleList = accountService.getRolesByAccountName(account.getAccountName());
+ if (CollectionUtils.isEmpty(roleList)) throw new InsufficientAuthenticationException("User has no roles assigned");
+ List<GrantedAuthority> authorities = roleList.stream()
.map(authority -> new SimpleGrantedAuthority(authority.getRoleName()))
.collect(Collectors.toList());
diff --git a/src/main/java/com/moral/service/AccountService.java b/src/main/java/com/moral/service/AccountService.java
index dcc1fe2..7c94cc8 100644
--- a/src/main/java/com/moral/service/AccountService.java
+++ b/src/main/java/com/moral/service/AccountService.java
@@ -6,6 +6,7 @@
import com.moral.common.bean.PageBean;
import com.moral.entity.Account;
+import com.moral.entity.Role;
public interface AccountService {
@@ -32,4 +33,8 @@
Map<String, Object> getOrganizationIdByAccountId(String id);
List<Account> getAccountList(String accountName);
+
+ List<Role> getRolesByAccountName(String accountName);
+
+ Map<String, Object> getMenuListsByAccountName(String accountName);
}
diff --git a/src/main/java/com/moral/service/impl/AccountServiceImpl.java b/src/main/java/com/moral/service/impl/AccountServiceImpl.java
index 261adc9..8a842b9 100644
--- a/src/main/java/com/moral/service/impl/AccountServiceImpl.java
+++ b/src/main/java/com/moral/service/impl/AccountServiceImpl.java
@@ -1,12 +1,20 @@
package com.moral.service.impl;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+
import static com.moral.common.bean.Constants.IS_DELETE_FALSE;
import static com.moral.common.bean.Constants.IS_DELETE_TRUE;
import static com.moral.common.util.ResourceUtil.getValue;
import static org.apache.commons.lang3.StringUtils.isNumeric;
import static org.springframework.util.ObjectUtils.isEmpty;
-
-import java.util.*;
import javax.annotation.Resource;
@@ -14,18 +22,21 @@
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import com.github.pagehelper.PageHelper;
import com.moral.common.bean.Constants;
import com.moral.common.bean.PageBean;
import com.moral.common.exception.BusinessException;
-import com.moral.common.util.Crypto;
import com.moral.common.util.ResourceUtil;
import com.moral.common.util.ValidateUtil;
import com.moral.entity.Account;
+import com.moral.entity.Menu;
import com.moral.entity.Organization;
+import com.moral.entity.Role;
import com.moral.mapper.AccountMapper;
+import com.moral.mapper.MenuMapper;
import com.moral.mapper.OrganizationMapper;
import com.moral.service.AccountService;
import com.moral.service.OrganizationService;
@@ -37,6 +48,7 @@
public class AccountServiceImpl implements AccountService {
@Resource
private BCryptPasswordEncoder encoder;
+
@Resource
private AccountMapper accountMapper;
@@ -212,4 +224,68 @@
List<Account> accountList = accountMapper.getAccountList(accountName);
return accountList;
}
+
+ @Override
+ public List<Role> getRolesByAccountName(String accountName) {
+ List<Role> roleList = accountMapper.getRolesByAccountName(accountName);
+ return roleList;
+ }
+
+ @Override
+ public Map<String, Object> getMenuListsByAccountName(String accountName) {
+ List<Menu> menuList=accountMapper.getParentMenuListsByAccountName(accountName);
+ String email=accountMapper.getEmailByAccountName(accountName);
+ Map<String,Object> mapList=new LinkedHashMap<>();
+ Map<String,Object> appMap=new LinkedHashMap<>();
+ appMap.put("name","������������������������");
+ appMap.put("description","������������������������������������������");
+ mapList.put("app",appMap);
+ Map<String,Object> userMap=new LinkedHashMap<>();
+ userMap.put("name",accountName);
+ userMap.put("avatar","./assets/img/zorro.svg");
+ userMap.put("email",email);
+ mapList.put("user",userMap);
+ Map<String,Object> navigationMap=new LinkedHashMap<>();
+ Map<String,Object> navigationChildMap=new LinkedHashMap<>();
+ navigationChildMap.put("text","���������");
+ navigationChildMap.put("link", "/dashboard/workplace");
+ navigationChildMap.put("icon","icon-speedometer");
+ navigationChildMap.put("translate","dashboard_workplace");
+ List<Map> navigationChildList=new ArrayList<>();
+ navigationChildList.add(navigationChildMap);
+ navigationMap.put("text","���������");
+ navigationMap.put("translate","main_navigation");
+ navigationMap.put("group",true);
+ navigationMap.put("children",navigationChildList);
+ Map<String,Object> systemMap=new LinkedHashMap<>();
+ systemMap.put("text","������������");
+ systemMap.put("group",true);
+ List<Map> systemList=new ArrayList<>();
+ if(!CollectionUtils.isEmpty(menuList)){
+ for(Menu m:menuList){
+ Map<String,Object> systemChildMap=new LinkedHashMap<>();
+ systemChildMap.put("text",m.getMenuName());
+ systemChildMap.put("icon",m.getMenuIcon());
+ List<Menu> childMenuLists=accountMapper.getChildMenuIdsByAccountName(accountName,m.getId());
+ List<Map> systemSonList=new ArrayList<>();
+ if(!CollectionUtils.isEmpty(childMenuLists)){
+ for(Menu childMenu:childMenuLists){
+ Map<String,Object> systemSonMap=new LinkedHashMap<>();
+ systemSonMap.put("text",childMenu.getMenuName());
+ systemSonMap.put("link",childMenu.getMenuUrl());
+ systemSonList.add(systemSonMap);
+ }
+ }
+ systemChildMap.put("children",systemSonList);
+ systemList.add(systemChildMap);
+ }
+ }
+ systemMap.put("children",systemList);
+ List<Map> list=new ArrayList<>();
+ list.add(navigationMap);
+ list.add(systemMap);
+ mapList.put("menu",list);
+ return mapList;
+ }
+
}
diff --git a/src/main/java/com/moral/service/impl/MenuServiceImpl.java b/src/main/java/com/moral/service/impl/MenuServiceImpl.java
index 3db3a07..0c5da0c 100644
--- a/src/main/java/com/moral/service/impl/MenuServiceImpl.java
+++ b/src/main/java/com/moral/service/impl/MenuServiceImpl.java
@@ -34,6 +34,9 @@
@Transactional
public void addOrModify(Menu menu) {
try {
+ if(menu.getMenuParentId()==null){
+ menu.setMenuParentId(0);
+ }
menu.setUpdateTime(new Date());
menu.setUpdateUser(menu.getUpdateUser());
if (menu.getId() != null) {
@@ -47,7 +50,6 @@
menu.setId(menuResult.getId());
menuMapper.updateByPrimaryKeySelective(menu);
} else {
- System.out.println("channelId:"+menu.getChannelId());
menu.setChannelId(menu.getChannelId());
menu.setIsDelete(Constants.IS_DELETE_FALSE);
menu.setCreateTime(new Date());
diff --git a/src/main/java/com/moral/service/impl/RoleServiceImpl.java b/src/main/java/com/moral/service/impl/RoleServiceImpl.java
index 9cf3716..27ed222 100644
--- a/src/main/java/com/moral/service/impl/RoleServiceImpl.java
+++ b/src/main/java/com/moral/service/impl/RoleServiceImpl.java
@@ -42,7 +42,6 @@
roleQuery.setIsDelete(Constants.IS_DELETE_FALSE);
Role roleResult = roleMapper.selectOne(roleQuery);
if (roleResult == null) {
- role.setChannelId(role.getChannelId());
role.setIsDelete(Constants.IS_DELETE_FALSE);
role.setCreateTime(new Date());
role.setCreateUser(role.getCreateUser());
diff --git a/src/main/resources/mapper/AccountMapper.xml b/src/main/resources/mapper/AccountMapper.xml
index c7c2903..a7e353d 100644
--- a/src/main/resources/mapper/AccountMapper.xml
+++ b/src/main/resources/mapper/AccountMapper.xml
@@ -1,35 +1,56 @@
<?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.moral.mapper.AccountMapper">
- <resultMap id="BaseResultMap" type="com.moral.entity.Account">
- <id column="id" jdbcType="INTEGER" property="id" />
- <result column="account_name" jdbcType="VARCHAR" property="accountName" />
- <result column="password" jdbcType="VARCHAR" property="password" />
- <result column="organization_id" jdbcType="INTEGER" property="organizationId" />
- <result column="email" jdbcType="VARCHAR" property="email" />
- <result column="mobile" jdbcType="VARCHAR" property="mobile" />
- <result column="weixin" jdbcType="VARCHAR" property="weixin" />
- <result column="is_delete" jdbcType="CHAR" property="isDelete" />
- <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
- <result column="expire_time" jdbcType="TIMESTAMP" property="expireTime" />
- <result column="user_name" jdbcType="VARCHAR" property="userName" />
- <association property="jwtTokenVersion" javaType="com.moral.entity.JwtTokenVersion">
- <result column="jwt_token_version_id" property="id" jdbcType="INTEGER" />
- <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
- </association>
- </resultMap>
- <sql id="Base_Column_List">
+ <resultMap id="BaseResultMap" type="com.moral.entity.Account">
+ <id column="id" jdbcType="INTEGER" property="id"/>
+ <result column="account_name" jdbcType="VARCHAR" property="accountName"/>
+ <result column="password" jdbcType="VARCHAR" property="password"/>
+ <result column="organization_id" jdbcType="INTEGER" property="organizationId"/>
+ <result column="email" jdbcType="VARCHAR" property="email"/>
+ <result column="mobile" jdbcType="VARCHAR" property="mobile"/>
+ <result column="weixin" jdbcType="VARCHAR" property="weixin"/>
+ <result column="is_delete" jdbcType="CHAR" property="isDelete"/>
+ <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+ <result column="expire_time" jdbcType="TIMESTAMP" property="expireTime"/>
+ <result column="user_name" jdbcType="VARCHAR" property="userName"/>
+ <association property="jwtTokenVersion" javaType="com.moral.entity.JwtTokenVersion">
+ <result column="jwt_token_version_id" property="id" jdbcType="INTEGER"/>
+ <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
+ </association>
+ </resultMap>
+
+ <resultMap id="RoleResultMap" type="com.moral.entity.Role">
+ <id column="id" property="id" jdbcType="INTEGER"/>
+ <result column="role_code" property="roleCode" jdbcType="VARCHAR"/>
+ <result column="role_name" property="roleName" jdbcType="VARCHAR"/>
+ <result column="is_delete" property="isDelete" jdbcType="CHAR"/>
+ <result column="role_remark" property="roleRemark" jdbcType="VARCHAR"/>
+ <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
+ <result column="create_user" property="createUser" jdbcType="VARCHAR"/>
+ <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
+ <result column="update_user" property="updateUser" jdbcType="VARCHAR"/>
+ </resultMap>
+
+ <resultMap id="MenuResultMap" type="com.moral.entity.Menu">
+ <id column="id" property="id" jdbcType="INTEGER"/>
+ <result column="menu_name" property="menuName" jdbcType="VARCHAR"/>
+ <result column="menu_icon" property="menuIcon" jdbcType="VARCHAR"/>
+ <result column="menu_url" property="menuUrl" jdbcType="VARCHAR"/>
+ <result column="menu_parent_id" property="menuParentId" jdbcType="INTEGER"/>
+ </resultMap>
+
+ <sql id="Base_Column_List">
id, account_name, password, organization_id, email, mobile, weixin, is_delete, create_time,
expire_time, user_name
</sql>
- <select id="getByAccountName" parameterType="java.lang.String" resultMap="BaseResultMap">
+ <select id="getByAccountName" parameterType="java.lang.String" resultMap="BaseResultMap">
select
acc.*,jtv.id as jwt_token_version_id,jtv.update_time as update_time
from account acc
left join jwt_token_version jtv on acc.account_name = jtv.account_name
where acc.account_name = #{name,jdbcType=VARCHAR}
</select>
- <select id="getRoleNameByAccountId" resultType="java.util.Map">
+ <select id="getRoleNameByAccountId" resultType="java.util.Map">
SELECT
r.role_name
FROM
@@ -39,8 +60,8 @@
ar.role_id = r.id
AND ar.account_id = #{accountId}
</select>
-
- <select id="getOrganizationIdByAccountId" resultType="java.util.Map">
+
+ <select id="getOrganizationIdByAccountId" resultType="java.util.Map">
SELECT organization_id
FROM account
WHERE id=#{id}
@@ -55,4 +76,71 @@
and account_name like concat('%',#{accountName},'%')
</if>
</select>
+
+ <select id="getRolesByAccountName" resultMap="RoleResultMap" parameterType="java.lang.String">
+ select
+ r.*
+ from
+ role r
+ right join account_role ar on ar.role_id = r.id
+ right join account a on a.id = ar.account_id
+ where
+ a.account_name = #{accountName} and r.id is not null
+ </select>
+
+ <select id="getParentMenuListsByAccountName" resultMap="MenuResultMap" parameterType="java.lang.String">
+ select
+ DISTINCT
+ m.id,m.menu_name,m.menu_icon,m.menu_url,m.menu_order,m.menu_parent_id
+ from
+ menu m
+ right join role_menu rm on rm.channel_id = m.channel_id and rm.menu_id=m.id and m.channel_id=2
+ right join role on rm.role_id in
+ (
+ select
+ r.id
+ from
+ role r
+ right join
+ account_role ar on ar.role_id = r.id
+ right join
+ account a on a.id = ar.account_id
+ where
+ a.account_name = #{accountName} and r.is_delete=0 and r.id is not null
+ )
+ where m.menu_parent_id=0
+ order by m.menu_order
+ </select>
+
+ <select id="getChildMenuIdsByAccountName" resultMap="MenuResultMap">
+ select
+ DISTINCT
+ m.id,m.menu_name,m.menu_icon,m.menu_url,m.menu_order,m.menu_parent_id
+ from
+ menu m
+ right join role_menu rm on rm.channel_id = m.channel_id and rm.menu_id=m.id and m.channel_id=2
+ right join role on rm.role_id in
+ (
+ select
+ r.id
+ from
+ role r
+ right join
+ account_role ar on ar.role_id = r.id
+ right join
+ account a on a.id = ar.account_id
+ where
+ a.account_name = #{accountName} and r.is_delete=0 and r.id is not null
+ )
+ where m.menu_parent_id = #{id}
+ order by m.menu_order
+ </select>
+
+ <select id="getEmailByAccountName" resultType="java.lang.String">
+ select
+ email
+ from account
+ where account_name = #{accountName}
+ </select>
+
</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/MenuMapper.xml b/src/main/resources/mapper/MenuMapper.xml
index fdffd4c..d9e91d8 100644
--- a/src/main/resources/mapper/MenuMapper.xml
+++ b/src/main/resources/mapper/MenuMapper.xml
@@ -104,7 +104,7 @@
from menu
where id IN
(select distinct(menu_parent_Id) from menu
- where menu_parent_Id is not null)
+ where menu_parent_Id <![CDATA[ <> ]]> 0)
<if test="menuName != 'null'">
and menu_name like concat('%',#{menuName},'%')
</if>
@@ -119,4 +119,5 @@
and menu_name like concat('%',#{menuName},'%')
</if>
</select>
+
</mapper>
\ No newline at end of file
diff --git a/src/main/resources/mapper/RoleMapper.xml b/src/main/resources/mapper/RoleMapper.xml
index 95334fb..965ff3e 100644
--- a/src/main/resources/mapper/RoleMapper.xml
+++ b/src/main/resources/mapper/RoleMapper.xml
@@ -2,11 +2,10 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.moral.mapper.RoleMapper">
- <resultMap id="ResultMap" type="com.moral.entity.Role">
+ <resultMap id="BaseResultMap" type="com.moral.entity.Role">
<id column="id" property="id" jdbcType="INTEGER" />
<result column="role_code" property="roleCode" jdbcType="VARCHAR" />
<result column="role_name" property="roleName" jdbcType="VARCHAR" />
- <result column="channel_id" property="channelId" jdbcType="INTEGER" />
<result column="is_delete" property="isDelete" jdbcType="CHAR" />
<result column="role_remark" property="roleRemark" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
@@ -15,15 +14,8 @@
<result column="update_user" property="updateUser" jdbcType="VARCHAR" />
</resultMap>
- <resultMap id="BaseResultMap" type="com.moral.entity.Role" extends="ResultMap">
- <association property="channel" javaType="com.moral.entity.Channel">
- <result column="channel_id" jdbcType="INTEGER" property="id" />
- <result column="channel_name" jdbcType="VARCHAR" property="channelName" />
- </association>
- </resultMap>
-
<sql id="Base_Column_List" >
- id, role_code, role_name, channel_id, is_delete, role_remark, create_time, create_user,
+ id, role_code, role_name, is_delete, role_remark, create_time, create_user,
update_time, update_user
</sql>
@@ -57,7 +49,7 @@
</where>
</sql>
- <select id="getRoleListByName" resultMap="ResultMap">
+ <select id="getRoleListByName" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from role
@@ -69,10 +61,8 @@
<select id="getRoleList" resultMap="BaseResultMap">
select
- r.*,
- c.channel_name
- from role r
- left join channel c on r.channel_id = c.id
+ <include refid="Base_Column_List"/>
+ from role
<if test="_parameter != null" >
<include refid="Example_Where_Clause" />
</if>
--
Gitblit v1.8.0