Commit 78ddee6c by java-李谡

油量分析权限验证

parent 61f6e755
...@@ -52,6 +52,18 @@ ...@@ -52,6 +52,18 @@
</select> </select>
<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 id="getParentRoles" resultType="com.ejweb.modules.role.entity.UserRolesEntity">
SELECT DISTINCT(p.id), p.permission,p.name AS menuName SELECT DISTINCT(p.id), p.permission,p.name AS menuName
FROM sys_user2role a FROM sys_user2role a
......
...@@ -23,12 +23,13 @@ public interface UserRolesDao extends BaseDao { ...@@ -23,12 +23,13 @@ public interface UserRolesDao extends BaseDao {
List<UserRolesEntity> getRootRoles(UserRolesBean bean); List<UserRolesEntity> getRootRoles(UserRolesBean bean);
List<InformationEntity> getInformation(UserRolesBean bean); List<InformationEntity> getInformation(UserRolesBean bean);
Integer getOilRole(UserRolesBean bean);
/** /**
*
* @author zhanglg
* @time 2016年10月3日
* @param bean * @param bean
* @return * @return
* @author zhanglg
* @time 2016年10月3日
*/ */
List<UserRolesEntity> getParentRoles(UserRolesBean bean); List<UserRolesEntity> getParentRoles(UserRolesBean bean);
......
...@@ -6,12 +6,12 @@ import com.ejweb.modules.role.bean.UserRolesBean; ...@@ -6,12 +6,12 @@ import com.ejweb.modules.role.bean.UserRolesBean;
import com.ejweb.modules.role.dao.UserRolesDao; import com.ejweb.modules.role.dao.UserRolesDao;
import com.ejweb.modules.role.entity.InformationEntity; import com.ejweb.modules.role.entity.InformationEntity;
import com.ejweb.modules.role.entity.UserRolesEntity; import com.ejweb.modules.role.entity.UserRolesEntity;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* @author yuxg * @author yuxg
...@@ -28,45 +28,54 @@ public class UserRolesService extends BaseService<UserRolesDao> { ...@@ -28,45 +28,54 @@ public class UserRolesService extends BaseService<UserRolesDao> {
public List<UserRolesEntity> getRootRoles(UserRolesBean bean) { public List<UserRolesEntity> getRootRoles(UserRolesBean bean) {
return dao.getRootRoles( bean); return dao.getRootRoles(bean);
} }
public List<UserRolesEntity> getUserPermissionList(String userCode) { public List<UserRolesEntity> getUserPermissionList(String userCode) {
UserRolesBean bean = new UserRolesBean(); UserRolesBean bean = new UserRolesBean();
bean.setUserCode(userCode); 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(); public List<JSONObject> getList(String userCode, String p) {
List<JSONObject> jsonlist=new ArrayList<JSONObject>(); UserRolesBean bean = new UserRolesBean();
List<JSONObject> jsonlist = new ArrayList<JSONObject>();
bean.setUserCode(userCode); bean.setUserCode(userCode);
if(StringUtils.isNoneBlank(p)){ if (StringUtils.isNoneBlank(p)) {
bean.setPermission(p); bean.setPermission(p);
} }
List<UserRolesEntity> list1= getParentRoles(bean); List<UserRolesEntity> list1 = getParentRoles(bean);
for(UserRolesEntity entity1 :list1 ){ for (UserRolesEntity entity1 : list1) {
JSONObject json=new JSONObject(); JSONObject json = new JSONObject();
json.put("name", entity1.getMenuName()); json.put("name", entity1.getMenuName());
json.put("permission", entity1.getPermission()); json.put("permission", entity1.getPermission());
getChildList(bean,json,entity1.getId()); getChildList(bean, json, entity1.getId());
jsonlist.add(json); jsonlist.add(json);
} }
return jsonlist; return jsonlist;
} }
private JSONObject getChildList(UserRolesBean bean,JSONObject data,String id){
private JSONObject getChildList(UserRolesBean bean, JSONObject data, String id) {
bean.setId(id); bean.setId(id);
List<UserRolesEntity> list1= getUserRoles(bean); List<UserRolesEntity> list1 = getUserRoles(bean);
if(list1.size()!=0){ if (list1.size() != 0) {
List<JSONObject> jsonlist1=new ArrayList<JSONObject>(); List<JSONObject> jsonlist1 = new ArrayList<JSONObject>();
for(UserRolesEntity entity1 :list1 ){ for (UserRolesEntity entity1 : list1) {
JSONObject json=new JSONObject(); JSONObject json = new JSONObject();
json.put("name", entity1.getMenuName()); json.put("name", entity1.getMenuName());
json.put("permission", entity1.getPermission()); json.put("permission", entity1.getPermission());
getChildList(bean,json,entity1.getId()); getChildList(bean, json, entity1.getId());
jsonlist1.add(json); jsonlist1.add(json);
} }
data.put("children", jsonlist1); data.put("children", jsonlist1);
...@@ -75,11 +84,10 @@ public class UserRolesService extends BaseService<UserRolesDao> { ...@@ -75,11 +84,10 @@ public class UserRolesService extends BaseService<UserRolesDao> {
} }
/** /**
*
* @author zhanglg
* @time 2016年10月3日
* @param bean * @param bean
* @return * @return
* @author zhanglg
* @time 2016年10月3日
*/ */
public List<UserRolesEntity> getParentRoles(UserRolesBean bean) { public List<UserRolesEntity> getParentRoles(UserRolesBean bean) {
......
...@@ -350,12 +350,17 @@ public class UserController { ...@@ -350,12 +350,17 @@ public class UserController {
bean.setUserCode(userEntity.getId()); bean.setUserCode(userEntity.getId());
// 默认有航线论证权限(0表示有航线论证权限,1是没有) // 默认有航线论证权限(0表示有航线论证权限,1是没有)
userEntity.setVerify("0"); userEntity.setVerify("0");
// 默认没有油量分析权限(0表示有油量分析权限,1是没有)
userEntity.setOil("1");
List<InformationEntity> informationEntity = userRolesService.getInformation(bean); List<InformationEntity> informationEntity = userRolesService.getInformation(bean);
// 获取航线论证的部门信息 // 获取航线论证的部门信息
if (informationEntity == null || informationEntity.size() == 0) { if (informationEntity == null || informationEntity.size() == 0) {
// 无航向论证权限 // 无航向论证权限
userEntity.setVerify("1"); userEntity.setVerify("1");
} }
if (userRolesService.getOilRole(bean)) {
userEntity.setOil("0");
}
userEntity.setShowPhone(userEntity.getPhone()); userEntity.setShowPhone(userEntity.getPhone());
userEntity.setPhone(Util.formatedWorkPhone(userEntity.getPhone())); userEntity.setPhone(Util.formatedWorkPhone(userEntity.getPhone()));
responseBean.setData(userEntity); responseBean.setData(userEntity);
......
...@@ -14,6 +14,7 @@ public class LoginUserEntity extends BaseEntity { ...@@ -14,6 +14,7 @@ public class LoginUserEntity extends BaseEntity {
@JSONField(serialize=false) @JSONField(serialize=false)
private String officeId; // 归属ID private String officeId; // 归属ID
private String verify; private String verify;
private String oil = "1";
private String officeName; // 归属部门 private String officeName; // 归属部门
private String officeFullName; // 归属部门 private String officeFullName; // 归属部门
@JSONField(serialize = false) @JSONField(serialize = false)
...@@ -281,14 +282,24 @@ public class LoginUserEntity extends BaseEntity { ...@@ -281,14 +282,24 @@ public class LoginUserEntity extends BaseEntity {
public String getPlatform() { public String getPlatform() {
return platform; return platform;
} }
public void setPlatform(String platform) { public void setPlatform(String platform) {
this.platform = platform; this.platform = platform;
} }
public String getDeviceToken() { public String getDeviceToken() {
return deviceToken; return deviceToken;
} }
public void setDeviceToken(String deviceToken) { public void setDeviceToken(String deviceToken) {
this.deviceToken = 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