package org.jeecg.modules.dnc.controller;
|
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.extern.slf4j.Slf4j;
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
import org.jeecg.modules.dnc.entity.Button;
|
import org.jeecg.modules.dnc.request.ButtonRequest;
|
import org.jeecg.modules.dnc.response.CommonCode;
|
import org.jeecg.modules.dnc.response.QueryListResponseResult;
|
import org.jeecg.modules.dnc.response.QueryPageResponseResult;
|
import org.jeecg.modules.dnc.response.ResponseResult;
|
import org.jeecg.modules.dnc.service.IButtonService;
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
import org.jeecgframework.poi.excel.entity.ExportParams;
|
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.servlet.ModelAndView;
|
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import java.util.Collections;
|
import java.util.List;
|
|
@Slf4j
|
@Api(tags = "按钮管理")
|
@RestController
|
@RequestMapping("/ucenter/btn")
|
public class ButtonController {
|
@Autowired
|
private IButtonService buttonService;
|
|
@AutoLog(value = "按钮管理-新增按钮对象")
|
@ApiOperation(value = "按钮管理-新增按钮对象", notes = "按钮管理-新增按钮对象")
|
@PostMapping("/add")
|
public ResponseResult addButton(@RequestBody Button button) {
|
boolean b = buttonService.addButton(button);
|
if(b) {
|
return new ResponseResult(CommonCode.SUCCESS);
|
}
|
return new ResponseResult(CommonCode.FAIL);
|
}
|
|
@AutoLog(value = "按钮管理-根据按钮类型查询按钮列表")
|
@ApiOperation(value = "按钮管理-根据按钮类型查询按钮列表", notes = "按钮管理-根据按钮类型查询按钮列表")
|
@GetMapping("/find/list")
|
public QueryListResponseResult<Button> findByButtonType(@RequestParam("buttonType") Integer buttonType) {
|
List<Button> list = buttonService.findByButtonType(buttonType);
|
if(list == null)
|
list = Collections.emptyList();
|
return new QueryListResponseResult<>(CommonCode.SUCCESS, list);
|
}
|
|
@AutoLog(value = "按钮管理-分页列表查询")
|
@ApiOperation(value = "按钮管理-分页列表查询", notes = "按钮管理-分页列表查询")
|
@GetMapping("/find/page/{page}/{size}")
|
public QueryPageResponseResult<Button> findByPageList(@PathVariable("page") int page, @PathVariable("size") int size, ButtonRequest buttonRequest) {
|
return buttonService.findByPageList(page, size, buttonRequest);
|
}
|
|
@AutoLog(value = "按钮管理-编辑按钮")
|
@ApiOperation(value = "按钮管理-编辑按钮", notes = "按钮管理-编辑按钮")
|
@PutMapping("/edit/{id}")
|
public ResponseResult editButton(@PathVariable("id") String id,@RequestBody Button button) {
|
boolean b = buttonService.editButton(id,button);
|
if(b) {
|
return new ResponseResult(CommonCode.SUCCESS);
|
}
|
return new ResponseResult(CommonCode.FAIL);
|
}
|
|
@AutoLog(value = "按钮管理-删除按钮")
|
@ApiOperation(value = "按钮管理-删除按钮", notes = "按钮管理-删除按钮")
|
@DeleteMapping("/delete")
|
public ResponseResult deleteButton(@RequestParam("id") String id) {
|
boolean b = buttonService.deleteButtonById(id);
|
if(b) {
|
return new ResponseResult(CommonCode.SUCCESS);
|
}
|
return new ResponseResult(CommonCode.FAIL);
|
}
|
|
@AutoLog(value = "按钮管理-查询角色分配和未分配的系统按钮")
|
@ApiOperation(value = "按钮管理-查询角色分配和未分配的系统按钮", notes = "按钮管理-查询角色分配和未分配的系统按钮")
|
@GetMapping("/get/role")
|
public QueryListResponseResult<Button> findPermsByRoleId(@RequestParam("roleId") String roleId) {
|
List<Button> list = buttonService.findPermsByRoleId(roleId);
|
if(list == null)
|
list = Collections.emptyList();
|
return new QueryListResponseResult<>(CommonCode.SUCCESS, list);
|
}
|
|
@AutoLog(value = "按钮管理-获取菜单分配的按钮列表 包含未分配按钮")
|
@ApiOperation(value = "按钮管理-获取菜单分配的按钮列表 包含未分配按钮", notes = "按钮管理-获取菜单分配的按钮列表 包含未分配按钮")
|
@GetMapping("/get/menu")
|
public QueryListResponseResult<Button> findByMenuId(@RequestParam("menuId") String menuId) {
|
List<Button> list = buttonService.findByMenuId(menuId);
|
if(list == null)
|
list = Collections.emptyList();
|
return new QueryListResponseResult<>(CommonCode.SUCCESS, list);
|
}
|
|
@AutoLog(value = "按钮管理-获取对象分配的按钮列表 包含未分配按钮")
|
@ApiOperation(value = "按钮管理-获取对象分配的按钮列表 包含未分配按钮", notes = "按钮管理-获取对象分配的按钮列表 包含未分配按钮")
|
@GetMapping("/get/object")
|
public QueryListResponseResult<Button> findByObjectId(@RequestParam("objectId") String objectId) {
|
List<Button> list = buttonService.findByObjectId(objectId);
|
if(list == null)
|
list = Collections.emptyList();
|
return new QueryListResponseResult<>(CommonCode.SUCCESS, list);
|
}
|
|
@AutoLog(value = "按钮管理-导出自定义")
|
@ApiOperation(value = "按钮管理-导出自定义", notes = "按钮管理-导出自定义")
|
@GetMapping("/exportXls")
|
public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
|
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
List<Button> list = buttonService.list();
|
//mv.addObject(NormalExcelConstants.FILE_NAME,"导出Excel文件名字");
|
//注解对象Class
|
mv.addObject(NormalExcelConstants.CLASS,Button.class);
|
//自定义导出字段
|
//mv.addObject(NormalExcelConstants.EXPORT_FIELDS,"name,keyWord,punchTime");
|
//自定义表格参数
|
mv.addObject(NormalExcelConstants.PARAMS,new ExportParams("自定义导出Excel模板内容标题", "自定义Sheet名字"));
|
//导出数据列表
|
mv.addObject(NormalExcelConstants.DATA_LIST,list);
|
return mv;
|
}
|
}
|