New file |
| | |
| | | package com.kidgrow.usercenter.controller; |
| | | |
| | | import java.util.Map; |
| | | |
| | | import com.kidgrow.common.annotation.LoginUser; |
| | | import com.kidgrow.common.constant.SecurityConstants; |
| | | import com.kidgrow.common.controller.BaseController; |
| | | import com.kidgrow.usercenter.dto.SysRoleOrganizationDto; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import com.kidgrow.usercenter.model.SysRoleOrganization; |
| | | import com.kidgrow.usercenter.service.ISysRoleOrganizationService; |
| | | import com.kidgrow.common.model.*; |
| | | |
| | | import org.springframework.validation.BindingResult; |
| | | import org.springframework.validation.ObjectError; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.validation.Valid; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * @Description: 角色对应的 部门 |
| | | * @Project: 用户中心 |
| | | * @CreateDate: Created in 2020-04-21 14:24:41 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | * @version: 1.0 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/sysroleorganization") |
| | | @Api(tags = "角色对应的 部门") |
| | | public class SysRoleOrganizationController extends BaseController{ |
| | | @Autowired |
| | | private ISysRoleOrganizationService sysRoleOrganizationService; |
| | | |
| | | /** |
| | | * 列表 |
| | | */ |
| | | @ApiOperation(value = "查询列表") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "page", value = "分页起始位置", required = true, dataType = "Integer"), |
| | | @ApiImplicitParam(name = "limit", value = "分页结束位置", required = true, dataType = "Integer") |
| | | }) |
| | | @GetMapping |
| | | public ResultBody<PageResult> list(@RequestParam Map<String, Object> params) { |
| | | if(params.size()==0){ |
| | | params.put("page",1); |
| | | params.put("limit",10); |
| | | } |
| | | return ResultBody.ok().data(sysRoleOrganizationService.findList(params)); |
| | | } |
| | | |
| | | /** |
| | | * 查询 |
| | | */ |
| | | @ApiOperation(value = "查询") |
| | | @GetMapping("/{id}") |
| | | public ResultBody findById(@PathVariable Long id) { |
| | | SysRoleOrganization model = sysRoleOrganizationService.getById(id); |
| | | return ResultBody.ok().data(model).msg("查询成功"); |
| | | } |
| | | |
| | | /** |
| | | * 根据SysRoleOrganization当做查询条件进行查询 |
| | | */ |
| | | @ApiOperation(value = "根据SysRoleOrganization当做查询条件进行查询") |
| | | @PostMapping("/query") |
| | | public ResultBody findByObject(@RequestBody SysRoleOrganization sysRoleOrganization) { |
| | | SysRoleOrganization model = sysRoleOrganizationService.findByObject(sysRoleOrganization); |
| | | return ResultBody.ok().data(model).msg("查询成功"); |
| | | } |
| | | |
| | | /** |
| | | * 新增or更新 |
| | | */ |
| | | @ApiOperation(value = "保存") |
| | | @PostMapping |
| | | public ResultBody save(@Valid @RequestBody SysRoleOrganizationDto sysRoleOrganizationDto, BindingResult bindingResult, @LoginUser SysUser user, HttpServletRequest request) { |
| | | List<String> errMsg= new ArrayList<>(); |
| | | String header = request.getHeader(SecurityConstants.USER_ORG_ID_HEADER); |
| | | if (bindingResult.hasErrors()) { |
| | | for (ObjectError error : bindingResult.getAllErrors()) { |
| | | errMsg.add(error.getDefaultMessage()); |
| | | } |
| | | return ResultBody.failed().msg(errMsg.toString()); |
| | | } else { |
| | | boolean v= sysRoleOrganizationService.saveOrUpdateSer(sysRoleOrganizationDto,user); |
| | | if(v) { |
| | | return ResultBody.ok().data(sysRoleOrganizationDto).msg("保存成功"); |
| | | } |
| | | else { |
| | | return ResultBody.failed().msg("保存失败"); |
| | | } |
| | | } |
| | | } |
| | | @ApiOperation(value = "获取tree") |
| | | @GetMapping("getTree") |
| | | public ResultBody getTree(@RequestParam Map<String, Object> params,@LoginUser SysUser user) { |
| | | return sysRoleOrganizationService.getTree(params,user); |
| | | } |
| | | @ApiOperation(value = "获取数据权限的map") |
| | | @PostMapping("getRoleOrg") |
| | | public Map<String, Object> getRoleOrgMap(@RequestBody List<SysRole> list) { |
| | | SysUser user=new SysUser(); |
| | | user.setRoles(list); |
| | | return sysRoleOrganizationService.getRoleOrgMap(user); |
| | | } |
| | | |
| | | /** |
| | | * 删除 |
| | | */ |
| | | @ApiOperation(value = "删除") |
| | | @DeleteMapping("/{id}") |
| | | public ResultBody delete(@PathVariable Long id) { |
| | | boolean v= sysRoleOrganizationService.removeById(id); |
| | | if(v) { |
| | | return ResultBody.ok().msg("删除成功"); |
| | | } |
| | | else { |
| | | return ResultBody.failed().msg("删除失败"); |
| | | } |
| | | } |
| | | } |