package com.landtool.lanbase.modules.api.controller;
|
|
import java.io.IOException;
|
import java.util.List;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import com.landtool.lanbase.modules.sys.entity.SysResource;
|
import com.landtool.lanbase.modules.sys.service.SysResourceService;
|
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiParam;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
@Controller
|
@RequestMapping(path="/api/sys/resource")
|
@Api(value = "", tags = {"资源管理相关接口"})
|
public class SysResourceApiController {
|
@Autowired
|
private SysResourceService sysResourceService;
|
|
/*
|
* 查询资源信息
|
*/
|
|
@GetMapping("/getInfoById/{resourceid}")
|
@ApiOperation(
|
value = "查询资源信息",
|
notes = ""
|
)
|
public void getInfoById(@ApiParam(name="resourceid",value="资源Id",required=true)
|
@PathVariable(name = "resourceid") Long resourceid,
|
HttpServletResponse response) throws IOException {
|
SimplePropertyPreFilter filter = new SimplePropertyPreFilter();
|
filter.getExcludes().add("rcreatedate");
|
filter.getExcludes().add("rcreateuser");
|
|
response.setHeader("Content-Type","application/json;charset=UTF-8");
|
response.getWriter().write(JSONObject.toJSONString(sysResourceService.getInfoById(resourceid),filter));
|
}
|
|
/*
|
* 查询系统对应资源列表
|
*/
|
|
@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("rcreatedate");
|
filter.getExcludes().add("rcreateuser");
|
|
response.setHeader("Content-Type","application/json;charset=UTF-8");
|
response.getWriter().write(JSONObject.toJSONString(sysResourceService.queryListByAppId(appId),filter));
|
}
|
|
/*
|
* 查询角色对应资源列表
|
*/
|
|
@GetMapping("/queryListByRoldId/{roleId}")
|
@ApiOperation(
|
value = "查询角色对应资源列表",
|
notes = ""
|
)
|
public void queryListByRoldId (@ApiParam(name="roleId",value="角色Id",required=true)
|
@PathVariable(name = "roleId") Long roleId,
|
HttpServletResponse response) throws IOException {
|
SimplePropertyPreFilter filter = new SimplePropertyPreFilter();
|
filter.getExcludes().add("rcreatedate");
|
filter.getExcludes().add("rcreateuser");
|
|
response.setHeader("Content-Type","application/json;charset=UTF-8");
|
response.getWriter().write(JSONObject.toJSONString(sysResourceService.queryListByRoldId(roleId),filter));
|
|
}
|
/*
|
* 查询某个系统用户对应资源列表
|
*/
|
@GetMapping("/queryListByUserIdAndAppId/{appId}/{userId}")
|
@ApiOperation(
|
value = "查询某个系统用户对应资源列表",
|
notes = ""
|
)
|
public void queryListByUserIdAndAppId (@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("rcreatedate");
|
filter.getExcludes().add("rcreateuser");
|
|
response.setHeader("Content-Type","application/json;charset=UTF-8");
|
response.getWriter().write(JSONObject.toJSONString(sysResourceService.queryListByUserId(appId, userId),filter));
|
|
}
|
|
/*
|
* 查询某个系统用户对应资源列表
|
*/
|
@GetMapping("/queryListByUserId/{userId}")
|
@ApiOperation(
|
value = "查询某个用户对应资源列表",
|
notes = ""
|
)
|
public void queryListByUserId (@ApiParam(name="userId",value="用户Id",required=true)
|
@PathVariable(name = "userId") Long userId,
|
HttpServletResponse response) throws IOException {
|
SimplePropertyPreFilter filter = new SimplePropertyPreFilter();
|
filter.getExcludes().add("rcreatedate");
|
filter.getExcludes().add("rcreateuser");
|
|
response.setHeader("Content-Type","application/json;charset=UTF-8");
|
response.getWriter().write(JSONObject.toJSONString(sysResourceService.queryResources(userId),filter));
|
|
}
|
}
|