3-16
This commit is contained in:
+84
@@ -0,0 +1,84 @@
|
||||
package com.adc.da.slrs.tsRoleMeunData.controller;
|
||||
|
||||
|
||||
import com.adc.da.http.ResponseMessage;
|
||||
import com.adc.da.http.Result;
|
||||
import com.adc.da.slrs.tsRoleMeunData.service.ITsRoleMenuDataService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.adc.da.slrs.tsRoleMeunData.entity.TsRoleMenuData;
|
||||
import io.swagger.annotations.Api;
|
||||
import com.adc.da.base.web.BaseController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author yzh
|
||||
* @since 2022-03-16
|
||||
*/
|
||||
@RestController
|
||||
@Api(description = "|TsRoleMenuData|")
|
||||
@RequestMapping("/${restPath}/tsRoleMeunData/ts-role-menu-data")
|
||||
public class TsRoleMenuDataController extends BaseController<TsRoleMenuData> {
|
||||
|
||||
@Autowired
|
||||
private ITsRoleMenuDataService iTsRoleMenuDataService;
|
||||
|
||||
|
||||
@ApiOperation("角色与菜单关联控制右侧数据列表")
|
||||
@PostMapping("/saveBatch")
|
||||
public ResponseMessage<Object> disable(@RequestBody TsRoleMenuData tsRoleMenuData){
|
||||
//上来就给他 清了 能满足清空 修改 新增
|
||||
QueryWrapper<TsRoleMenuData> wrapper=new QueryWrapper<>();
|
||||
wrapper.eq("ROLE_ID",tsRoleMenuData.getRoleId());
|
||||
iTsRoleMenuDataService.remove(wrapper);
|
||||
|
||||
if (StringUtils.isNotBlank(tsRoleMenuData.getMenuIds())){
|
||||
List<String> menus=new ArrayList<>();
|
||||
if (tsRoleMenuData.getMenuIds().contains(",")){
|
||||
menus.addAll(new ArrayList<>(Arrays.asList(tsRoleMenuData.getMenuIds().split(","))));
|
||||
}else {
|
||||
menus.add(tsRoleMenuData.getMenuIds());
|
||||
}
|
||||
List<TsRoleMenuData> res=new ArrayList<>();
|
||||
menus.forEach(s -> {
|
||||
TsRoleMenuData tsRoleMenuData1=new TsRoleMenuData();
|
||||
tsRoleMenuData1.setRoleId(tsRoleMenuData.getRoleId());
|
||||
tsRoleMenuData1.setMenuId(s);
|
||||
res.add(tsRoleMenuData1);
|
||||
});
|
||||
iTsRoleMenuDataService.saveBatch(res);
|
||||
return Result.success();
|
||||
}else {
|
||||
return Result.error("请选择菜单");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("查询与角色绑定的菜单--支持多个角色查询")
|
||||
@GetMapping("/list")
|
||||
public ResponseMessage<Object> list(String ids){
|
||||
//判断disableFlag是否填入正确
|
||||
List<String> list=new ArrayList<>();
|
||||
if (ids.contains(",")){
|
||||
list.addAll(new ArrayList<>(Arrays.asList(ids.split(","))));
|
||||
}else {
|
||||
list.add(ids);
|
||||
}
|
||||
QueryWrapper<TsRoleMenuData> wrapper=new QueryWrapper<>();
|
||||
wrapper.in("ROLE_ID",list);
|
||||
List<TsRoleMenuData> tsRoleMenuData=iTsRoleMenuDataService.list(wrapper);
|
||||
return Result.success(tsRoleMenuData.stream().map(TsRoleMenuData::getMenuId).distinct().collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.adc.da.slrs.tsRoleMeunData.dao;
|
||||
|
||||
import com.adc.da.slrs.tsRoleMeunData.entity.TsRoleMenuData;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author yzh
|
||||
* @since 2022-03-16
|
||||
*/
|
||||
public interface TsRoleMenuDataDao extends BaseMapper<TsRoleMenuData> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.adc.da.slrs.tsRoleMeunData.entity;
|
||||
|
||||
import com.adc.da.base.entity.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author yzh
|
||||
* @since 2022-03-16
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="TsRoleMenuData对象", description="")
|
||||
public class TsRoleMenuData extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "角色id")
|
||||
@TableField("ROLE_ID")
|
||||
private String roleId;
|
||||
|
||||
@ApiModelProperty(value = "菜单id")
|
||||
@TableField("MENU_ID")
|
||||
private String menuId;
|
||||
|
||||
@ApiModelProperty(value = "菜单id")
|
||||
@TableField(exist = false)
|
||||
private String menuIds;
|
||||
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.adc.da.slrs.tsRoleMeunData.service;
|
||||
|
||||
import com.adc.da.slrs.tsRoleMeunData.entity.TsRoleMenuData;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author yzh
|
||||
* @since 2022-03-16
|
||||
*/
|
||||
public interface ITsRoleMenuDataService extends IService<TsRoleMenuData> {
|
||||
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.adc.da.slrs.tsRoleMeunData.service.impl;
|
||||
|
||||
import com.adc.da.slrs.tsRoleMeunData.entity.TsRoleMenuData;
|
||||
import com.adc.da.slrs.tsRoleMeunData.dao.TsRoleMenuDataDao;
|
||||
import com.adc.da.slrs.tsRoleMeunData.service.ITsRoleMenuDataService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author yzh
|
||||
* @since 2022-03-16
|
||||
*/
|
||||
@Service
|
||||
public class TsRoleMenuDataServiceImpl extends ServiceImpl<TsRoleMenuDataDao, TsRoleMenuData> implements ITsRoleMenuDataService {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user