Commit 354494eb by 宋振民

Merge remote-tracking branch 'origin/dev-2.0-0126' into dev-2.0-security

parents e085ac44 6228435d
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for sys_module
-- ----------------------------
DROP TABLE IF EXISTS `sys_module`;
CREATE TABLE `sys_module` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`CREATE_DATE` datetime NOT NULL,
`CREATE_USERID` decimal(11, 0) NOT NULL,
`STATE` decimal(2, 0) NOT NULL,
`MODULE_NAME` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`MODULE_URL` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`MODULE_IMAGE` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`MODULE_TYPE` varchar(6) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`PARENT_ID` decimal(11, 0) NULL DEFAULT NULL,
`MODULE_CODE` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`SORT` decimal(11, 0) NULL DEFAULT NULL,
PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_module
-- ----------------------------
INSERT INTO `sys_module` VALUES (1, '2021-03-03 13:43:19', 1, 1, '医生职业档案', NULL, NULL, '1', 0, 'DOCTORS_ARCHIVES', 1);
SET FOREIGN_KEY_CHECKS = 1;
INSERT INTO `sys_role_menu_rs` (`ID`, `CREATE_DATE`, `CREATE_USERID`, `STATE`, `MENU_ID`, `ROLE_ID`) VALUES (23, '2021-03-03 12:51:07', 1, 1, 34, 2);
INSERT INTO `sys_role_menu_rs` (`ID`, `CREATE_DATE`, `CREATE_USERID`, `STATE`, `MENU_ID`, `ROLE_ID`) VALUES (24, '2021-03-03 15:01:20', 1, 1, 35, 2);
INSERT INTO `sys_role_menu_rs` (`ID`, `CREATE_DATE`, `CREATE_USERID`, `STATE`, `MENU_ID`, `ROLE_ID`) VALUES (25, '2021-03-03 15:01:34', 1, 1, 36, 2);
INSERT INTO `sys_role_menu_rs` (`ID`, `CREATE_DATE`, `CREATE_USERID`, `STATE`, `MENU_ID`, `ROLE_ID`) VALUES (26, '2021-03-03 15:01:53', 1, 1, 34, 1);
INSERT INTO `sys_role_menu_rs` (`ID`, `CREATE_DATE`, `CREATE_USERID`, `STATE`, `MENU_ID`, `ROLE_ID`) VALUES (27, '2021-03-03 15:29:02', 1, 1, 35, 1);
INSERT INTO `sys_role_menu_rs` (`ID`, `CREATE_DATE`, `CREATE_USERID`, `STATE`, `MENU_ID`, `ROLE_ID`) VALUES (28, '2021-03-03 15:29:38', 1, 1, 36, 1);
INSERT INTO `sys_role_menu_rs` (`ID`, `CREATE_DATE`, `CREATE_USERID`, `STATE`, `MENU_ID`, `ROLE_ID`) VALUES (29, '2021-03-03 15:29:51', 1, 1, 30, 1);
INSERT INTO `sys_role_menu_rs` (`ID`, `CREATE_DATE`, `CREATE_USERID`, `STATE`, `MENU_ID`, `ROLE_ID`) VALUES (30, '2021-03-03 15:30:29', 1, 1, 31, 1);
INSERT INTO `sys_role_menu_rs` (`ID`, `CREATE_DATE`, `CREATE_USERID`, `STATE`, `MENU_ID`, `ROLE_ID`) VALUES (31, '2021-03-03 15:30:39', 1, 1, 32, 1);
INSERT INTO `sys_role_menu_rs` (`ID`, `CREATE_DATE`, `CREATE_USERID`, `STATE`, `MENU_ID`, `ROLE_ID`) VALUES (32, '2021-03-03 15:30:48', 1, 1, 33, 1);
INSERT INTO `sys_role_menu_rs` (`ID`, `CREATE_DATE`, `CREATE_USERID`, `STATE`, `MENU_ID`, `ROLE_ID`) VALUES (33, '2021-03-03 15:32:57', 1, 1, 30, 2);
INSERT INTO `sys_role_menu_rs` (`ID`, `CREATE_DATE`, `CREATE_USERID`, `STATE`, `MENU_ID`, `ROLE_ID`) VALUES (34, '2021-03-03 15:33:17', 1, 1, 31, 2);
INSERT INTO `sys_role_menu_rs` (`ID`, `CREATE_DATE`, `CREATE_USERID`, `STATE`, `MENU_ID`, `ROLE_ID`) VALUES (35, '2021-03-03 15:33:31', 1, 1, 32, 2);
INSERT INTO `sys_role_menu_rs` (`ID`, `CREATE_DATE`, `CREATE_USERID`, `STATE`, `MENU_ID`, `ROLE_ID`) VALUES (36, '2021-03-03 15:33:42', 1, 1, 33, 2);
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for sys_role_module_rs
-- ----------------------------
DROP TABLE IF EXISTS `sys_role_module_rs`;
CREATE TABLE `sys_role_module_rs` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`CREATE_DATE` datetime NOT NULL,
`CREATE_USERID` decimal(11, 0) NOT NULL,
`STATE` decimal(2, 0) NULL DEFAULT NULL,
`MODULE_ID` decimal(11, 0) NULL DEFAULT NULL,
`ROLE_ID` decimal(11, 0) NULL DEFAULT NULL,
PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of sys_role_module_rs
-- ----------------------------
INSERT INTO `sys_role_module_rs` VALUES (1, '2021-03-03 13:42:28', 1, 1, 1, 1);
INSERT INTO `sys_role_module_rs` VALUES (2, '2021-03-03 13:42:46', 1, 1, 1, 2);
SET FOREIGN_KEY_CHECKS = 1;
......@@ -9,6 +9,7 @@ import com.hs.api.model.SysRole;
import com.hs.api.model.SysUser;
import com.hs.api.model.reqmodel.Disease;
import com.hs.api.model.reqmodel.MenuReq;
import com.hs.api.model.reqmodel.ModuleReq;
import com.hs.api.model.respmodel.LoginInfo;
import com.hs.api.model.respmodel.SysMenuList;
import com.hs.api.service.LoginService;
......@@ -96,11 +97,23 @@ public class UserController {
@PostMapping("menu/list")
@Token
@ApiOperation("查询综合菜单")
public Object getMenuByType(@RequestBody MenuReq req) throws Exception {
List<SysMenuList> sysMenuList = sysMenuService.getMenuByType(req.getMenuType());
public Object getMenuByType(HttpServletRequest request,@RequestBody MenuReq req) throws Exception {
String token = request.getHeader(Constants.TOKEN_KEY);
SysUser user = (SysUser) RedisUtil.get(token);
List<SysMenuList> sysMenuList = sysMenuService.getMenuByType(user.getId(), req.getMenuType());
return Result.success(sysMenuList);
}
@PostMapping("module/state")
@Token
@ApiOperation("查询module状态")
public Object getModuleStateByCode(HttpServletRequest request,@RequestBody ModuleReq req) throws Exception {
String token = request.getHeader(Constants.TOKEN_KEY);
SysUser user = (SysUser) RedisUtil.get(token);
boolean menuState = sysMenuService.getModuleStateByCode(user.getId(), req.getModuleCode());
return Result.success(menuState);
}
/**
* 根据用户id查询用户机构
*
......
package com.hs.api.mapper;
import com.hs.api.model.SysMenu;
import com.hs.api.model.SysModule;
import com.hs.api.model.respmodel.SysMenuList;
import org.apache.ibatis.annotations.Param;
......@@ -20,4 +21,8 @@ public interface SysMenuMapper {
List<SysMenuList> selectMenuByUser(@Param("userId") Long userId);
List<SysMenuList> selectMenuByType(@Param("menuType") Integer menuType);
List<SysMenuList> selectMenuByRs(@Param("userId") Long userId,@Param("menuType") Integer menuType);
List<SysModule> getModuleByCode(@Param("userId") Long userId, @Param("moduleCode") String moduleCode);
}
\ No newline at end of file
package com.hs.api.model;
import java.util.Date;
public class SysModule {
private Long id;
private Date createDate;
private Long createUserid;
private boolean state;
private String moduleName;
private String moduleUrl;
private String moduleImage;
private Long parentId;
private String pageCode;
private Long sort;
private Long moduleType;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public Long getCreateUserid() {
return createUserid;
}
public void setCreateUserid(Long createUserid) {
this.createUserid = createUserid;
}
public boolean getState() {
return state;
}
public void setState(boolean state) {
this.state = state;
}
public String getmoduleName() {
return moduleName;
}
public void setmoduleName(String moduleName) {
this.moduleName = moduleName;
}
public String getmoduleUrl() {
return moduleUrl;
}
public void setmoduleUrl(String moduleUrl) {
this.moduleUrl = moduleUrl;
}
public String getmoduleImage() {
return moduleImage;
}
public void setmoduleImage(String moduleImage) {
this.moduleImage = moduleImage;
}
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public String getPageCode() {
return pageCode;
}
public void setPageCode(String pageCode) {
this.pageCode = pageCode;
}
public Long getSort() {
return sort;
}
public void setSort(Long sort) {
this.sort = sort;
}
public Long getmoduleType() {
return moduleType;
}
public void setmoduleType(Long moduleType) {
this.moduleType = moduleType;
}
}
\ No newline at end of file
......@@ -10,4 +10,8 @@ public class MenuReq {
@NotNull(message = "菜单类型不能为空")
@ApiModelProperty("菜单类型")
private Integer menuType;
@NotNull(message = "用户ID不能为空")
@ApiModelProperty("用户ID")
private Long userId;
}
package com.hs.api.model.reqmodel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Data
public class ModuleReq {
@NotNull(message = "模块编码不能为空")
@ApiModelProperty("模块编码")
private String moduleCode;
@NotNull(message = "用户ID不能为空")
@ApiModelProperty("用户ID")
private Long userId;
}
......@@ -2,8 +2,11 @@ package com.hs.api.service.Impl;
import com.hs.api.mapper.SysMenuMapper;
import com.hs.api.model.SysMenu;
import com.hs.api.model.SysModule;
import com.hs.api.model.SysUser;
import com.hs.api.model.respmodel.SysMenuList;
import com.hs.api.service.SysMenuService;
import com.hs.common.utils.RedisUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
......@@ -29,10 +32,15 @@ public class SysMenuServiceImpl implements SysMenuService {
}
@Override
public List<SysMenuList> getMenuByType(Integer menuType) throws Exception {
public List<SysMenuList> getMenuByType(Long userId, Integer menuType) throws Exception {
SysMenuList sysMenuList = new SysMenuList();
SysMenu sysMenu = new SysMenu();
List<SysMenuList> list = sysMenuMapper.selectMenuByType(menuType);
List<SysMenuList> list = new ArrayList<>();
if(menuType==4) {
list = sysMenuMapper.selectMenuByRs(userId,menuType);
}else {
list = sysMenuMapper.selectMenuByType(menuType);
}
List<SysMenuList> resultList = getLevelData(list, Long.valueOf(MENU_TOP_PARENT_ID));
resultList = resultList.stream().sorted(Comparator.comparing(SysMenu::getSort)).collect(Collectors.toList());
return resultList;
......@@ -52,6 +60,16 @@ public class SysMenuServiceImpl implements SysMenuService {
}
@Override
public boolean getModuleStateByCode(Long userId, String moduleCode) {
List<SysModule> module = sysMenuMapper.getModuleByCode(userId, moduleCode);
if(module.size()>0) {
return module.get(0).getState();
}else {
return true;
}
}
@Override
public int add(SysMenu sysMenu) {
return sysMenuMapper.insert(sysMenu);
}
......
......@@ -12,5 +12,7 @@ public interface SysMenuService extends ServiceBase<SysMenu> {
List<SysMenuList> getMenu(Long userId) throws Exception;
List<SysMenuList> getMenuByType(Integer menuType) throws Exception;
List<SysMenuList> getMenuByType(Long user_id, Integer menuType) throws Exception;
boolean getModuleStateByCode(Long userId, String moduleCode) throws Exception;
}
......@@ -14,6 +14,19 @@
<result column="SORT" jdbcType="DECIMAL" property="sort"/>
<result column="MENU_TYPE" jdbcType="DECIMAL" property="menuType"/>
</resultMap>
<resultMap id="sysModuleResultMap" type="com.hs.api.model.SysModule">
<id column="ID" jdbcType="DECIMAL" property="id"/>
<result column="CREATE_DATA" jdbcType="TIMESTAMP" property="createData"/>
<result column="CREATE_USERID" jdbcType="DECIMAL" property="createUserid"/>
<result column="module_state" jdbcType="DECIMAL" property="state"/>
<result column="MODULE_NAME" jdbcType="VARCHAR" property="moduleName"/>
<result column="MODULE_URL" jdbcType="VARCHAR" property="moduleUrl"/>
<result column="MODULE_IMAGE" jdbcType="VARCHAR" property="moduleImage"/>
<result column="PARENT_ID" jdbcType="DECIMAL" property="parentId"/>
<result column="PAGE_CODE" jdbcType="VARCHAR" property="pageCode"/>
<result column="SORT" jdbcType="DECIMAL" property="sort"/>
<result column="MODULE_TYPE" jdbcType="DECIMAL" property="moduleType"/>
</resultMap>
<resultMap id="sysMenuResultMap" type="com.hs.api.model.respmodel.SysMenuList" extends="BaseResultMap"/>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete
......@@ -116,4 +129,36 @@
where STATE = 1
and MENU_TYPE = #{menuType}
</select>
<select id="selectMenuByRs" resultMap="sysMenuResultMap">
select DISTINCT m.ID,
m.MENU_NAME,
m.MENU_URL,
m.MENU_IMAGE,
m.PARENT_ID,
m.PAGE_CODE,
m.SORT,
m.MENU_TYPE
from SYS_ROLE_MENU_RS rmr
LEFT JOIN
SYS_MENU m on rmr.MENU_ID = m.ID
LEFT JOIN
SYS_USER_ROLE_RS urr on rmr.ROLE_ID = urr.Role_ID
where rmr.STATE = 1
and m.STATE = 1
and urr.STATE = 1
and urr.USER_ID = #{userId,jdbcType=DECIMAL}
and m.MENU_TYPE = #{menuType,jdbcType=INTEGER}
</select>
<select id="getModuleByCode" resultMap="sysModuleResultMap">
SELECT DISTINCT
sm.*,rmr.state module_state
FROM
SYS_ROLE_MODULE_RS rmr
LEFT JOIN SYS_MODULE sm ON rmr.MODULE_ID = sm.id
LEFT JOIN SYS_USER_ROLE_RS urr ON rmr.ROLE_ID = urr.Role_ID
WHERE
sm.module_code = #{moduleCode,jdbcType=VARCHAR}
AND urr.user_id = #{userId,jdbcType=DECIMAL}
AND urr.state =1
</select>
</mapper>
\ No newline at end of file
......@@ -20,7 +20,7 @@ public class LoginServiceTest {
String password = "123";
String macAddrss = "EO-D5-5E-6C-4D-7D";
String ip = "112.64.68.44";
loginService.login(logName, password, macAddrss, ip);
//loginService.login(logName, password, macAddrss, ip);
System.out.println(1111);
}
}
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