package com.landtool.lanbase.modules.api.controller;
|
|
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSONObject;
|
import com.landtool.lanbase.common.utils.ComplexPropertyPreFilter;
|
import com.landtool.lanbase.common.utils.PageUtils;
|
import com.landtool.lanbase.common.utils.Query;
|
import com.landtool.lanbase.common.utils.Result;
|
import com.landtool.lanbase.config.SysTemPropertyConfig;
|
import com.landtool.lanbase.modules.sys.entity.SysDiyApp;
|
import com.landtool.lanbase.modules.sys.entity.SysSysteminfo;
|
import com.landtool.lanbase.modules.sys.entity.SysSysteminfoApply;
|
import com.landtool.lanbase.modules.sys.service.SysDiyAppService;
|
import com.landtool.lanbase.modules.sys.service.SysSysteminfoApplyService;
|
import com.landtool.lanbase.modules.sys.service.SysSysteminfoService;
|
|
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.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.io.IOException;
|
import java.net.URLDecoder;
|
import java.sql.Timestamp;
|
import java.time.LocalDateTime;
|
import java.util.*;
|
|
/**
|
* @Description: 应用程序模块提供的api
|
* @Author: zimao.guo
|
* @Date: 9:53 2018/1/31
|
*/
|
@Controller
|
@RequestMapping(path = "/api/sys/systeminfo/")
|
@Api(value = "", tags = {"应用程序相关接口"})
|
public class SysSysteminfoApiController {
|
|
@Autowired
|
private SysSysteminfoService systeminfoService;
|
@Autowired
|
private SysSysteminfoApplyService sysSysteminfoApplyService;
|
@Autowired
|
private SysDiyAppService sysDiyAppService;
|
|
@Autowired
|
private SysTemPropertyConfig sysProps;
|
|
/**
|
* @Description: 获取应用程序列表
|
*/
|
@GetMapping(path = "/queryTopList")
|
@ApiOperation(value = "获取应用程序列表", notes = "获取应用程序列表")
|
@ResponseBody
|
public void queryTopList(@ApiParam(name = "userid", value = "用户ID" ,required = true) @RequestParam(name = "userid") Integer userid,
|
@ApiParam(name = "num", value = "数量" ,required = true) @RequestParam(name = "num") Integer num,
|
@ApiParam(name = "type", value = "系统分类") @RequestParam(name = "type" , required = false) String type,
|
HttpServletResponse response, HttpServletRequest request) throws IOException {
|
ComplexPropertyPreFilter filter = new ComplexPropertyPreFilter();
|
Map<String, Object> map = new HashMap<>();
|
map.put("userid", userid);
|
map.put("num", num);
|
Map<String, Object> usermap = new HashMap<>();
|
usermap.put("userid", userid);
|
usermap.put("num", num);
|
if(type != null && type.length() != 0){
|
type =java.net.URLDecoder.decode(type);
|
}
|
usermap.put("type", type);
|
String typeStr = "";
|
List<String> typeList = new ArrayList<String>();;
|
if(type != null && type.length() !=0){
|
type = URLDecoder.decode(type,"UTF-8");
|
String[] typelist = type.split("\\,");
|
for (String t:typelist) {
|
if(typeStr.length()==0){
|
typeStr+="'"+t+"'";
|
}else{
|
typeStr+=",'"+t+"'";
|
}
|
typeList.add(t);
|
}
|
typeStr = type;
|
}
|
map.put("type", typeList);
|
List<SysSysteminfo> list;
|
list = systeminfoService.queryTopUserList(usermap);//获取用户设置应用程序
|
if(list.size() == 0) {
|
list = systeminfoService.queryTopList(map);
|
}
|
response.setHeader("Content-Type", "application/json;charset=UTF-8");
|
response.getWriter().write(JSONObject.toJSONString(list, filter));
|
}
|
|
/**
|
* @Description: 获取用户所属应用程序列表
|
* @Author: xiaoxuan.xie
|
* @Date: 09:30 2018/4/20
|
* @return: String
|
* @see SysSysteminfo
|
*/
|
@GetMapping(path = "/getSysListByUserId/{userid}")
|
@ApiOperation(value = "获取用户所属应用程序列表", notes = "")
|
public void GetMapUrlObject(@ApiParam(name = "userid", value = "用户Id", required = true) @PathVariable(name = "userid") Long userid, HttpServletResponse response, HttpServletRequest request) throws IOException {
|
ComplexPropertyPreFilter filter = new ComplexPropertyPreFilter();
|
List<SysSysteminfo> list = systeminfoService.getSysListByUserId(userid);
|
response.setHeader("Content-Type", "application/json;charset=UTF-8");
|
response.getWriter().write(JSONObject.toJSONString(list, filter));
|
}
|
|
/**
|
* @Description: 获取应用程序列表(排除用户设置系统导航显示)
|
* @Author: xiaoxuan.xie
|
* @Date: 18:00 2018/5/10
|
* @return: String
|
* @see SysSysteminfo
|
*/
|
@GetMapping(path = "/getSysListIgnoredUserId")
|
@ApiOperation(value = "获取应用程序列表(排除用户设置系统导航显示)", notes = "")
|
@ResponseBody
|
public String getSysListIgnoredUserId(@ApiParam(name = "userid", value = "用户Id", required = true) @RequestParam(name = "userid") Integer userid,
|
@ApiParam(name = "limit", value = "每页记录数", required = true) @RequestParam(name = "limit") Integer limit,
|
@ApiParam(name = "page", value = "当前页数", required = true) @RequestParam(name = "page") Integer page,
|
@ApiParam(name = "appfullname", value = "系统名称") String appfullname,
|
@ApiParam(name = "systype", value = "系统类型") String systype,
|
@ApiParam(name = "otherids", value = "应用系统ids") String otherids,
|
HttpServletResponse response, HttpServletRequest request) throws IOException {
|
Map<String, Object> params = new HashMap<>();
|
params.put("userid", userid);
|
params.put("limit", limit);
|
params.put("page", page);
|
if(appfullname != null && !appfullname.isEmpty()) {
|
params.put("appfullname", appfullname);
|
}
|
if(systype != null && !systype.isEmpty()) {
|
params.put("systype", systype);
|
}
|
if(otherids != null && !otherids.isEmpty()){
|
params.put("otherids",otherids);
|
}
|
Query query = new Query(params);
|
List<SysSysteminfo> systeminfoList = systeminfoService.getSysListIgnoredUserId(query);
|
int total = systeminfoService.querySysListIgnoredUserIdTotal(query);
|
|
PageUtils pageUtil = new PageUtils(systeminfoList, total, query.getLimit(), query.getPage());
|
|
StringBuilder rsb = new StringBuilder();
|
rsb.append("{'totalCount':'" + total);
|
rsb.append("','topics':[");
|
for (Integer i = 0; i < systeminfoList.size(); i++) {
|
if (i != 0) {
|
rsb.append(",");
|
}
|
rsb.append("{'appid':'" + systeminfoList.get(i).getAppid() + "'");//应用程序ID
|
rsb.append(",'appfullname':'" + systeminfoList.get(i).getAppfullname() + "'");//系统名称
|
rsb.append(",'apptype':'" + systeminfoList.get(i).getSystype() + "'");//系统类型
|
rsb.append("}");
|
}
|
rsb.append("]}");
|
|
return rsb.toString();
|
}
|
|
/**
|
* @Description: 设置用户显示应用程序
|
* @Author: xiaoxuan.xie
|
* @Date: 16:00 2018/5/11
|
* @return: String
|
* @see SysSysteminfo
|
*/
|
@GetMapping(path = "/addUserShowSystemInfo")
|
@ApiOperation(value = "设置用户显示应用程序", notes = "")
|
@ResponseBody
|
public String addUserShowSystemInfo(@ApiParam(name = "userid", value = "用户Id", required = true) @RequestParam(name = "userid") Integer userid,
|
@ApiParam(name = "appids", value = "应用程序IDs", required = true) @RequestParam(name = "appids") String appids,
|
@ApiParam(name = "type", value = "参数type") @RequestParam(name = "type" , required = false) String type,
|
HttpServletResponse response, HttpServletRequest request) throws IOException {
|
if(appids != null && appids.length() != 0){
|
String[] ids = appids.split("\\,");
|
for (String id:ids) {
|
SysDiyApp sysDiyApp = new SysDiyApp();
|
sysDiyApp.setAppid(Integer.parseInt(id));
|
sysDiyApp.setUserid(userid);
|
sysDiyApp.setOrderid(0);
|
if(type != null && type.length()!=0){
|
type =java.net.URLDecoder.decode(type);
|
}
|
sysDiyApp.setType(type);
|
sysDiyAppService.save(sysDiyApp);
|
}
|
}
|
return "新增成功";
|
}
|
|
/**
|
* @Description: 根据id获取应用程序信息
|
* @Author: dsh
|
* @Date: 2018-05-28
|
* @return: String
|
* @see SysSysteminfo
|
*/
|
@GetMapping(path = "/getSysteminfoById/{appid}")
|
@ApiOperation(value = "根据id获取应用程序信息", notes = "")
|
@ResponseBody
|
public String getSysteminfoById(@ApiParam(name = "appid", value = "appid", required = true) @PathVariable(name = "appid") Long appid){
|
StringBuilder rsb = new StringBuilder();
|
SysSysteminfo info = systeminfoService.getInfoById(appid);
|
Map<String,Object> map = new HashMap<>();
|
if(info != null){
|
map.put("appid", info.getAppid());
|
map.put("appfullname", info.getAppfullname());
|
map.put("apptype", info.getSystype());
|
map.put("sysaddress", info.getSysaddress());
|
map.put("maguser",info.getMaguser());
|
}
|
return JSON.toJSONString(map);
|
}
|
|
/**
|
* @Description: 获取全部应用程序列表
|
*/
|
@GetMapping(path = "/queryAllList")
|
@ApiOperation(value = "获取全部应用程序列表", notes = "获取全部应用程序列表")
|
@ResponseBody
|
public String queryAllList(@ApiParam(name = "sysstatus", value = "系统状态") Integer sysstatus,
|
@ApiParam(name = "iscaslogin", value = "集成单点登录") Integer iscaslogin,
|
@ApiParam(name = "appfullname", value = "系统名称") String appfullname,
|
@ApiParam(name = "systype", value = "系统类型") String systype,
|
HttpServletResponse response, HttpServletRequest request) throws IOException {
|
ComplexPropertyPreFilter filter = new ComplexPropertyPreFilter();
|
Map<String, Object> params = new HashMap<String,Object>();
|
if(appfullname != null && !appfullname.isEmpty()) {
|
params.put("appfullname", URLDecoder.decode(appfullname));
|
}
|
if(systype != null && !systype.isEmpty()) {
|
params.put("systype", systype);
|
}
|
if(sysstatus != null && sysstatus!=0) {
|
params.put("sysstatus", sysstatus);
|
}
|
if(iscaslogin != null) {
|
params.put("iscaslogin", iscaslogin);
|
}
|
params.put("isadmin", 1);//暂时先查全部
|
params.put("currentsystemid",sysProps.getCurrentSystemId());//过滤本系统
|
List<SysSysteminfo> list = systeminfoService.queryAllList(params);
|
StringBuilder rsb = new StringBuilder();
|
|
List<Map<String,Object>> maps = new LinkedList<>();
|
for (Integer i = 0; i < list.size(); i++) {
|
|
Map<String,Object> map = new HashMap<>();
|
map.put("appid",list.get(i).getAppid());
|
map.put("appfullname",list.get(i).getAppfullname());
|
map.put("appname",list.get(i).getAppname());
|
map.put("systype",list.get(i).getSystype());
|
map.put("chinesename",(list.get(i).getChinesename() != null ? list.get(i).getChinesename(): ""));
|
map.put("unitname",(list.get(i).getUnitname() != null ? list.get(i).getUnitname(): ""));
|
map.put("sysaddress",list.get(i).getSysaddress());
|
map.put("sysimgurl",list.get(i).getSysimgurl());
|
map.put("sysstatus",list.get(i).getSysstatus());
|
map.put("browser",list.get(i).getBrowser());
|
map.put("iscaslogin",list.get(i).getIscaslogin());
|
|
maps.add(map);
|
}
|
return JSON.toJSONString(maps);
|
}
|
|
/**
|
* @Description:
|
* @author ykm
|
* @param
|
* @return 应用程序ID数组
|
* @date 2019/03/12 14:13
|
*/
|
@GetMapping(path = "/getSysteminfoIdList")
|
@ApiOperation(value = "获取应用程序所有ID", notes = "")
|
@ResponseBody
|
public String getSysteminfoIdList(){
|
List<String> list = new LinkedList<>();
|
List<SysSysteminfo> systeminfoList = systeminfoService.queryListAll();
|
for(SysSysteminfo sysSysteminfo : systeminfoList) {
|
list.add(sysSysteminfo.getAppid().toString());
|
}
|
return list.toString();
|
}
|
|
|
@GetMapping(path = "/isAdmitSysByUserid")
|
@ApiOperation(value = "判断该services是否是用户能访问的系统", notes = "")
|
@ResponseBody
|
public boolean isAdmitSysByUserid(String service, String userid){
|
Map<String,Object> map=new HashMap<String, Object>();
|
map.put("userid", userid);
|
map.put("service", service);
|
int count = systeminfoService.isAdmitSysByUserid(map);
|
return count>0?true:false;
|
|
}
|
|
// /**
|
// * 接受访问申请
|
// * add by zhangshouxin 2021 2 25
|
// * @param userid 用户id
|
// * @param appid appid
|
// * @return
|
// */
|
// @GetMapping(path = "/applyAppAdmission")
|
// @ApiOperation(value = "申请开放用户访问应用系统", notes = "")
|
// @ResponseBody
|
// public String applyAppAdmission(Integer appid, Integer userid){
|
// Map<String,Object> map=new HashMap<String, Object>();
|
// map.put("userid", userid);
|
// map.put("appid", appid);
|
// //TODO 查询申请条目是否存在,若存在返回该申请已存在,否则进入申请流程
|
// SysSysteminfoApply existdata= sysSysteminfoApplyService.byId(map);
|
// if(existdata!=null||existdata.getId()>0){
|
// return "不可重复申请";
|
// }
|
// SysSysteminfoApply sysSysteminfoApply=new SysSysteminfoApply();
|
// sysSysteminfoApply.setAppid(appid);
|
// sysSysteminfoApply.setApplytime(Timestamp.valueOf(LocalDateTime.now()));
|
// sysSysteminfoApply.setUserid(userid);
|
// sysSysteminfoApply.setAuditresult(0);
|
// Integer result=sysSysteminfoApplyService.add(sysSysteminfoApply);
|
// return result>0?"申请成功":"申请失败";
|
//
|
// }
|
|
|
// /**
|
// * 应用程序查看申请
|
// */
|
// @RequestMapping(value = "/applySystemPermission", method = {RequestMethod.GET})
|
// public Result applySystemPermission(Integer appid) {
|
// Map<String, Object> map = new HashMap<String, Object>();
|
// Long userid = getUserId();
|
// map.put("appid", appid);
|
// map.put("userid", userid);
|
// SysSysteminfoApply sysSysteminfoApply = sysSysteminfoApplyService.byId(map);
|
// String result = "";
|
// if (sysSysteminfoApply != null) {
|
// //用户已申请
|
// if(sysSysteminfoApply.getAuditresult() == 0) {
|
// result = "已申请,管理员未批复!";
|
// } else if(sysSysteminfoApply.getAuditresult() == 1) {
|
// result = "管理员已通过申请,请重新尝试!";
|
// } else if(sysSysteminfoApply.getAuditresult() == 2) {
|
// result = "管理员已驳回申请,请联系管理员!驳回意见:" + sysSysteminfoApply.getAuditopinion();
|
// }
|
// } else {
|
// //用户未申请
|
// SysSysteminfoApply systeminfoApply = new SysSysteminfoApply();
|
// systeminfoApply.setAppid(appid);
|
// systeminfoApply.setUserid(userid.intValue());
|
// Timestamp audittime = new Timestamp(new Date().getTime());
|
// systeminfoApply.setApplytime(audittime);
|
// systeminfoApply.setAuditresult(0);//待批复
|
// int id = sysSysteminfoApplyService.add(systeminfoApply);
|
// result = "已通知管理员!";
|
// }
|
// return Result.ok().put("result", result);
|
// }
|
|
|
}
|