puzhibing
2026-09-22 04ea80303ff4d3be8139248ef698a12b9e5d06e1
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
package com.ruoyi.other.controller;
 
import com.ruoyi.common.core.web.domain.AjaxResult;
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.security.annotation.Logical;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.other.api.domain.TGroupCompany;
import com.ruoyi.other.service.TGroupCompanyService;
import io.swagger.annotations.ApiOperation;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
 
/**
 * <p>
 * 公司(企业)管理 前端控制器
 * </p>
 *
 * @author mxcd
 * @since 2026-09-22
 */
@RestController
@RequestMapping("/group-company")
public class TGroupCompanyController {
 
    @Resource
    private TGroupCompanyService groupCompanyService;
 
    /**
     * 分页查询公司
     */
    @RequiresPermissions(value = {"/companyManagement/list", "/fleet/list"}, logical = Logical.OR)
    @GetMapping("/page")
    @ApiOperation(value = "分页查询公司", tags = {"管理后台-公司管理"})
    public AjaxResult<PageInfo<TGroupCompany>> page(@RequestParam(value = "current", defaultValue = "1") Integer current,
                                                     @RequestParam(value = "size", defaultValue = "10") Integer size,
                                                     @RequestParam(value = "groupId", required = false) Integer groupId,
                                                     @RequestParam(value = "name", required = false) String name,
                                                     @RequestParam(value = "contactName", required = false) String contactName,
                                                     @RequestParam(value = "contactPhone", required = false) String contactPhone,
                                                     @RequestParam(value = "status", required = false) Integer status) {
        PageInfo<TGroupCompany> page = new PageInfo<>(current, size);
        groupCompanyService.lambdaQuery()
                .eq(groupId != null, TGroupCompany::getGroupId, groupId)
                .like(StringUtils.hasText(name), TGroupCompany::getName, name)
                .like(StringUtils.hasText(contactName), TGroupCompany::getContactName, contactName)
                .like(StringUtils.hasText(contactPhone), TGroupCompany::getContactPhone, contactPhone)
                .eq(status != null, TGroupCompany::getStatus, status)
                .orderByDesc(TGroupCompany::getId)
                .page(page);
        return AjaxResult.success(page);
    }
 
    /**
     * 公司详情
     */
    @RequiresPermissions(value = {"/companyManagement/list"}, logical = Logical.OR)
    @GetMapping("/detail")
    @ApiOperation(value = "公司详情", tags = {"管理后台-公司管理"})
    public AjaxResult<TGroupCompany> detail(@RequestParam("id") Integer id) {
        return AjaxResult.success(groupCompanyService.getById(id));
    }
 
    /**
     * 添加公司
     */
    @RequiresPermissions(value = {"/companyManagement/list"}, logical = Logical.OR)
    @PostMapping("/add")
    @ApiOperation(value = "添加公司", tags = {"管理后台-公司管理"})
    @Log(title = "【公司管理】添加公司", businessType = BusinessType.INSERT)
    public AjaxResult add(@RequestBody TGroupCompany company) {
        if (company.getGroupId() == null) {
            return AjaxResult.error("所属集团不能为空");
        }
        if (!StringUtils.hasText(company.getName())) {
            return AjaxResult.error("公司名称不能为空");
        }
        company.setId(null);
        company.setDelFlag(false);
        if (company.getStatus() == null) {
            company.setStatus(1);
        }
        groupCompanyService.save(company);
        return AjaxResult.success();
    }
 
    /**
     * 编辑公司
     */
    @RequiresPermissions(value = {"/companyManagement/list"}, logical = Logical.OR)
    @PostMapping("/edit")
    @ApiOperation(value = "编辑公司", tags = {"管理后台-公司管理"})
    @Log(title = "【公司管理】编辑公司", businessType = BusinessType.UPDATE)
    public AjaxResult edit(@RequestBody TGroupCompany company) {
        if (company.getId() == null) {
            return AjaxResult.error("公司ID不能为空");
        }
        groupCompanyService.updateById(company);
        return AjaxResult.success();
    }
 
    /**
     * 删除公司
     */
    @RequiresPermissions(value = {"/companyManagement/list"}, logical = Logical.OR)
    @DeleteMapping("/del")
    @ApiOperation(value = "删除公司", tags = {"管理后台-公司管理"})
    @Log(title = "【公司管理】删除公司", businessType = BusinessType.DELETE)
    public AjaxResult del(@RequestParam("id") Integer id) {
        if (id == null) {
            return AjaxResult.error("公司ID不能为空");
        }
        groupCompanyService.removeById(id);
        return AjaxResult.success();
    }
 
    /**
     * 切换公司启用状态
     */
    @RequiresPermissions(value = {"/companyManagement/list"}, logical = Logical.OR)
    @PostMapping("/status")
    @ApiOperation(value = "切换公司启用状态", tags = {"管理后台-公司管理"})
    @Log(title = "【公司管理】切换公司状态", businessType = BusinessType.UPDATE)
    public AjaxResult status(@RequestParam("id") Integer id, @RequestParam("status") Integer status) {
        if (id == null) {
            return AjaxResult.error("公司ID不能为空");
        }
        TGroupCompany update = new TGroupCompany();
        update.setId(id);
        update.setStatus(status);
        groupCompanyService.updateById(update);
        return AjaxResult.success();
    }
 
}