tj
2025-06-05 2d549a04870d1315868a7cf19952b64e8071e711
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
package com.cloudroam.controller.v1;
 
 
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cloudroam.common.util.PageUtil;
import com.cloudroam.dto.company.CreateOrUpdateCompanyInfoDTO;
import com.cloudroam.dto.company.QueryCompanyDTO;
import com.cloudroam.dto.projectDaily.CreateOrUpdateProjectDailyDTO;
import com.cloudroam.dto.projectDaily.QueryProjectDailyDTO;
import com.cloudroam.model.LogDO;
import com.cloudroam.model.ProjectDailyDO;
import com.cloudroam.model.UserDO;
import com.cloudroam.service.CompanyInfoService;
import io.github.talelin.autoconfigure.exception.NotFoundException;
import io.github.talelin.core.annotation.Logger;
import io.github.talelin.core.annotation.LoginRequired;
import io.github.talelin.core.annotation.PermissionMeta;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.cloudroam.model.CompanyInfoDO;
import com.cloudroam.vo.CreatedVO;
import com.cloudroam.vo.DeletedVO;
import com.cloudroam.vo.PageResponseVO;
import com.cloudroam.vo.UpdatedVO;
 
import javax.validation.constraints.Min;
import javax.validation.constraints.Max;
import javax.validation.constraints.Positive;
 
import java.util.List;
 
/**
* @author generator@TaoJie
* @since 2023-08-08
*/
@RestController
@RequestMapping("/v1/company-info")
public class CompanyInfoController {
 
    @Autowired
    private CompanyInfoService companyInfoService;
 
    @PostMapping("")
    @LoginRequired
    @PermissionMeta(value = "客户创建", module = "客户信息",mount = true)
    @Logger(template = "{user.nickname} 创建了客户 ")
    public CreatedVO create(@RequestBody @Validated CreateOrUpdateCompanyInfoDTO validator) {
        companyInfoService.createCompanyInfo(validator);
        return new CreatedVO();
    }
 
    @PutMapping("/{id}")
    @LoginRequired
    @PermissionMeta(value = "客户更新", module = "客户信息",mount = true)
    @Logger(template = "{user.nickname} 更新了客户 ")
    public UpdatedVO update(@PathVariable String id,@RequestBody @Validated CreateOrUpdateCompanyInfoDTO validator) {
        if(StrUtil.isBlank(id)){
            throw new NotFoundException("传入的Id不能为空");
        }
        CompanyInfoDO companyInfoDO = companyInfoService.getById(id);
 
        if(companyInfoDO == null){
            throw new NotFoundException("客户不存在");
        }
 
        companyInfoService.updateCompanyInfo(validator);
        return new UpdatedVO();
    }
 
    @DeleteMapping("/{id}")
    @LoginRequired
    @PermissionMeta(value = "客户删除", module = "客户信息",mount = true)
    @Logger(template = "{user.nickname} 删除了客户 ")
    public DeletedVO delete(@PathVariable String id) {
        if(StrUtil.isBlank(id)){
            throw new NotFoundException("id不能为空");
        }
        CompanyInfoDO companyInfoDO = companyInfoService.getById(id);
        if (companyInfoDO == null) {
            throw new NotFoundException("记录不存在");
        }
        companyInfoService.removeByIdLogic(id);
 
        return new DeletedVO();
    }
 
    @GetMapping("/{id}")
    public CompanyInfoDO get(@PathVariable(value = "id") String id) {
        if(StrUtil.isBlank(id)){
            throw new NotFoundException("id不能为空");
        }
        CompanyInfoDO companyInfoDO = companyInfoService.getById(id);
        if (companyInfoDO == null) {
            throw new NotFoundException("记录不存在");
        }
        return companyInfoDO;
    }
 
    @GetMapping("/page")
    @LoginRequired
    @PermissionMeta(value = "客户列表", module = "客户信息",mount = true)
    @Logger(template = "{user.nickname} 查看了客户列表 ")
    public PageResponseVO<CompanyInfoDO> page(
            @Validated QueryCompanyDTO dto
    ) {
 
        IPage<CompanyInfoDO> iPage = companyInfoService.getCompanyPage(dto);
        return PageUtil.build(iPage);
    }
 
    @GetMapping("/list")
    public List<CompanyInfoDO> list(
            @Validated QueryCompanyDTO dto
    ) {
        List<CompanyInfoDO> list=companyInfoService.getCompanyList(dto);
        return list;
    }
 
}