skyouc
2024-12-21 c635d78b479510ebe2556a420948effcd30a0731
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
package com.zy.asrs.common.sys.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zy.asrs.common.sys.entity.OperateLog;
import com.zy.asrs.common.sys.service.OperateLogService;
import com.zy.asrs.common.web.BaseController;
import com.zy.asrs.framework.annotations.ManagerAuth;
import com.zy.asrs.framework.common.Cools;
import com.zy.asrs.framework.common.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.*;
 
@RestController
public class OperateLogController extends BaseController {
 
    @Autowired
    private OperateLogService operateLogService;
 
    @RequestMapping(value = "/operateLog/{id}/auth")
    @ManagerAuth
    public R get(@PathVariable("id") Long id) {
        return R.ok(operateLogService.getById(String.valueOf(id)));
    }
 
    @RequestMapping(value = "/operateLog/page/auth")
    @ManagerAuth
    public R list(@RequestParam(defaultValue = "1")Integer curr,
                  @RequestParam(defaultValue = "10")Integer limit,
                  @RequestParam(required = false)String orderByField,
                  @RequestParam(required = false)String orderByType,
                  @RequestParam Map<String, Object> param){
        LambdaQueryWrapper<OperateLog> wrapper = new LambdaQueryWrapper<>();
        return R.ok(operateLogService.page(new Page<>(curr, limit), wrapper));
    }
 
    @RequestMapping(value = "/operateLog/edit/auth")
    @ManagerAuth
    public R edit(OperateLog operateLog) {
        if (Cools.isEmpty(operateLog)){
            return R.error();
        }
        if (null == operateLog.getId()){
            operateLogService.save(operateLog);
        } else {
            operateLogService.updateById(operateLog);
        }
        return R.ok();
    }
 
    @RequestMapping(value = "/operateLog/add/auth")
    @ManagerAuth
    public R add(OperateLog operateLog) {
        operateLogService.save(operateLog);
        return R.ok();
    }
 
    @RequestMapping(value = "/operateLog/update/auth")
    @ManagerAuth
    public R update(OperateLog operateLog){
        if (Cools.isEmpty(operateLog) || null==operateLog.getId()){
            return R.error();
        }
        operateLogService.updateById(operateLog);
        return R.ok();
    }
 
    @RequestMapping(value = "/operateLog/delete/auth")
    @ManagerAuth
    public R delete(Integer[] ids){
        if (Cools.isEmpty(ids)){
            return R.error();
        }
        operateLogService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }
 
    @RequestMapping(value = "/operateLogQuery/auth")
    @ManagerAuth
    public R query(String condition) {
        LambdaQueryWrapper<OperateLog> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(OperateLog::getAction, condition);
        Page<OperateLog> page = operateLogService.page(new Page<>(0, 10), wrapper);
        List<Map<String, Object>> result = new ArrayList<>();
        for (OperateLog operateLog : page.getRecords()){
            Map<String, Object> map = new HashMap<>();
            map.put("id", operateLog.getId());
            map.put("value", operateLog.getId());
            result.add(map);
        }
        return R.ok(result);
    }
 
}