huliguo
2025-05-28 340a6a4ba1297249af7f03c0974818bb5baae497
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
package com.ruoyi.web.controller.system;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.system.domain.CompanyType;
import com.ruoyi.system.pojo.dto.AddCompanyTypeDTO;
import com.ruoyi.system.pojo.vo.CompanyTypePageVO;
import com.ruoyi.system.pojo.dto.EditCompanyTypeDTO;
import com.ruoyi.system.service.CompanyTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import javax.validation.Valid;
 
@Slf4j
@RestController
@RequestMapping("/system/companyType")
@Api( tags = "后台-系统设置-公司类型管理")
public class CompanyTypeController {
    @Resource
    private CompanyTypeService companyTypeService;
 
    /**
     * 公司类型分页
     */
    @GetMapping("/getCompanyTypePage")
    @ApiOperation(value = "公司类型分页")
    public R<IPage<CompanyTypePageVO>> getCompanyTypePage(
            @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize,
            @RequestParam(value = "name",required = false) String name) {
        return R.ok(companyTypeService.getCompanyTypePage(pageNum,pageSize,name));
    }
 
    /**
     * 新增
     */
    @PostMapping("/add")
    @ApiOperation(value = "公司类型添加")
    public R<Void> add(@RequestBody AddCompanyTypeDTO dto) {
        companyTypeService.add(dto);
        return R.ok();
    }
    /**
     * 查看详情
     */
    @GetMapping("/getCompanyTypeById/{id}")
    @ApiOperation(value = "根据id查看详情")
    public R<CompanyType> getCompanyTypeById(@PathVariable("id")Integer id) {
        CompanyType companyType = companyTypeService.getById(id);
        if (null == companyType||companyType.getDelFlag()!=0){
            throw new ServiceException("该类型不存在");
        }
        return R.ok(companyType);
    }
 
    /**
     * 修改
     */
    @PutMapping("/edit")
    @ApiOperation(value = "公司类型编辑")
    public R<Void> edit(@RequestBody @Valid EditCompanyTypeDTO dto) {
        companyTypeService.edit(dto);
        return R.ok();
    }
    /**
     * 删除
     */
    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "公司类型删除")
    public R<Void> delete(@PathVariable("id")Integer id) {
        companyTypeService.delete(id);
        return R.ok();
    }
 
 
}