1
13693261870
2022-09-16 762f2fb45db004618ba099aa3c0bd89dba1eb843
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
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);
    }
 
}