Commit ce42e534 authored by wzp's avatar wzp

修改获取菜单和日志返回信息

parent 9a5967ba
...@@ -32,6 +32,7 @@ import javax.servlet.http.HttpServletRequest; ...@@ -32,6 +32,7 @@ import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.net.InetAddress; import java.net.InetAddress;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -101,21 +102,22 @@ class SystemOperationLogService extends ServiceImpl<SysLogMapper, SysLog> { ...@@ -101,21 +102,22 @@ class SystemOperationLogService extends ServiceImpl<SysLogMapper, SysLog> {
String operatingcontent = ""; String operatingcontent = "";
Object[] method_param = null; Object[] method_param = null;
// Object object; Object object;
// try { try {
// method_param = point.getArgs(); //获取方法参数 method_param = point.getArgs(); //获取方法参数
// // String param=(String) point.proceed(point.getArgs()); // String param=(String) point.proceed(point.getArgs());
// object = point.proceed(); object = point.proceed();
// } catch (Exception e) { } catch (Exception e) {
// // 异常处理记录日志..log.error(e); // 异常处理记录日志..log.error(e);
// throw e; throw e;
// } }
if (methodLog.operModule().getMsg().contains("运维")) { if (methodLog.operModule().getMsg().contains("运维")) {
TOperationLog operationLog = new TOperationLog(); TOperationLog operationLog = new TOperationLog();
operationLog.setCreateTime(LocalDateTime.now()); operationLog.setCreateTime(LocalDateTime.now());
operationLog.setUserId(user.getId()); operationLog.setUserId(user.getId());
operationLog.setOperationType(methodLog.operType().getMsg()); operationLog.setOperationType(methodLog.operType().getMsg());
return operationLogService.save(operationLog); operationLogService.save(operationLog);
return object;
} }
SysLog sysLog = new SysLog(); SysLog sysLog = new SysLog();
if ("1".equals(user.getId())) { if ("1".equals(user.getId())) {
...@@ -132,7 +134,7 @@ class SystemOperationLogService extends ServiceImpl<SysLogMapper, SysLog> { ...@@ -132,7 +134,7 @@ class SystemOperationLogService extends ServiceImpl<SysLogMapper, SysLog> {
getControllerMethodDescription(methodLog, sysLog); getControllerMethodDescription(methodLog, sysLog);
int insert = sysLogMapper.insert(sysLog); int insert = sysLogMapper.insert(sysLog);
return insert; return object;
} }
/** /**
......
...@@ -9,6 +9,7 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -9,6 +9,7 @@ import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* <p> * <p>
...@@ -69,8 +70,24 @@ public class Menu extends Model<Menu> { ...@@ -69,8 +70,24 @@ public class Menu extends Model<Menu> {
/** /**
* 排序 * 排序
*/ */
@TableField("sort")
@ApiModelProperty(value = "排序")
private Integer sort; private Integer sort;
/**
* 级别
*/
@TableField("level")
@ApiModelProperty(value = "级别")
private Integer level;
/**
* 下级
*/
@TableField(exist = false)
@ApiModelProperty(value = "下级")
private List<Menu> children;
public String getId() { public String getId() {
return id; return id;
...@@ -144,6 +161,22 @@ public class Menu extends Model<Menu> { ...@@ -144,6 +161,22 @@ public class Menu extends Model<Menu> {
this.sort = sort; this.sort = sort;
} }
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public List<Menu> getChildren() {
return children;
}
public void setChildren(List<Menu> children) {
this.children = children;
}
@Override @Override
protected Serializable pkVal() { protected Serializable pkVal() {
return this.id; return this.id;
......
...@@ -133,6 +133,11 @@ public class TUser implements Serializable { ...@@ -133,6 +133,11 @@ public class TUser implements Serializable {
@TableField(exist = false) @TableField(exist = false)
private String orgName; private String orgName;
@ApiModelProperty("机构编码")
@TableField(exist = false)
private String orgCode;
@ApiModelProperty("角色集合") @ApiModelProperty("角色集合")
@TableField(exist = false) @TableField(exist = false)
private List<Role> roleList; private List<Role> roleList;
......
...@@ -9,7 +9,9 @@ import org.springframework.stereotype.Service; ...@@ -9,7 +9,9 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* <p> * <p>
...@@ -28,7 +30,20 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IM ...@@ -28,7 +30,20 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IM
public List<Menu> getUserMenuPerms(List<Role> list) { public List<Menu> getUserMenuPerms(List<Role> list) {
List<String> list1 = new ArrayList<>(); List<String> list1 = new ArrayList<>();
list.stream().forEach(r-> list1.add(r.getId())); list.stream().forEach(r-> list1.add(r.getId()));
return menuMapper.getUserMenuPerms(list1); List<Menu> menuList = menuMapper.getUserMenuPerms(list1);
HashMap<String, Menu> map = new HashMap<>();
menuList.forEach(m->map.put(m.getId(),m));
for (Menu menu : menuList) {
Menu parent = map.get(menu.getParentId());
if (parent!=null){
if (parent.getChildren()==null){
parent.setChildren(new ArrayList<>());
}
parent.getChildren().add(menu);
}
}
menuList = menuList.stream().filter(m -> m.getLevel()==1).collect(Collectors.toList());
return menuList;
} }
} }
...@@ -6,6 +6,7 @@ import cn.wisenergy.chnmuseum.party.common.log.OperType; ...@@ -6,6 +6,7 @@ import cn.wisenergy.chnmuseum.party.common.log.OperType;
import cn.wisenergy.chnmuseum.party.common.util.DateUtil80; import cn.wisenergy.chnmuseum.party.common.util.DateUtil80;
import cn.wisenergy.chnmuseum.party.common.util.ImportExcelUtil; import cn.wisenergy.chnmuseum.party.common.util.ImportExcelUtil;
import cn.wisenergy.chnmuseum.party.model.TArea; import cn.wisenergy.chnmuseum.party.model.TArea;
import cn.wisenergy.chnmuseum.party.model.TUser;
import cn.wisenergy.chnmuseum.party.service.TAreaService; import cn.wisenergy.chnmuseum.party.service.TAreaService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
...@@ -133,7 +134,13 @@ public class TOrganController extends BaseController { ...@@ -133,7 +134,13 @@ public class TOrganController extends BaseController {
@ApiOperation(value = "获取机构全部列表(无分页)", notes = "获取机构全部列表(无分页)") @ApiOperation(value = "获取机构全部列表(无分页)", notes = "获取机构全部列表(无分页)")
@MethodLog(operModule = OperModule.ORG,operType = OperType.SELECT) @MethodLog(operModule = OperModule.ORG,operType = OperType.SELECT)
public Map<String, Object> getTOrganList() { public Map<String, Object> getTOrganList() {
List<TOrgan> tOrganList = tOrganService.list(Wrappers.<TOrgan>lambdaQuery().eq(TOrgan::getIsDeleted, 0)); TUser user = null;
try {
user = getcurUser();
} catch (Exception e) {
e.printStackTrace();
}
List<TOrgan> tOrganList = tOrganService.list(Wrappers.<TOrgan>lambdaQuery().eq(TOrgan::getIsDeleted, 0).likeRight(TOrgan::getCode,user.getOrgCode()).orderByDesc(TOrgan::getCreateTime));
return getResult(tOrganList); return getResult(tOrganList);
} }
......
...@@ -3,10 +3,13 @@ package cn.wisenergy.chnmuseum.party.web.controller.base; ...@@ -3,10 +3,13 @@ package cn.wisenergy.chnmuseum.party.web.controller.base;
import cn.wisenergy.chnmuseum.party.auth.util.JwtTokenUtil; import cn.wisenergy.chnmuseum.party.auth.util.JwtTokenUtil;
import cn.wisenergy.chnmuseum.party.common.enums.RESPONSE_CODE_ENUM; import cn.wisenergy.chnmuseum.party.common.enums.RESPONSE_CODE_ENUM;
import cn.wisenergy.chnmuseum.party.common.enums.RESULT_INFO_ENUM; import cn.wisenergy.chnmuseum.party.common.enums.RESULT_INFO_ENUM;
import cn.wisenergy.chnmuseum.party.model.TUser;
import cn.wisenergy.chnmuseum.party.service.impl.TUserServiceImpl;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SimplePropertyPreFilter; import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.catalina.User;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -26,9 +29,13 @@ public class BaseController implements Serializable { ...@@ -26,9 +29,13 @@ public class BaseController implements Serializable {
private static final long serialVersionUID = 624841049563451448L; private static final long serialVersionUID = 624841049563451448L;
protected static final Logger logger = LoggerFactory.getLogger(BaseController.class); protected static final Logger logger = LoggerFactory.getLogger(BaseController.class);
@Resource @Resource
protected HttpServletRequest request; protected HttpServletRequest request;
@Resource
protected TUserServiceImpl userService;
/** /**
* <p> * <p>
* 获取分页对象 * 获取分页对象
...@@ -190,4 +197,15 @@ public class BaseController implements Serializable { ...@@ -190,4 +197,15 @@ public class BaseController implements Serializable {
return JwtTokenUtil.getUsername(authorization); return JwtTokenUtil.getUsername(authorization);
} }
/**
* <p>
* 根据token信息获取当前用户
* </p>
*/
protected TUser getcurUser() {
String userName = getUserName();
TUser user = userService.selectByUsername(userName);
return user;
}
} }
...@@ -12,11 +12,12 @@ ...@@ -12,11 +12,12 @@
<result column="menu_name" property="menuName" /> <result column="menu_name" property="menuName" />
<result column="parent_id" property="parentId" /> <result column="parent_id" property="parentId" />
<result column="is_button" property="isButton" /> <result column="is_button" property="isButton" />
<result column="level" property="level" />
</resultMap> </resultMap>
<select id="getUserMenuPerms" resultMap="BaseResultMap"> <select id="getUserMenuPerms" resultMap="BaseResultMap">
SELECT distinct SELECT distinct
m.id,m.menu_name,m.menu_url,m.parent_id,m.sort,m.is_button m.id,m.menu_name,m.menu_url,m.parent_id,m.sort,m.is_button,m.level
FROM FROM
ref_role_menu rm ref_role_menu rm
LEFT JOIN menu m ON m.id = rm.menu_id LEFT JOIN menu m ON m.id = rm.menu_id
...@@ -29,7 +30,7 @@ ...@@ -29,7 +30,7 @@
</foreach> </foreach>
</if> </if>
</where> </where>
ORDER BY m.sort ASC ORDER BY m.level desc
</select> </select>
</mapper> </mapper>
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
<result column="password" property="password"/> <result column="password" property="password"/>
<result column="org_name" property="orgName"/> <result column="org_name" property="orgName"/>
<result column="area_name" property="areaName"/> <result column="area_name" property="areaName"/>
<result column="org_code" property="orgCode"/>
<collection fetchType="eager" property="roleList" ofType="cn.wisenergy.chnmuseum.party.model.Role" <collection fetchType="eager" property="roleList" ofType="cn.wisenergy.chnmuseum.party.model.Role"
select="selectRoles" column="user_name"/> select="selectRoles" column="user_name"/>
</resultMap> </resultMap>
...@@ -51,7 +52,7 @@ ...@@ -51,7 +52,7 @@
</sql> </sql>
<select id="selectByUsername" resultMap="BaseResultMap"> <select id="selectByUsername" resultMap="BaseResultMap">
select u.*,o.name org_name,a.full_name area_name select u.*,o.name org_name,a.full_name area_name,o.code org_code
from t_user u from t_user u
left join t_organ o on o.id = u.org_id left join t_organ o on o.id = u.org_id
left join t_area a on u.area_id = a.id left join t_area a on u.area_id = a.id
......
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