package com.landtool.lanbase.modules.api.controller;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;
|
import com.landtool.lanbase.modules.sys.entity.SysRole;
|
import com.landtool.lanbase.modules.sys.service.SysRoleService;
|
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiParam;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.servlet.http.HttpServletResponse;
|
import java.io.IOException;
|
import java.util.List;
|
|
/**
|
* @Description: 系统角色的api {@link com.landtool.lanbase.modules.sys.controller.SysRoleController}
|
* @Author: zimao.guo
|
* @Date: 11:37 2018/1/30
|
*
|
*/
|
@Controller
|
@RequestMapping(path="/api/sys/role")
|
@Api(value = "", tags = {"角色管理相关接口"})
|
public class SysRoleApiController {
|
|
@Autowired
|
private SysRoleService sysRoleService;
|
|
/**
|
* @Description: 根据appId查询所有角色 {@link SysRoleService}
|
* @Author: zimao.guo
|
* @Date: 13:37 2018/1/30
|
* @return: void
|
* @see Void
|
* @param appId
|
* @param response
|
*/
|
@GetMapping("/queryListByAppId/{appId}")
|
@ApiOperation(
|
value = "查询系统角色列表",
|
notes = ""
|
)
|
public void queryListByAppId(@ApiParam(name="appId",value="系统Id",required=true)
|
@PathVariable(name = "appId") Long appId,
|
HttpServletResponse response) throws IOException{
|
SimplePropertyPreFilter filter = new SimplePropertyPreFilter();
|
filter.getExcludes().add("totalOfUsers");
|
filter.getExcludes().add("systemName");
|
filter.getExcludes().add("rCreateDate");
|
filter.getExcludes().add("rCreateUser");
|
|
List<SysRole> roleList = sysRoleService.queryListByAppId(appId);
|
|
response.setHeader("Content-Type","application/json;charset=UTF-8");
|
response.getWriter().write(JSONObject.toJSONString(roleList,filter));
|
|
}
|
|
/**
|
* @Description: 根据appId和UserId来查询角色列表 {@link SysRoleService}
|
* @Author: zimao.guo
|
* @Date: 17:21 2018/1/30
|
* @return: void
|
* @see Void
|
* @param appId
|
* @param userId
|
* @param response
|
*/
|
@GetMapping("/queryListByUserId/{appId}/{userId}")
|
@ApiOperation(
|
value = "查询系统用户角色列表",
|
notes = ""
|
)
|
public void queryListByUserId(@ApiParam(name="appId",value="系统Id",required=true)
|
@PathVariable(name = "appId") Long appId,
|
@ApiParam(name="userId",value="用户Id",required=true)
|
@PathVariable(name ="userId")Long userId,
|
HttpServletResponse response) throws IOException{
|
|
SimplePropertyPreFilter filter = new SimplePropertyPreFilter();
|
filter.getExcludes().add("totalOfUsers");
|
filter.getExcludes().add("systemName");
|
filter.getExcludes().add("rCreateDate");
|
filter.getExcludes().add("rCreateUser");
|
|
List<SysRole> roleList = sysRoleService.queryListByUserId(appId,userId);
|
|
response.setHeader("Content-Type","application/json;charset=UTF-8");
|
response.getWriter().write(JSONObject.toJSONString(roleList,filter));
|
}
|
|
}
|