gaoluyang
昨天 8c65f898ed6e5b0c7a94c792c4562f6ec831dccd
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
package cn.iocoder.yudao.module.crm.controller.admin.customer;
 
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.address.CrmCustomerAddressRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.address.CrmCustomerAddressSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerAddressDO;
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerAddressService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 
/**
 * 管理后台 - CRM 客户收货地址
 *
 * @author 超级管理员
 */
@Tag(name = "管理后台 - CRM 客户收货地址")
@RestController
@RequestMapping("/crm/customer-address")
@Validated
public class CrmCustomerAddressController {
 
    @Resource
    private CrmCustomerAddressService customerAddressService;
 
    @PostMapping("/create")
    @Operation(summary = "创建客户收货地址")
    @PreAuthorize("@ss.hasPermission('crm:customer:update')")
    public CommonResult<Long> createCustomerAddress(@Valid @RequestBody CrmCustomerAddressSaveReqVO createReqVO) {
        return success(customerAddressService.createCustomerAddress(createReqVO));
    }
 
    @PutMapping("/update")
    @Operation(summary = "修改客户收货地址")
    @PreAuthorize("@ss.hasPermission('crm:customer:update')")
    public CommonResult<Boolean> updateCustomerAddress(@Valid @RequestBody CrmCustomerAddressSaveReqVO updateReqVO) {
        customerAddressService.updateCustomerAddress(updateReqVO);
        return success(true);
    }
 
    @DeleteMapping("/delete")
    @Operation(summary = "删除客户收货地址")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('crm:customer:update')")
    public CommonResult<Boolean> deleteCustomerAddress(@RequestParam("id") Long id) {
        customerAddressService.deleteCustomerAddress(id);
        return success(true);
    }
 
    @GetMapping("/list")
    @Operation(summary = "获得客户收货地址列表")
    @Parameter(name = "customerId", description = "客户编号", required = true)
    @PreAuthorize("@ss.hasPermission('crm:customer:query')")
    public CommonResult<List<CrmCustomerAddressRespVO>> getCustomerAddressList(@RequestParam("customerId") Long customerId) {
        List<CrmCustomerAddressDO> list = customerAddressService.getCustomerAddressList(customerId);
        return success(BeanUtils.toBean(list, CrmCustomerAddressRespVO.class));
    }
 
}