package com.landtool.lanbase.modules.sys.controller;
|
|
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.modules.log.service.LogActionService;
|
import com.landtool.lanbase.modules.sys.entity.SysSysteminfoApply;
|
import com.landtool.lanbase.modules.sys.entity.SysSysteminfoApplyJoinOrgUser;
|
import com.landtool.lanbase.modules.sys.service.SysSysteminfoApplyService;
|
import io.swagger.annotations.Api;
|
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.*;
|
|
import java.sql.Timestamp;
|
import java.util.*;
|
import java.util.Date;
|
import java.util.HashMap;
|
import java.util.Map;
|
|
@RestController
|
@RequestMapping("/sys/systeminfoapply")
|
@Api(value = "", tags = {"应用程序查看权限申请表"})
|
public class SysSysteminfoApplyController extends AbstractController{
|
|
@Autowired
|
private SysSysteminfoApplyService sysSysteminfoApplyService;
|
@Autowired
|
private LogActionService actionService;
|
/**
|
* 列表
|
*/
|
@RequestMapping(value ="/list", method ={RequestMethod.POST, RequestMethod.GET})
|
// @RequiresPermissions("sys:systeminfo:list")
|
@RequiresPermissions(value = {"sys:systeminfo:list","sys:systeminfo:edit"}, logical = Logical.OR)
|
public Result list(@RequestParam Map<String, Object> params){
|
Query query = new Query(params);
|
List<SysSysteminfoApplyJoinOrgUser> list = sysSysteminfoApplyService.queryListByAppid(query);
|
Integer total = sysSysteminfoApplyService.queryTotalByAppid(query);
|
PageUtils pageUtil = new PageUtils(list, total, query.getLimit(), query.getPage());
|
return Result.ok().put("page", pageUtil);
|
}
|
|
/**
|
* 保存审核结果
|
*/
|
@ResponseBody
|
@RequestMapping("/saveresult")
|
public Result saveresult(Integer applyid,Integer auditresult,String auditopinion) {
|
int result = 0;
|
Timestamp audittime = new Timestamp(new Date().getTime());
|
// //此处要对当前用户身份进行判断
|
// Long userid= getUserId();
|
|
|
|
Map<String,Object> paramMap = new HashMap<String,Object>();
|
paramMap.put("id",applyid);
|
paramMap.put("auditresult",auditresult);
|
paramMap.put("auditopinion",auditopinion);
|
try {
|
result = sysSysteminfoApplyService.updateResult(paramMap);
|
}catch (Exception ex){
|
|
}
|
return Result.ok().put("result", result);
|
}
|
|
/**
|
* 保存审核结果
|
*/
|
@ResponseBody
|
@RequestMapping("/delRecord")
|
public Result delRecord(Integer applyid,Integer auditresult) {
|
int result = 0;
|
|
Map<String,Object> paramMap = new HashMap<String,Object>();
|
paramMap.put("id",applyid);
|
paramMap.put("auditresult",auditresult);
|
paramMap.put("auditopinion","审核");
|
try {
|
result = sysSysteminfoApplyService.updateResult(paramMap);
|
}catch (Exception ex){
|
|
}
|
return Result.ok().put("result", result);
|
}
|
/**
|
* 应用程序查看申请
|
*/
|
@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);
|
}
|
|
/**
|
* 应用程序查看申请
|
*/
|
@RequestMapping(value = "/applySystemPermissionForAdmin", method = {RequestMethod.GET}, produces = "application/json;charset=utf-8")
|
public Result applySystemPermissionForAdmin(Integer appid,Integer userid,String username) {
|
Map<String, Object> map = new HashMap<String, Object>();
|
map.put("appid", appid);
|
map.put("userid", actionService.queryUserId(username));
|
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);
|
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);
|
}
|
|
}
|