xuhy
2024-10-23 815ea3a4565daf9bb9053e0140aa7fd4a177e809
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
package com.ruoyi.chargingPile.controller;
 
 
import com.ruoyi.chargingPile.api.model.TFaultMessage;
import com.ruoyi.chargingPile.api.model.TRepair;
import com.ruoyi.chargingPile.service.TRepairService;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.BasePage;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.log.enums.OperatorType;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.feignClient.SysUserClient;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;
 
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xiaochen
 * @since 2024-08-08
 */
@RestController
@RequestMapping("/t-repair")
public class TRepairController {
 
    @Resource
    private TRepairService repairService;
    @Resource
    private TokenService tokenService;
    @Autowired
    private SysUserClient userClient;
 
    /**
     * 添加故障报修管理
     */
    @Log(title = "添加故障报修管理", businessType = BusinessType.INSERT,operatorType = OperatorType.MOBILE)
    @ApiOperation(tags = {"小程序-故障报修"},value = "添加故障报修管理")
    @PostMapping(value = "/add")
    public AjaxResult<String> add(@Validated @RequestBody TRepair dto) {
        Long userId = tokenService.getLoginUserApplet().getUserId();
        // 查询报修人员信息
        SysUser user = userClient.getSysUser(userId).getData();
        if(Objects.nonNull(user)){
            dto.setRepairman(user.getUserName());
        }
        repairService.add(dto);
        return AjaxResult.success();
    }
    
    @ResponseBody
    @GetMapping("/getRepairList")
    @ApiOperation(value = "获取报修记录列表数据", tags = {"管理后台-设备监控"})
    public AjaxResult<PageInfo<TRepair>> getRepairList(String name, String siteId, BasePage basePage){
        PageInfo<TRepair> pageInfo = new PageInfo<>(basePage.getPageCurr(), basePage.getPageSize());
        List<TRepair> repairList = repairService.getRepairList(pageInfo, name, siteId);
        pageInfo.setRecords(repairList);
        return AjaxResult.success(pageInfo);
    }
    
    
    
    
    @ResponseBody
    @PostMapping("/addRepair")
    @ApiOperation(value = "添加报修记录", tags = {"管理后台-设备监控"})
    @Log(title = "【设备监控】添加报修记录", businessType = BusinessType.INSERT,operatorType = OperatorType.MANAGE)
    public AjaxResult addRepair(@RequestBody TRepair repair){
        repairService.save(repair);
        return AjaxResult.success();
    }
    
    
    @ResponseBody
    @DeleteMapping("/delRepair/{id}")
    @ApiOperation(value = "删除报修记录", tags = {"管理后台-设备监控"})
    @Log(title = "【设备监控】删除报修记录", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE)
    public AjaxResult delRepair(@PathVariable Integer id){
        repairService.removeById(id);
        return AjaxResult.success();
    }
}