parent
414c00a182
commit
c9b42453a1
@ -0,0 +1,100 @@
|
||||
package com.macro.mall.portal.controller;
|
||||
|
||||
import com.macro.mall.common.api.CommonResult;
|
||||
import com.macro.mall.model.UmsMemberReceiveAddress;
|
||||
import com.macro.mall.portal.service.UmsMemberReceiveAddressService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 会员收货地址管理Controller
|
||||
* Created by macro on 2018/8/28.
|
||||
*/
|
||||
@Controller
|
||||
@Api(tags = "UmsMemberReceiveAddressController")
|
||||
@Tag(name = "UmsMemberReceiveAddressController", description = "会员收货地址管理")
|
||||
@RequestMapping("/member/address")
|
||||
public class UmsMemberReceiveAddressController {
|
||||
@Autowired
|
||||
private UmsMemberReceiveAddressService memberReceiveAddressService; // 注入会员收货地址服务
|
||||
|
||||
/**
|
||||
* 添加收货地址
|
||||
* @param address 收货地址信息
|
||||
* @return 添加结果
|
||||
*/
|
||||
@ApiOperation("添加收货地址")
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public CommonResult add(@RequestBody UmsMemberReceiveAddress address) {
|
||||
int count = memberReceiveAddressService.add(address); // 调用服务添加收货地址
|
||||
if (count > 0) {
|
||||
return CommonResult.success(count); // 添加成功,返回影响的行数
|
||||
}
|
||||
return CommonResult.failed(); // 添加失败,返回失败结果
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除收货地址
|
||||
* @param id 收货地址ID
|
||||
* @return 删除结果
|
||||
*/
|
||||
@ApiOperation("删除收货地址")
|
||||
@RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public CommonResult delete(@PathVariable Long id) {
|
||||
int count = memberReceiveAddressService.delete(id); // 调用服务删除收货地址
|
||||
if (count > 0) {
|
||||
return CommonResult.success(count); // 删除成功,返回影响的行数
|
||||
}
|
||||
return CommonResult.failed(); // 删除失败,返回失败结果
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改收货地址
|
||||
* @param id 收货地址ID
|
||||
* @param address 收货地址信息
|
||||
* @return 修改结果
|
||||
*/
|
||||
@ApiOperation("修改收货地址")
|
||||
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public CommonResult update(@PathVariable Long id, @RequestBody UmsMemberReceiveAddress address) {
|
||||
int count = memberReceiveAddressService.update(id, address); // 调用服务更新收货地址
|
||||
if (count > 0) {
|
||||
return CommonResult.success(count); // 更新成功,返回影响的行数
|
||||
}
|
||||
return CommonResult.failed(); // 更新失败,返回失败结果
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有收货地址
|
||||
* @return 收货地址列表
|
||||
*/
|
||||
@ApiOperation("获取所有收货地址")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonResult<List<UmsMemberReceiveAddress>> list() {
|
||||
List<UmsMemberReceiveAddress> addressList = memberReceiveAddressService.list(); // 调用服务获取所有收货地址
|
||||
return CommonResult.success(addressList); // 返回收货地址列表
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取收货地址详情
|
||||
* @param id 收货地址ID
|
||||
* @return 收货地址详情
|
||||
*/
|
||||
@ApiOperation("获取收货地址详情")
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonResult<UmsMemberReceiveAddress> getItem(@PathVariable Long id) {
|
||||
UmsMemberReceiveAddress address = memberReceiveAddressService.getItem(id); // 调用服务获取收货地址详情
|
||||
return CommonResult.success(address); // 返回收货地址详情
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue