hyingbo
7 天以前 cc0e9036de6e922e8fe254fef01d8de9996024b7
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
157
158
159
160
161
162
163
package org.jeecg.modules.mdc.controller;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.mdc.entity.MdcVacationManagement;
import org.jeecg.modules.mdc.service.IMdcVacationManagementService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
/**
 * @Description: 假期管理
 * @Author: ym
 * @Date: 2023-07-05
 */
@Slf4j
@RestController
@Api(tags = "假期管理")
@RequestMapping("/mdc/mdcVacationManagement")
public class MdcVacationManagementController extends JeecgController<MdcVacationManagement, IMdcVacationManagementService> {
 
    @Resource
    private IMdcVacationManagementService mdcVacationManagementService;
 
    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    @AutoLog(value = "假期管理-根据id查询")
    @ApiOperation(value = "假期管理-根据id查询", notes = "假期管理-根据id查询")
    @GetMapping("/queryById")
    public Result<?> queryById(@RequestParam(required = true, name = "id") String id) {
        MdcVacationManagement mdcVacationManagement = mdcVacationManagementService.queryById(id);
        //查询不为空则返回数据
        return null != mdcVacationManagement ? Result.OK(mdcVacationManagement) : Result.error("未找到对应数据");
    }
 
    /**
     * 新增
     *
     * @param mdcVacationManagement
     * @return
     */
    @AutoLog(value = "假期管理-新增")
    @ApiOperation(value = "假期管理-新增", notes = "假期管理-新增")
    @PostMapping("/addVacation")
    public Result<?> addVacation(@RequestBody MdcVacationManagement mdcVacationManagement) {
        if (StringUtils.isBlank(mdcVacationManagement.getEquipmentIds())) {
            return Result.error("未选择设备,请排查");
        }
        boolean flag = mdcVacationManagementService.addVacation(mdcVacationManagement);
        return flag ? Result.ok("新增成功") : Result.error("新增失败");
    }
 
    /**
     * 修改
     *
     * @param mdcVacationManagement
     * @return
     */
    @AutoLog(value = "假期管理-修改")
    @ApiOperation(value = "假期管理-修改", notes = "假期管理-修改")
    @PutMapping("/editVacation")
    public Result<?> editVacation(@RequestBody MdcVacationManagement mdcVacationManagement) {
        boolean flag = mdcVacationManagementService.editVacation(mdcVacationManagement);
        return flag ? Result.ok("修改成功") : Result.error("修改失败");
    }
 
    /**
     * 根据id删除假期管理
     *
     * @param id
     * @return
     */
    @AutoLog(value = "假期管理-根据id删除")
    @ApiOperation(value = "假期管理-根据id删除", notes = "假期管理-根据id删除")
    @DeleteMapping("/deleteVacation")
    public Result<?> deleteVacation(@RequestParam(required = true, name = "id") String id) {
        boolean flag = mdcVacationManagementService.deleteVacation(id);
        return flag ? Result.ok("删除成功") : Result.error("删除失败");
    }
 
    /**
     * 批量删除
     *
     * @param ids
     * @return
     */
    @AutoLog(value = "假期管理-批量删除")
    @ApiOperation(value = "假期管理-批量删除", notes = "假期管理-批量删除")
    @DeleteMapping("/deleteBatchVacation")
    public Result<?> deleteBatchVacation(@RequestParam(required = true, name = "ids") String ids) {
        boolean flag = mdcVacationManagementService.deleteBatchVacation(ids);
        return flag ? Result.ok("批量删除成功") : Result.error("批量删除失败");
    }
 
    /**
     * 导出excel
     *
     * @param request
     * @param mdcVacationManagement
     * @return
     */
    @AutoLog(value = "假期管理-导出excel")
    @ApiOperation(value = "假期管理-导出excel",notes = "假期管理-导出excel")
    @RequestMapping("/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, MdcVacationManagement mdcVacationManagement) {
        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        String userId = user.getId();
        return mdcVacationManagementService.exportXls(userId, mdcVacationManagement);
    }
 
    /**
     * 导入excel
     *
     * @param request
     * @param response
     * @return
     */
    @RequestMapping("/importExcel")
    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
        return super.importExcel(request, response, MdcVacationManagement.class);
    }
 
    /**
     * 分页查询
     * @param mdcVacationManagement
     * @param pageNo
     * @param pageSize
     * @param request
     * @return
     */
    @AutoLog(value = "假期管理-分页查询")
    @ApiOperation(value = "假期管理-分页查询",notes = "假期管理-分页查询")
    @GetMapping("/pageList")
    public Result<?> pageList(MdcVacationManagement mdcVacationManagement,
                              @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                              @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                              HttpServletRequest request) {
        if (mdcVacationManagement == null) {
            return Result.error("请传递有效参数");
        }
        LoginUser user=(LoginUser) SecurityUtils.getSubject().getPrincipal();
        String userId= user.getId();
        Page page=new Page(pageNo,pageSize);
        IPage<MdcVacationManagement> mdcVacationManagementIPage= mdcVacationManagementService.pageList(userId,page,request,mdcVacationManagement);
        return Result.ok(mdcVacationManagementIPage);
    }
}