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
122
package com.cloudroam.controller.v1;
 
 
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.cloudroam.bo.supplierContact.SupplierContactInfoBO;
import com.cloudroam.common.util.PageUtil;
import com.cloudroam.dto.supplierContact.CreateOrUpdateSupplierContactDTO;
import com.cloudroam.dto.supplierContact.QuerySupplierContactDTO;
import com.cloudroam.service.SupplierContactInfoService;
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 io.github.talelin.core.annotation.PermissionModule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.cloudroam.model.SupplierContactInfoDO;
import com.cloudroam.vo.CreatedVO;
import com.cloudroam.vo.DeletedVO;
import com.cloudroam.vo.PageResponseVO;
import com.cloudroam.vo.UpdatedVO;
 
import java.util.List;
 
/**
* @author generator@TaoJie
* @since 2024-07-16
*/
@RestController
@RequestMapping("/v1/supplier-contact-info")
@Validated
@PermissionModule("供应商联系人")
public class SupplierContactInfoController {
 
    @Autowired
    private SupplierContactInfoService supplierContactInfoService;
 
    @PostMapping("")
    @LoginRequired
    @PermissionMeta(value = "供应商联系人创建", module = "供应商联系人",mount = false)
    @Logger(template = "{user.nickname} 创建了供应商联系人 ")
    public CreatedVO create(@RequestBody @Validated CreateOrUpdateSupplierContactDTO validator) {
        supplierContactInfoService.CreateSupplierContactInfo(validator);
        return new CreatedVO();
    }
 
    @PutMapping("/{id}")
    @LoginRequired
    @PermissionMeta(value = "供应商联系人编辑",mount = false)
    @Logger(template = "{user.nickname} 编辑了供应商联系人 ")
    public UpdatedVO update(@PathVariable String id,@RequestBody @Validated CreateOrUpdateSupplierContactDTO validator) {
 
        if(StrUtil.isBlank(id)){
            throw new NotFoundException("传入的Id不能为空");
        }
        SupplierContactInfoDO supplierContactInfoDO = supplierContactInfoService.getById(id);
 
        if(supplierContactInfoDO == null){
            throw new NotFoundException("记录不存在");
        }
 
        supplierContactInfoService.updateSupplierContactInfo(validator);
 
        return new UpdatedVO();
    }
 
    @DeleteMapping("/{id}")
    @LoginRequired
    @PermissionMeta(value = "供应商联系人删除",mount = false)
    @Logger(template = "{user.nickname} 删除了供应商联系人 ")
    public DeletedVO delete(@PathVariable String id) {
        if(StrUtil.isBlank(id)){
            throw new NotFoundException("传入的Id不能为空");
        }
        SupplierContactInfoDO supplierContactInfoDO = supplierContactInfoService.getById(id);
 
        if(supplierContactInfoDO == null){
            throw new NotFoundException("记录不存在");
        }
        supplierContactInfoService.removeByIdLogic(id);
        return new DeletedVO();
    }
 
    @GetMapping("/{id}")
    public SupplierContactInfoBO get(@PathVariable(value = "id") String id) {
        if(StrUtil.isBlank(id)){
            throw new NotFoundException("id不能为空");
        }
        SupplierContactInfoDO supplierContactInfoDO = supplierContactInfoService.getById(id);
        if(supplierContactInfoDO == null){
            throw new NotFoundException("记录不存在");
        }
 
        SupplierContactInfoBO supplierContactInfoBO=supplierContactInfoService.getSupplierContactInfoById(id);
 
 
 
 
        return supplierContactInfoBO;
    }
 
    @LoginRequired
    @PermissionMeta(value = "供应商联系人",module = "供应商管理",mount = true)
    @Logger(template = "{user.nickname} 查看供应商联系人  ")
    @GetMapping("/page")
    public PageResponseVO<SupplierContactInfoBO> page(@Validated QuerySupplierContactDTO dto
    ) {
        IPage<SupplierContactInfoBO> iPage=supplierContactInfoService.getSupplierContactInfoPage(dto);
        return PageUtil.build(iPage);
    }
 
    @GetMapping("/list")
    public List<SupplierContactInfoDO> list(
            @Validated QuerySupplierContactDTO dto
    ) {
        List<SupplierContactInfoDO> list=supplierContactInfoService.getSupplierContactInfoList(dto);
        return list;
    }
 
}