|
@@ -8,12 +8,12 @@
|
|
|
* 版权所有,侵权必究!
|
|
|
*/
|
|
|
|
|
|
-package com.qs.mp.web.controller.api.channel.mall;
|
|
|
+package com.qs.mp.web.controller.api.user;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.qs.mp.channel.domain.ChannelAddr;
|
|
|
+import com.qs.mp.user.domain.UserAddr;
|
|
|
import com.qs.mp.channel.domain.param.AddrParam;
|
|
|
-import com.qs.mp.channel.service.IChannelAddrService;
|
|
|
+import com.qs.mp.user.service.IUserAddrService;
|
|
|
import com.qs.mp.common.core.domain.AjaxResult;
|
|
|
import com.qs.mp.utils.SecurityUtils;
|
|
|
import io.swagger.annotations.Api;
|
|
@@ -31,14 +31,14 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
@RestController
|
|
|
-@RequestMapping("/api/v1/mp/channel/mall")
|
|
|
+@RequestMapping("/api/v1/mp/user")
|
|
|
@Api(tags = "地址接口")
|
|
|
@AllArgsConstructor
|
|
|
-public class ChannelAddrController {
|
|
|
+public class UserAddrController {
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
- private IChannelAddrService channelAddrService;
|
|
|
+ private IUserAddrService userAddrService;
|
|
|
|
|
|
@Autowired
|
|
|
private MapperFacade mapperFacade;
|
|
@@ -50,34 +50,34 @@ public class ChannelAddrController {
|
|
|
@ApiOperation(value = "渠道地址列表" , notes = "获取渠道的所有地址信息")
|
|
|
public AjaxResult list(@RequestBody AddrParam addrParam) {
|
|
|
Long channelId = SecurityUtils.getLoginUser().getChannelId();
|
|
|
- List<ChannelAddr> channelAddrs = channelAddrService.list(
|
|
|
- new LambdaQueryWrapper<ChannelAddr>().eq(ChannelAddr::getChannelId, channelId)
|
|
|
- .orderByDesc(ChannelAddr::getCommonAddr).orderByDesc(ChannelAddr::getUpdateTime));
|
|
|
- return AjaxResult.success(channelAddrs);
|
|
|
+ List<UserAddr> userAddrs = userAddrService.list(
|
|
|
+ new LambdaQueryWrapper<UserAddr>().eq(UserAddr::getUserId, channelId)
|
|
|
+ .orderByDesc(UserAddr::getCommonAddr).orderByDesc(UserAddr::getUpdateTime));
|
|
|
+ return AjaxResult.success(userAddrs);
|
|
|
}
|
|
|
|
|
|
@PostMapping("/addr/create")
|
|
|
@ApiOperation(value = "新增用户地址" , notes = "新增用户地址")
|
|
|
public AjaxResult create(@Valid @RequestBody AddrParam addrParam) {
|
|
|
- Long channelId = SecurityUtils.getLoginUser().getChannelId();
|
|
|
+ Long userId = SecurityUtils.getLoginUser().getUserId();
|
|
|
|
|
|
if (addrParam.getAddrId() != null && addrParam.getAddrId() != 0) {
|
|
|
return AjaxResult.error("该地址已存在");
|
|
|
}
|
|
|
- int addrCount = channelAddrService.count(
|
|
|
- new LambdaQueryWrapper<ChannelAddr>().eq(ChannelAddr::getChannelId, channelId));
|
|
|
- ChannelAddr channelAddr = mapperFacade.map(addrParam, ChannelAddr.class);
|
|
|
+ int addrCount = userAddrService.count(
|
|
|
+ new LambdaQueryWrapper<UserAddr>().eq(UserAddr::getUserId, userId));
|
|
|
+ UserAddr userAddr = mapperFacade.map(addrParam, UserAddr.class);
|
|
|
|
|
|
if (addrCount == 0) {
|
|
|
- channelAddr.setCommonAddr(1);
|
|
|
+ userAddr.setCommonAddr(1);
|
|
|
} else {
|
|
|
- channelAddr.setCommonAddr(0);
|
|
|
+ userAddr.setCommonAddr(0);
|
|
|
}
|
|
|
- channelAddr.setChannelId(channelId);
|
|
|
- channelAddr.setStatus(1);
|
|
|
- channelAddr.setCreateTime(new Date());
|
|
|
- channelAddr.setUpdateTime(new Date());
|
|
|
- channelAddrService.save(channelAddr);
|
|
|
+ userAddr.setUserId(userId);
|
|
|
+ userAddr.setStatus(1);
|
|
|
+ userAddr.setCreateTime(new Date());
|
|
|
+ userAddr.setUpdateTime(new Date());
|
|
|
+ userAddrService.save(userAddr);
|
|
|
|
|
|
return AjaxResult.success("添加地址成功");
|
|
|
}
|
|
@@ -88,17 +88,17 @@ public class ChannelAddrController {
|
|
|
@PostMapping("/addr/update")
|
|
|
@ApiOperation(value = "修改订单用户地址" , notes = "修改用户地址")
|
|
|
public AjaxResult update(@Valid @RequestBody AddrParam addrParam) {
|
|
|
- Long channelId = SecurityUtils.getLoginUser().getChannelId();
|
|
|
+ Long userId = SecurityUtils.getLoginUser().getUserId();
|
|
|
|
|
|
- ChannelAddr dbChannelAddr = channelAddrService.getChannelAddrByUserId(addrParam.getAddrId(),
|
|
|
- channelId);
|
|
|
+ UserAddr dbChannelAddr = userAddrService.getChannelAddrByUserId(addrParam.getAddrId(),
|
|
|
+ userId);
|
|
|
if (dbChannelAddr == null) {
|
|
|
return AjaxResult.error("该地址已被删除");
|
|
|
}
|
|
|
|
|
|
- ChannelAddr channelAddr = mapperFacade.map(addrParam, ChannelAddr.class);
|
|
|
- channelAddr.setChannelId(channelId);
|
|
|
- channelAddrService.updateById(channelAddr);
|
|
|
+ UserAddr userAddr = mapperFacade.map(addrParam, UserAddr.class);
|
|
|
+ userAddr.setUserId(userId);
|
|
|
+ userAddrService.updateById(userAddr);
|
|
|
return AjaxResult.success("修改地址成功");
|
|
|
}
|
|
|
|
|
@@ -111,16 +111,16 @@ public class ChannelAddrController {
|
|
|
if (addrParam.getAddrId() == null || addrParam.getAddrId() == 0) {
|
|
|
return AjaxResult.error("参数异常,地址ID缺失");
|
|
|
}
|
|
|
- Long channelId = SecurityUtils.getLoginUser().getChannelId();
|
|
|
- ChannelAddr channelAddr = channelAddrService.getChannelAddrByUserId(addrParam.getAddrId(),
|
|
|
- channelId);
|
|
|
+ Long userId = SecurityUtils.getLoginUser().getUserId();
|
|
|
+ UserAddr channelAddr = userAddrService.getChannelAddrByUserId(addrParam.getAddrId(),
|
|
|
+ userId);
|
|
|
if (channelAddr == null) {
|
|
|
return AjaxResult.error("该地址已被删除");
|
|
|
}
|
|
|
if (channelAddr.getCommonAddr() == 1) {
|
|
|
return AjaxResult.error("默认地址无法删除");
|
|
|
}
|
|
|
- channelAddrService.removeById(addrParam.getAddrId());
|
|
|
+ userAddrService.removeById(addrParam.getAddrId());
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|
|
@@ -133,8 +133,8 @@ public class ChannelAddrController {
|
|
|
if (addrParam.getAddrId() == null || addrParam.getAddrId() == 0) {
|
|
|
return AjaxResult.error("参数异常,地址ID缺失");
|
|
|
}
|
|
|
- Long channelId = SecurityUtils.getLoginUser().getChannelId();
|
|
|
- channelAddrService.updateDefaultChannelAddr(addrParam.getAddrId(), channelId);
|
|
|
+ Long userId = SecurityUtils.getLoginUser().getUserId();
|
|
|
+ userAddrService.updateDefaultChannelAddr(addrParam.getAddrId(), userId);
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|
|
@@ -144,8 +144,8 @@ public class ChannelAddrController {
|
|
|
@PostMapping("/addr/queryDefault")
|
|
|
@ApiOperation(value = "查询默认地址" , notes = "查询默认地址")
|
|
|
public AjaxResult queryDefaultAddr(@RequestBody AddrParam addrParam) {
|
|
|
- Long channelId = SecurityUtils.getLoginUser().getChannelId();
|
|
|
- ChannelAddr addr = channelAddrService.getDefaultChannelAddr(channelId);
|
|
|
+ Long userId = SecurityUtils.getLoginUser().getUserId();
|
|
|
+ UserAddr addr = userAddrService.getDefaultChannelAddr(userId);
|
|
|
return AjaxResult.success(addr);
|
|
|
}
|
|
|
|
|
@@ -158,9 +158,9 @@ public class ChannelAddrController {
|
|
|
if (addrParam.getAddrId() == null || addrParam.getAddrId() == 0) {
|
|
|
return AjaxResult.error("参数异常,地址ID缺失");
|
|
|
}
|
|
|
- Long channelId = SecurityUtils.getLoginUser().getChannelId();
|
|
|
- ChannelAddr channelAddr = channelAddrService.getChannelAddrByUserId(addrParam.getAddrId(),
|
|
|
- channelId);
|
|
|
+ Long userId = SecurityUtils.getLoginUser().getUserId();
|
|
|
+ UserAddr channelAddr = userAddrService.getChannelAddrByUserId(addrParam.getAddrId(),
|
|
|
+ userId);
|
|
|
return AjaxResult.success(channelAddr);
|
|
|
}
|
|
|
|