Commit 78ddee6c by java-李谡

油量分析权限验证

parent 61f6e755
......@@ -51,15 +51,27 @@
WHERE s.id=#{userCode} AND m.name like CONCAT('航线论证Web','%')
</select>
<select id="getParentRoles" resultType="com.ejweb.modules.role.entity.UserRolesEntity">
SELECT DISTINCT(p.id), p.permission,p.name AS menuName
<select id="getOilRole" resultType="java.lang.Integer">
SELECT
count( * )
FROM
sys_user2role ur
LEFT JOIN sys_role r ON r.id = ur.role_id
WHERE
r.enname = 'oil-analysis'
AND r.del_flag = 0
AND ur.user_id = #{userCode}
</select>
<select id="getParentRoles" resultType="com.ejweb.modules.role.entity.UserRolesEntity">
SELECT DISTINCT(p.id), p.permission,p.name AS menuName
FROM sys_user2role a
left JOIN sys_role s ON a.role_id=s.id
LEFT JOIN sys_menu2role t on s.id=t.role_id
LEFT JOIN sys_menu2role t on s.id=t.role_id
LEFT JOIN sys_menu p on p.id=t.menu_id
WHERE user_id = #{userCode}
<choose>
<choose>
<when test="permission != null and permission != ''">
AND p.permission=#{permission}
</when>
......
......@@ -23,14 +23,15 @@ public interface UserRolesDao extends BaseDao {
List<UserRolesEntity> getRootRoles(UserRolesBean bean);
List<InformationEntity> getInformation(UserRolesBean bean);
Integer getOilRole(UserRolesBean bean);
/**
*
* @author zhanglg
* @time 2016年10月3日
* @param bean
* @return
* @author zhanglg
* @time 2016年10月3日
*/
List<UserRolesEntity> getParentRoles(UserRolesBean bean);
// 获取用户权限列表
......
......@@ -6,15 +6,15 @@ import com.ejweb.modules.role.bean.UserRolesBean;
import com.ejweb.modules.role.dao.UserRolesDao;
import com.ejweb.modules.role.entity.InformationEntity;
import com.ejweb.modules.role.entity.UserRolesEntity;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* @author yuxg
* @author yuxg
* @version 1.0
* @time 2016-09-02
*/
......@@ -25,48 +25,57 @@ public class UserRolesService extends BaseService<UserRolesDao> {
return dao.getUserRoles(bean);
}
public List<UserRolesEntity> getRootRoles(UserRolesBean bean) {
return dao.getRootRoles( bean);
return dao.getRootRoles(bean);
}
public List<UserRolesEntity> getUserPermissionList(String userCode) {
UserRolesBean bean = new UserRolesBean();
bean.setUserCode(userCode);
return dao.getUserPermissionList( bean);
return dao.getUserPermissionList(bean);
}
public List<InformationEntity> getInformation(UserRolesBean bean){
return dao.getInformation( bean);
public List<InformationEntity> getInformation(UserRolesBean bean) {
return dao.getInformation(bean);
}
public boolean getOilRole(UserRolesBean bean) {
Integer roleCount = dao.getOilRole(bean);
return Objects.nonNull(roleCount);
}
public List<JSONObject> getList(String userCode,String p){
UserRolesBean bean=new UserRolesBean();
List<JSONObject> jsonlist=new ArrayList<JSONObject>();
public List<JSONObject> getList(String userCode, String p) {
UserRolesBean bean = new UserRolesBean();
List<JSONObject> jsonlist = new ArrayList<JSONObject>();
bean.setUserCode(userCode);
if(StringUtils.isNoneBlank(p)){
if (StringUtils.isNoneBlank(p)) {
bean.setPermission(p);
}
List<UserRolesEntity> list1= getParentRoles(bean);
for(UserRolesEntity entity1 :list1 ){
JSONObject json=new JSONObject();
json.put("name", entity1.getMenuName());
json.put("permission", entity1.getPermission());
getChildList(bean,json,entity1.getId());
jsonlist.add(json);
}
return jsonlist;
List<UserRolesEntity> list1 = getParentRoles(bean);
for (UserRolesEntity entity1 : list1) {
JSONObject json = new JSONObject();
json.put("name", entity1.getMenuName());
json.put("permission", entity1.getPermission());
getChildList(bean, json, entity1.getId());
jsonlist.add(json);
}
private JSONObject getChildList(UserRolesBean bean,JSONObject data,String id){
return jsonlist;
}
private JSONObject getChildList(UserRolesBean bean, JSONObject data, String id) {
bean.setId(id);
List<UserRolesEntity> list1= getUserRoles(bean);
if(list1.size()!=0){
List<JSONObject> jsonlist1=new ArrayList<JSONObject>();
for(UserRolesEntity entity1 :list1 ){
JSONObject json=new JSONObject();
List<UserRolesEntity> list1 = getUserRoles(bean);
if (list1.size() != 0) {
List<JSONObject> jsonlist1 = new ArrayList<JSONObject>();
for (UserRolesEntity entity1 : list1) {
JSONObject json = new JSONObject();
json.put("name", entity1.getMenuName());
json.put("permission", entity1.getPermission());
getChildList(bean,json,entity1.getId());
getChildList(bean, json, entity1.getId());
jsonlist1.add(json);
}
data.put("children", jsonlist1);
......@@ -75,13 +84,12 @@ public class UserRolesService extends BaseService<UserRolesDao> {
}
/**
*
* @author zhanglg
* @time 2016年10月3日
* @param bean
* @return
* @author zhanglg
* @time 2016年10月3日
*/
public List<UserRolesEntity> getParentRoles(UserRolesBean bean) {
// TODO Auto-generated method stub
return dao.getParentRoles(bean);
......
......@@ -350,12 +350,17 @@ public class UserController {
bean.setUserCode(userEntity.getId());
// 默认有航线论证权限(0表示有航线论证权限,1是没有)
userEntity.setVerify("0");
// 默认没有油量分析权限(0表示有油量分析权限,1是没有)
userEntity.setOil("1");
List<InformationEntity> informationEntity = userRolesService.getInformation(bean);
// 获取航线论证的部门信息
if (informationEntity == null || informationEntity.size() == 0) {
// 无航向论证权限
userEntity.setVerify("1");
}
if (userRolesService.getOilRole(bean)) {
userEntity.setOil("0");
}
userEntity.setShowPhone(userEntity.getPhone());
userEntity.setPhone(Util.formatedWorkPhone(userEntity.getPhone()));
responseBean.setData(userEntity);
......
......@@ -14,6 +14,7 @@ public class LoginUserEntity extends BaseEntity {
@JSONField(serialize=false)
private String officeId; // 归属ID
private String verify;
private String oil = "1";
private String officeName; // 归属部门
private String officeFullName; // 归属部门
@JSONField(serialize = false)
......@@ -281,14 +282,24 @@ public class LoginUserEntity extends BaseEntity {
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform;
}
public String getDeviceToken() {
return deviceToken;
}
public void setDeviceToken(String deviceToken) {
this.deviceToken = deviceToken;
}
public String getOil() {
return oil;
}
public void setOil(String oil) {
this.oil = oil;
}
}
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