package com.landtool.lanbase.modules.sys.controller;
|
|
import com.alibaba.fastjson.JSONObject;
|
import com.landtool.lanbase.modules.sys.entity.SysSysteminfoApply;
|
import com.landtool.lanbase.modules.sys.service.SysSysteminfoApplyService;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiParam;
|
|
import java.io.IOException;
|
import java.util.*;
|
|
import org.apache.shiro.SecurityUtils;
|
import org.apache.shiro.authz.annotation.Logical;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import com.landtool.lanbase.modules.org.entity.OrgUser;
|
import com.landtool.lanbase.modules.org.service.OrgUserService;
|
import com.landtool.lanbase.modules.sys.entity.SysResource;
|
import com.landtool.lanbase.modules.sys.entity.SysSysteminfo;
|
import com.landtool.lanbase.modules.sys.service.SysSysteminfoService;
|
import com.landtool.lanbase.common.annotation.LogAction;
|
import com.landtool.lanbase.common.annotation.SysLog;
|
import com.landtool.lanbase.common.utils.PageUtils;
|
import com.landtool.lanbase.common.utils.Query;
|
import com.landtool.lanbase.common.utils.Result;
|
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
|
/**
|
* @author lanbase
|
* @Description: TODO(系统管理信息表)
|
* @date 2018-01-16 09:04:50
|
*/
|
@RestController
|
@RequestMapping("/sys/systeminfo")
|
@Api(value = "", tags = {"系统应用程序信息"})
|
public class SysSysteminfoController extends AbstractController{
|
|
@Autowired
|
private SysSysteminfoService systeminfoService;
|
|
@Autowired
|
private OrgUserService userService;
|
|
@Autowired
|
private SysSysteminfoApplyService sysSysteminfoApplyService;
|
|
/**
|
* 列表
|
*/
|
@LogAction("平台管理,应用程序管理,应用程序查询,查询")
|
@RequestMapping(value ="/list", method ={RequestMethod.POST, RequestMethod.GET})
|
// @RequiresPermissions("sys:systeminfo:list")
|
@RequiresPermissions(value = {"sys:systeminfo:list","sys:systeminfo:edit"}, logical = Logical.OR)
|
@ApiOperation(
|
value = "所有系统应用程序信息列表",
|
notes = ""
|
)
|
public Result list(@ApiParam(name="params",value="",required=true)@RequestParam Map<String, Object> params){
|
//查询列表数据
|
Set<String> permissions = userService.getUserPermissions(getUserId());
|
if(permissions.contains("org_user_admin")){//管理员可以查看所有应用程序
|
params.put("isadmin", 1);
|
}
|
else{//主管单位下的用户 or主管单位的单位管理员 为自己 or 自己录的应用程序 or 系统负责人为自己的应用程序
|
params.put("isadmin", 0);
|
}
|
OrgUser orgUser = (OrgUser) SecurityUtils.getSubject().getPrincipal();
|
params.put("userid", orgUser.getUserid());
|
Query query = new Query(params);
|
List<SysSysteminfo> systeminfoList = systeminfoService.queryList(query);
|
List<SysSysteminfo> list = new ArrayList<SysSysteminfo>();
|
for(int i = 0; i < systeminfoList.size(); i++) {
|
systeminfoList.get(i).setSystype(getSystemName(systeminfoList.get(i).getSystype()));
|
systeminfoList.get(i).setApplycount(sysSysteminfoApplyService.selectCount(systeminfoList.get(i).getAppid().intValue(),0));
|
systeminfoList.get(i).setAudityescount(sysSysteminfoApplyService.selectCount(systeminfoList.get(i).getAppid().intValue(),1));
|
systeminfoList.get(i).setAuditnocount(sysSysteminfoApplyService.selectCount(systeminfoList.get(i).getAppid().intValue(),2));
|
list.add(systeminfoList.get(i));
|
}
|
int total = systeminfoService.queryTotal(query);
|
|
PageUtils pageUtil = new PageUtils(list, total, query.getLimit(), query.getPage());
|
|
return Result.ok().put("page", pageUtil);
|
}
|
|
//获取系统中文名称
|
private String getSystemName(String name) {
|
String SystemName = name;
|
if(name.equals("haiyu")) {
|
SystemName = "海域";
|
}
|
if(name.equals("zonghe")) {
|
SystemName = "综合";
|
}
|
if(name.equals("haidao")) {
|
SystemName = "海岛";
|
}
|
if(name.equals("jingji")) {
|
SystemName = "经济";
|
}
|
if(name.equals("huangjing")) {
|
SystemName = "环境";
|
}
|
if(name.equals("zhifa")) {
|
SystemName = "执法";
|
}
|
if(name.equals("yubaojianzai")) {
|
SystemName = "预报减灾";
|
}
|
|
if(name.equals("huanjinganquan")) {
|
SystemName = "环境安全";
|
}
|
|
return SystemName;
|
}
|
|
/**
|
* 信息
|
*/
|
@GetMapping("/info/{appid}")
|
// @RequiresPermissions("sys:systeminfo:list")
|
@RequiresPermissions(value = {"sys:systeminfo:list","sys:systeminfo:edit"}, logical = Logical.OR)
|
@ApiOperation(
|
value = "所有应用程序信息",
|
notes = ""
|
)
|
public Result info(@ApiParam(name="appid",value="appId",required=true)@PathVariable("appid") Long appid){
|
SysSysteminfo systeminfo = systeminfoService.queryObject(appid);
|
|
return Result.ok().put("systeminfo", systeminfo);
|
}
|
|
/**
|
* 保存
|
*/
|
@LogAction("平台管理,应用程序管理,应用程序新增,新增")
|
@PostMapping("/save")
|
@RequiresPermissions("sys:systeminfo:edit")
|
@ApiOperation(
|
value = "保存系统应用程序信息",
|
notes = ""
|
)
|
public Result save(@ApiParam(name="应用程序信息对象",value="传入json格式",required=true)@RequestBody SysSysteminfo systeminfo){
|
if(systeminfo.getAppfullname() == null || systeminfo.getAppfullname().length() == 0 || systeminfo.getAppname() == null ||
|
systeminfo.getAppname().length() == 0 || systeminfo.getSysaddress() == null || systeminfo.getSysaddress().length() == 0){
|
return Result.error("保存失败,存在特殊字符,请重新输入!");
|
}
|
OrgUser orgUser = (OrgUser) SecurityUtils.getSubject().getPrincipal();
|
systeminfo.setRcreateuser(orgUser.getUserid());
|
if(systeminfo.getAppname()==null || systeminfo.getAppname()==""){
|
systeminfo.setAppname(systeminfo.getAppfullname());
|
}
|
int orderid = systeminfoService.queryMaxOrderid()+1;
|
systeminfo.setOrderid(orderid);
|
systeminfoService.save(systeminfo);
|
|
//保存完后获取对应appid
|
int appid = systeminfoService.querySysteminfoWithSEQ();
|
return Result.ok().put("appid",appid);
|
}
|
|
/**
|
* 修改
|
*/
|
@LogAction("平台管理,应用程序管理,应用程序修改,修改")
|
@PostMapping("/update")
|
@RequiresPermissions("sys:systeminfo:edit")
|
@ApiOperation(
|
value = "修改系统应用程序信息",
|
notes = ""
|
)
|
public Result update(@ApiParam(name="应用程序信息对象",value="传入json格式",required=true)@RequestBody SysSysteminfo systeminfo){
|
if(systeminfo.getAppfullname() == null || systeminfo.getAppfullname().length() == 0 || systeminfo.getAppname() == null ||
|
systeminfo.getAppname().length() == 0 || systeminfo.getSysaddress() == null || systeminfo.getSysaddress().length() == 0){
|
return Result.error("保存失败,存在特殊字符,请重新输入!");
|
}
|
if(systeminfo.getAppname()==null || systeminfo.getAppname()==""){
|
systeminfo.setAppname(systeminfo.getAppfullname());
|
}
|
systeminfoService.update(systeminfo);
|
|
return Result.ok();
|
}
|
|
/**
|
* 删除
|
*/
|
@LogAction("平台管理,应用程序管理,应用程序删除,删除")
|
@PostMapping("/delete")
|
@RequiresPermissions("sys:systeminfo:edit")
|
@ApiOperation(
|
value = "删除系统应用程序信息",
|
notes = ""
|
)
|
public Result delete(@ApiParam(name="appids",value="appId",required=true)@RequestBody Long[] appids){
|
systeminfoService.deleteBatch(appids);
|
|
return Result.ok();
|
}
|
|
/**
|
* 显示系统信息
|
*/
|
@SysLog("显示系统信息")
|
@GetMapping("/queryListAll")
|
@ApiOperation(
|
value = "显示系统信息",
|
notes = ""
|
)
|
public Map<String, Object> queryListAll(){
|
Map<String, Object> map = new HashMap<String,Object>();
|
List<SysSysteminfo> systemList = systeminfoService.queryListAll();
|
map.put("systemList", systemList);
|
return map;
|
}
|
|
/**
|
* 所有系统应用程序信息列表
|
*/
|
@RequestMapping(value ="/queryAllList", method ={RequestMethod.GET})
|
// @RequiresPermissions("sys:systeminfo:list")
|
@RequiresPermissions(value = {"sys:systeminfo:list","sys:systeminfo:edit"}, logical = Logical.OR)
|
public Result queryAllList(){
|
Map<String, Object> params = new HashMap<String,Object>();
|
//查询列表数据
|
Set<String> permissions = userService.getUserPermissions(getUserId());
|
if(permissions.contains("org_user_admin")){//管理员可以查看所有应用程序
|
params.put("isadmin", 1);
|
}
|
else{//主管单位下的用户 or主管单位的单位管理员 为自己 or 自己录的应用程序 or 系统负责人为自己的应用程序
|
params.put("isadmin", 0);
|
}
|
List<SysSysteminfo> systeminfoList = systeminfoService.queryAllList(params);
|
return Result.ok().put("systeminfoList", systeminfoList);
|
}
|
|
/**
|
* 修改排序
|
*/
|
@LogAction("平台管理,应用程序管理,应用程序排序修改,修改")
|
@PostMapping("/updateRorder")
|
@RequiresPermissions("sys:systeminfo:edit")
|
@ApiOperation(
|
value = "修改排序",
|
notes = ""
|
)
|
public Result updateRorder(@ApiParam(name="复合对象",value="传入json格式",required=true)@RequestBody JSONObject json){
|
String appids = json.getString("appids");
|
// String sorts = json.getString("sorts");
|
String[] appidList = appids.split(",");
|
// String[] sortList=sorts.split(",");
|
for(int i =0;i<appidList.length;i++){
|
SysSysteminfo info = new SysSysteminfo();
|
info.setAppid(Long.parseLong(appidList[i]));
|
// info.setOrderid(Integer.parseInt(sortList[i]));
|
info.setOrderid(i);
|
systeminfoService.updateRorder(info);
|
}
|
return Result.ok();
|
}
|
|
@GetMapping("/getNavigAtionShowCount")
|
public Integer getNavigAtionShowCount(Integer appid){
|
Integer result = 0;
|
try {
|
result = systeminfoService.queryNavigAtionShowCount(appid);
|
}catch (Exception ex){
|
|
}
|
return result;
|
}
|
}
|