rk
2025-12-15 a1a6e227628810259fcba0fff146792e97a80b8a
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
package com.doumee.api.web;
 
import com.doumee.config.annotation.LoginRequired;
import com.doumee.core.annotation.trace.Trace;
import com.doumee.core.model.ApiResponse;
import com.doumee.dao.business.model.Addr;
import com.doumee.dao.web.dto.AddrDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
@Api(tags = "用户收获地址")
@Trace(exclude = true)
@RestController
@RequestMapping("/web/addr")
@Slf4j
public class AddrApi extends ApiController{
 
 
    /**
     * 创建
     *
     * @param addr 实体对象
     * @return Integer
     */
    @LoginRequired
    @ApiOperation(value = "创建", notes = "小程序端")
    @PostMapping("/create")
    public ApiResponse<Integer> create(@RequestBody AddrDTO addr){
        return ApiResponse.success(addrService.create(addr,getMemberId()));
    }
 
 
 
    /**
     * 条件查询
     *
     * @return List<Addr>
     */
    @LoginRequired
    @ApiOperation(value = "查询用户地址列表", notes = "小程序端")
    @GetMapping("/findList")
    public ApiResponse<List<AddrDTO>> findList(){
        Addr addr = new Addr();
        addr.setMemberId(getMemberId());
        return ApiResponse.success(addrService.findList(addr));
    }
 
    /**
     * 获取默认地址
     * @return AddrDTO
     */
    @LoginRequired
    @ApiOperation(value = "查询用户默认地址", notes = "小程序端")
    @GetMapping("/findDefault")
    public ApiResponse<AddrDTO> findDefault(){
        return ApiResponse.success(addrService.findDefault(getMemberId()));
    }
 
 
 
    /**
     * 根据用户修改用户收货地址
     * @param addr
     */
    @LoginRequired
    @ApiOperation(value = "根据用户修改用户收货地址", notes = "小程序端")
    @PostMapping("/update")
    public ApiResponse update(@RequestBody AddrDTO addr){
        //校正用户memberId
        addr.setMemberId(getMemberId());
        addrService.update(addr);
        return ApiResponse.success(null);
    }
 
    @ApiOperation("根据ID查询")
    @GetMapping("/findById")
    @LoginRequired
    public ApiResponse findById(@RequestParam Integer id) {
        return ApiResponse.success(addrService.findById(id,getMemberId()));
    }
 
    /**
     * 删除
     *
     * @param addr 实体对象
     */
    @ApiOperation("根据ID删除")
    @PostMapping("/delete")
    @LoginRequired
    public ApiResponse delete(@RequestBody Addr addr){
        Addr query = new Addr();
        query.setId(addr.getId());
        addrService.delete(query);
        return ApiResponse.success(null);
    }
}