| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.doumee.api.web; |
| | | |
| | | import com.doumee.core.annotation.LoginRequired; |
| | | import com.doumee.core.model.ApiResponse; |
| | | import com.doumee.dao.business.model.Addr; |
| | | import com.doumee.service.business.AddrService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å°åç°¿ï¼å°ç¨åºç«¯ï¼ |
| | | * @author rk |
| | | * @date 2026/04/15 |
| | | */ |
| | | @Api(tags = "å°åç°¿") |
| | | @RestController |
| | | @RequestMapping("/web/addr") |
| | | public class AddrApi extends ApiController { |
| | | |
| | | @Autowired |
| | | private AddrService addrService; |
| | | |
| | | @LoginRequired |
| | | @ApiOperation(value = "æ¥è¯¢æçå°åå表", notes = "å°ç¨åºç«¯") |
| | | @GetMapping("/list") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "ç¨æ·tokenå¼", required = true), |
| | | }) |
| | | public ApiResponse<List<Addr>> list() { |
| | | return ApiResponse.success("æ¥è¯¢æå", addrService.findListWithArea(getMemberId())); |
| | | } |
| | | |
| | | @LoginRequired |
| | | @ApiOperation(value = "æ ¹æ®IDæ¥è¯¢å°å", notes = "å°ç¨åºç«¯") |
| | | @GetMapping("/{id}") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "ç¨æ·tokenå¼", required = true), |
| | | }) |
| | | public ApiResponse<Addr> findById(@PathVariable Integer id) { |
| | | return ApiResponse.success("æ¥è¯¢æå", addrService.findByIdWithArea(id)); |
| | | } |
| | | |
| | | @LoginRequired |
| | | @ApiOperation(value = "æ°å¢å°å", notes = "å°ç¨åºç«¯") |
| | | @PostMapping("/create") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "ç¨æ·tokenå¼", required = true), |
| | | }) |
| | | public ApiResponse create(@RequestBody Addr addr) { |
| | | addrService.createByMember(addr, getMemberId()); |
| | | return ApiResponse.success("æä½æå", addrService.findByIdWithArea(addr.getId())); |
| | | } |
| | | |
| | | @LoginRequired |
| | | @ApiOperation(value = "ä¿®æ¹å°å", notes = "å°ç¨åºç«¯") |
| | | @PostMapping("/updateById") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "ç¨æ·tokenå¼", required = true), |
| | | }) |
| | | public ApiResponse updateById(@RequestBody Addr addr) { |
| | | addrService.updateByMember(addr, getMemberId()); |
| | | return ApiResponse.success("æä½æå", addrService.findByIdWithArea(addr.getId())); |
| | | } |
| | | |
| | | @LoginRequired |
| | | @ApiOperation(value = "å é¤å°å", notes = "å°ç¨åºç«¯") |
| | | @GetMapping("/delete/{id}") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "ç¨æ·tokenå¼", required = true), |
| | | }) |
| | | public ApiResponse deleteById(@PathVariable Integer id) { |
| | | addrService.deleteById(id); |
| | | return ApiResponse.success("æä½æå"); |
| | | } |
| | | |
| | | @LoginRequired |
| | | @ApiOperation(value = "设为é»è®¤å°å", notes = "å°ç¨åºç«¯") |
| | | @PostMapping("/setDefault/{id}") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "ç¨æ·tokenå¼", required = true), |
| | | }) |
| | | public ApiResponse setDefault(@PathVariable Integer id) { |
| | | Addr addr = new Addr(); |
| | | addr.setId(id); |
| | | addr.setIsDefault(1); |
| | | addrService.updateByMember(addr, getMemberId()); |
| | | return ApiResponse.success("æä½æå"); |
| | | } |
| | | } |