src/main/java/com/whyc/controller/MenuUserController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/mapper/MenuUserMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/pojo/MenuUser.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/whyc/service/MenuUserService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/whyc/controller/MenuUserController.java
New file @@ -0,0 +1,50 @@ package com.whyc.controller; import com.whyc.dto.Response; import com.whyc.pojo.Menu; import com.whyc.pojo.MenuUser; import com.whyc.service.MenuService; import com.whyc.service.MenuUserService; import com.whyc.util.ActionUtil; import com.whyc.util.CommonUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.ibatis.annotations.Delete; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; @RestController @RequestMapping("menuUser") @Api(tags = "系统设置-系统配置-用户专属菜单") public class MenuUserController { @Autowired private MenuUserService service; @GetMapping("list") @ApiOperation(value = "查询列表") public Response<List<MenuUser>> getList(){ int userId = ActionUtil.getUser().getUId().intValue(); List<MenuUser> menuList = service.getList(userId); return new Response<List<MenuUser>>().set(1,menuList); } @PostMapping("list") @ApiOperation(value = "添加") public Response addList(@RequestBody List<MenuUser> menuList){ int userId = ActionUtil.getUser().getUId().intValue(); menuList.forEach(menuUser -> menuUser.setUserId(userId)); service.addList(menuList); return new Response().set(1,"添加完成"); } @DeleteMapping("list") @ApiOperation(value = "删除") public Response deleteList(@RequestBody List<Integer> numList){ service.deleteList(numList); return new Response().set(1,"删除完成"); } } src/main/java/com/whyc/mapper/MenuUserMapper.java
New file @@ -0,0 +1,6 @@ package com.whyc.mapper; import com.whyc.pojo.MenuUser; public interface MenuUserMapper extends CustomMapper<MenuUser>{ } src/main/java/com/whyc/pojo/MenuUser.java
New file @@ -0,0 +1,139 @@ package com.whyc.pojo; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import org.apache.ibatis.type.Alias; import java.util.List; @TableName(schema = "db_app_sys",value = "tb_menu_user") @Alias("MenuUser") public class MenuUser { @TableId(type = IdType.AUTO) private Integer num; private Integer id; private String label; private String name; private String src; private String icon; @TableField("enableduse") private boolean enableduse; @TableField("permitName") private String permitName; private Integer level; private Integer ord; @TableField("menuId") private Integer menuId; private boolean closable; @TableField("userId") private Integer userId; public Integer getNum() { return num; } public void setNum(Integer num) { this.num = num; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getLabel() { return label; } public void setLabel(String label) { this.label = label; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getSrc() { return src; } public void setSrc(String src) { this.src = src; } public String getIcon() { return icon; } public void setIcon(String icon) { this.icon = icon; } public boolean isEnableduse() { return enableduse; } public void setEnableduse(boolean enableduse) { this.enableduse = enableduse; } public boolean isClosable() { return closable; } public void setClosable(boolean closable) { this.closable = closable; } public String getPermitName() { return permitName; } public void setPermitName(String permitName) { this.permitName = permitName; } public Integer getLevel() { return level; } public void setLevel(Integer level) { this.level = level; } public Integer getOrd() { return ord; } public void setOrd(Integer ord) { this.ord = ord; } public Integer getMenuId() { return menuId; } public void setMenuId(Integer menuId) { this.menuId = menuId; } public Integer getUserId() { return userId; } public void setUserId(Integer userId) { this.userId = userId; } } src/main/java/com/whyc/service/MenuUserService.java
New file @@ -0,0 +1,32 @@ package com.whyc.service; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.whyc.dto.Response; import com.whyc.mapper.MenuUserMapper; import com.whyc.pojo.MenuUser; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.List; @Service public class MenuUserService { @Resource private MenuUserMapper mapper; public List<MenuUser> getList(int userId) { QueryWrapper<MenuUser> query = Wrappers.query(); query.eq("userId",userId); return mapper.selectList(query); } public void addList(List<MenuUser> menuList) { mapper.insertBatchSomeColumn(menuList); } public void deleteList(List<Integer> numList) { mapper.deleteBatchIds(numList); } }