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.bo.ContactInfoBO;
import com.cloudroam.common.util.PageUtil;
import com.cloudroam.dto.company.CreateOrUpdateCompanyInfoDTO;
import com.cloudroam.dto.contact.CreateOrUpdateContactDTO;
import com.cloudroam.dto.contact.QueryContactDTO;
import com.cloudroam.dto.projectInfo.CreateOrUpdateProjectInfoDTO;
import com.cloudroam.model.CompanyInfoDO;
import com.cloudroam.service.ContactInfoService;
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.ContactInfoDO;
import com.cloudroam.vo.CreatedVO;
import com.cloudroam.vo.DeletedVO;
import com.cloudroam.vo.PageResponseVO;
import com.cloudroam.vo.UpdatedVO;
 
import javax.validation.constraints.Positive;
 
import java.util.List;
 
/**
* @author generator@TaoJie
* @since 2023-08-08
*/
@RestController
@RequestMapping("/v1/contact-info")
@Validated
public class ContactInfoController {
 
    @Autowired
    private ContactInfoService contactInfoService;
 
    @PostMapping("")
    @LoginRequired
    @PermissionMeta(value = "客户联系人创建", module = "客户联系人",mount = false)
    @Logger(template = "{user.nickname} 创建了客户联系人 ")
    public CreatedVO create(@RequestBody @Validated CreateOrUpdateContactDTO validator) {
        contactInfoService.CreateContactInfo(validator);
        return new CreatedVO();
    }
 
    @PutMapping("/{id}")
    @LoginRequired
    @PermissionMeta(value = "客户联系人编辑", module = "客户联系人",mount = false)
    @Logger(template = "{user.nickname} 编辑了客户联系人 ")
    public UpdatedVO update(@PathVariable String id,@RequestBody @Validated CreateOrUpdateContactDTO validator) {
        if(StrUtil.isBlank(id)){
            throw new NotFoundException("传入的Id不能为空");
        }
        ContactInfoDO contactInfoDO = contactInfoService.getById(id);
 
        if(contactInfoDO == null){
            throw new NotFoundException("记录不存在");
        }
 
        contactInfoService.updateContactInfo(validator);
        return new UpdatedVO();
    }
 
    @DeleteMapping("/{id}")
    @LoginRequired
    @PermissionMeta(value = "客户联系人删除", module = "客户联系人",mount = false)
    @Logger(template = "{user.nickname} 删除了客户联系人 ")
    public DeletedVO delete(@PathVariable String id) {
        if(StrUtil.isBlank(id)){
            throw new NotFoundException("id不能为空");
        }
        ContactInfoDO contactInfoDO = contactInfoService.getById(id);
 
        if (contactInfoDO == null) {
            throw new NotFoundException("记录不存在");
        }
        contactInfoService.removeByIdLogic(id);
 
        return new DeletedVO();
    }
 
    @GetMapping("/{id}")
    public ContactInfoDO get(@PathVariable(value = "id") String id) {
        if(StrUtil.isBlank(id)){
            throw new NotFoundException("id不能为空");
        }
        ContactInfoDO contactInfoDO = contactInfoService.getById(id);
 
        if (contactInfoDO == null) {
            throw new NotFoundException("记录不存在");
        }
        return contactInfoDO;
    }
 
    @LoginRequired
    @PermissionMeta(value = "客户联系人列表", module = "客户联系人",mount = true)
    @Logger(template = "{user.nickname} 查看客户联系人  ")
    @GetMapping("/page")
    public PageResponseVO<ContactInfoBO> page(
            @Validated QueryContactDTO dto
    ) {
        IPage<ContactInfoBO> iPage=contactInfoService.getContactInfoPage(dto);
        return PageUtil.build(iPage);
    }
 
    @GetMapping("/list")
    public List<ContactInfoDO> list(
            @Validated QueryContactDTO dto
    ) {
        List<ContactInfoDO> list=contactInfoService.getContactList(dto);
        return list;
    }
 
 
}