xiaoyi
5 天以前 c9d4ba37c1f681b12e24014013fa9a28734bad42
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
package cn.iocoder.yudao.module.mes.controller.admin.pro.maintenancecalendar;
 
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.mes.controller.admin.pro.maintenancecalendar.vo.MesProMaintenanceCalendarPageReqVO;
import cn.iocoder.yudao.module.mes.controller.admin.pro.maintenancecalendar.vo.MesProMaintenanceCalendarRespVO;
import cn.iocoder.yudao.module.mes.controller.admin.pro.maintenancecalendar.vo.MesProMaintenanceCalendarSaveReqVO;
import cn.iocoder.yudao.module.mes.dal.dataobject.pro.maintenancecalendar.MesProMaintenanceCalendarDO;
import cn.iocoder.yudao.module.mes.service.pro.maintenancecalendar.MesProMaintenanceCalendarService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 
@Tag(name = "管理后台 - MES 电力运维日历")
@RestController
@RequestMapping("/mes/pro/maintenance-calendar")
@Validated
public class MesProMaintenanceCalendarController {
 
    @Resource
    private MesProMaintenanceCalendarService calendarService;
 
    @PostMapping("/create")
    @Operation(summary = "创建电力运维日历")
    @PreAuthorize("@ss.hasPermission('mes:pro-maintenance-calendar:create')")
    public CommonResult<Long> createCalendar(@Valid @RequestBody MesProMaintenanceCalendarSaveReqVO createReqVO) {
        return success(calendarService.createCalendar(createReqVO));
    }
 
    @PutMapping("/update")
    @Operation(summary = "更新电力运维日历")
    @PreAuthorize("@ss.hasPermission('mes:pro-maintenance-calendar:update')")
    public CommonResult<Boolean> updateCalendar(@Valid @RequestBody MesProMaintenanceCalendarSaveReqVO updateReqVO) {
        calendarService.updateCalendar(updateReqVO);
        return success(true);
    }
 
    @DeleteMapping("/delete")
    @Operation(summary = "删除电力运维日历")
    @Parameter(name = "ids", description = "编号数组", required = true)
    @PreAuthorize("@ss.hasPermission('mes:pro-maintenance-calendar:delete')")
    public CommonResult<Boolean> deleteCalendar(@RequestParam("ids") List<Long> ids) {
        calendarService.deleteCalendar(ids);
        return success(true);
    }
 
    @GetMapping("/get")
    @Operation(summary = "获得电力运维日历")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('mes:pro-maintenance-calendar:query')")
    public CommonResult<MesProMaintenanceCalendarRespVO> getCalendar(@RequestParam("id") Long id) {
        MesProMaintenanceCalendarDO calendar = calendarService.getCalendar(id);
        return success(calendar != null ? BeanUtils.toBean(calendar, MesProMaintenanceCalendarRespVO.class) : null);
    }
 
    @GetMapping("/page")
    @Operation(summary = "获得电力运维日历分页")
    @PreAuthorize("@ss.hasPermission('mes:pro-maintenance-calendar:query')")
    public CommonResult<PageResult<MesProMaintenanceCalendarRespVO>> getCalendarPage(@Valid MesProMaintenanceCalendarPageReqVO pageReqVO) {
        PageResult<MesProMaintenanceCalendarDO> pageResult = calendarService.getCalendarPage(pageReqVO);
        if (CollUtil.isEmpty(pageResult.getList())) {
            return success(PageResult.empty(pageResult.getTotal()));
        }
        return success(BeanUtils.toBean(pageResult, MesProMaintenanceCalendarRespVO.class));
    }
 
    @PutMapping("/publish")
    @Operation(summary = "发布电力运维日历")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('mes:pro-maintenance-calendar:update')")
    public CommonResult<Boolean> publishCalendar(@RequestParam("id") Long id) {
        calendarService.publishCalendar(id);
        return success(true);
    }
 
}