Pu Zhibing
昨天 d0d6f8f40e5d9762d940b47c566da1876361020e
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
package com.stylefeng.guns.modular.system.controller.checkCar;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.exception.GunsException;
import com.stylefeng.guns.core.shiro.ShiroKit;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.stylefeng.guns.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.stylefeng.guns.modular.system.model.TCheckFacilitator;
import com.stylefeng.guns.modular.system.service.ITCheckFacilitatorService;
 
/**
 * 代检车车检点控制器
 *
 * @author fengshuonan
 * @Date 2025-08-02 18:20:57
 */
@Controller
@RequestMapping("/tCheckFacilitator")
public class TCheckFacilitatorController extends BaseController {
 
    private String PREFIX = "/system/tCheckFacilitator/";
 
    @Autowired
    private ITCheckFacilitatorService tCheckFacilitatorService;
 
    /**
     * 跳转到代检车车检点首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "tCheckFacilitator.html";
    }
 
    /**
     * 跳转到添加代检车车检点
     */
    @RequestMapping("/tCheckFacilitator_add")
    public String tCheckFacilitatorAdd() {
        return PREFIX + "tCheckFacilitator_add.html";
    }
 
    /**
     * 跳转到修改代检车车检点
     */
    @RequestMapping("/tCheckFacilitator_update/{tCheckFacilitatorId}")
    public String tCheckFacilitatorUpdate(@PathVariable Integer tCheckFacilitatorId, Model model) {
        TCheckFacilitator tCheckFacilitator = tCheckFacilitatorService.selectById(tCheckFacilitatorId);
        model.addAttribute("item",tCheckFacilitator);
        LogObjectHolder.me().set(tCheckFacilitator);
        return PREFIX + "tCheckFacilitator_edit.html";
    }
 
    /**
     * 获取代检车车检点列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String name, String phone) {
        Integer roleType = ShiroKit.getUser().getRoleType();
        Integer companyId = ShiroKit.getUser().getObjectId();
 
        // 分公司管理员只能查看本分公司的代检车车检点
        return tCheckFacilitatorService.selectList(new EntityWrapper<TCheckFacilitator>()
                .eq(roleType == 2, "companyId", companyId)
                .like("name", name)
                .like("phone", phone)
                .orderBy("createTime", false));
    }
 
    /**
     * 新增代检车车检点
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(TCheckFacilitator tCheckFacilitator) {
        String name = ShiroKit.getUser().getName();
        Integer roleType = ShiroKit.getUser().getRoleType();
        if (roleType != 2) {
            throw new GunsException("只有分公司管理员可以操作");
        }
        tCheckFacilitator.setCreateBy(name);
        tCheckFacilitator.setCompanyId(ShiroKit.getUser().getObjectId());
        tCheckFacilitatorService.insert(tCheckFacilitator);
        return SUCCESS_TIP;
    }
 
    /**
     * 删除代检车车检点
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer tCheckFacilitatorId) {
        Integer roleType = ShiroKit.getUser().getRoleType();
        if (roleType != 2) {
            throw new GunsException("只有分公司管理员可以操作");
        }
        tCheckFacilitatorService.deleteById(tCheckFacilitatorId);
        return SUCCESS_TIP;
    }
 
    /**
     * 修改代检车车检点
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(TCheckFacilitator tCheckFacilitator) {
        String name = ShiroKit.getUser().getName();
        Integer roleType = ShiroKit.getUser().getRoleType();
        if (roleType != 2) {
            throw new GunsException("只有分公司管理员可以操作");
        }
        tCheckFacilitator.setUpdateBy(name);
        tCheckFacilitatorService.updateById(tCheckFacilitator);
        return SUCCESS_TIP;
    }
 
    /**
     * 代检车车检点详情
     */
    @RequestMapping(value = "/detail/{tCheckFacilitatorId}")
    @ResponseBody
    public Object detail(@PathVariable("tCheckFacilitatorId") Integer tCheckFacilitatorId) {
        return tCheckFacilitatorService.selectById(tCheckFacilitatorId);
    }
}