|
|
@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* https://www.mall4j.com/
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* 未经允许,不可做商业用途!
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* 版权所有,侵权必究!
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package com.yami.shop.admin.controller; // 定义类所在的包
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil; // 引入Hutool工具类库中的StrUtil工具类
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; // 引入MyBatis-Plus的条件查询包装器
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; // 引入MyBatis-Plus的分页接口
|
|
|
|
|
|
|
|
import com.yami.shop.bean.model.PickAddr; // 引入自提点地址模型类
|
|
|
|
|
|
|
|
import com.yami.shop.common.exception.YamiShopBindException; // 引入自定义异常类
|
|
|
|
|
|
|
|
import com.yami.shop.common.response.ResponseEnum; // 引入响应枚举类
|
|
|
|
|
|
|
|
import com.yami.shop.common.response.ServerResponseEntity; // 引入服务器响应实体类
|
|
|
|
|
|
|
|
import com.yami.shop.common.util.PageParam; // 引入分页参数工具类
|
|
|
|
|
|
|
|
import com.yami.shop.security.admin.util.SecurityUtils; // 引入安全工具类
|
|
|
|
|
|
|
|
import com.yami.shop.service.PickAddrService; // 引入自提点地址服务类
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; // 引入Spring的@Autowired注解
|
|
|
|
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize; // 引入Spring Security的PreAuthorize注解
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.*; // 引入Spring Web的注解
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import jakarta.validation.Valid; // 引入Jakarta Validation的Valid注解
|
|
|
|
|
|
|
|
import java.util.Arrays; // 引入Java的Arrays工具类
|
|
|
|
|
|
|
|
import java.util.Objects; // 引入Java的Objects工具类
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* PickAddrController类,用于管理自提点地址。
|
|
|
|
|
|
|
|
* 该类包含分页获取、获取详细信息、保存、修改和删除自提点地址的方法。
|
|
|
|
|
|
|
|
* @作者 lgh on 2018/10/17.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@RestController // 标注这是一个控制器类,并且其返回结果直接写入HTTP响应体中,而不是视图名称
|
|
|
|
|
|
|
|
@RequestMapping("/shop/pickAddr") // 定义请求路径的根地址为/shop/pickAddr
|
|
|
|
|
|
|
|
public class PickAddrController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private PickAddrService pickAddrService; // 自动注入自提点地址服务类
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 分页获取自提点地址
|
|
|
|
|
|
|
|
* @param pickAddr 自提点地址查询条件
|
|
|
|
|
|
|
|
* @param page 分页参数
|
|
|
|
|
|
|
|
* @return 服务器响应实体,包含分页后的自提点地址信息
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@GetMapping("/page")
|
|
|
|
|
|
|
|
@PreAuthorize("@pms.hasPermission('shop:pickAddr:page')") // 权限检查
|
|
|
|
|
|
|
|
public ServerResponseEntity<IPage<PickAddr>> page(PickAddr pickAddr, PageParam<PickAddr> page) {
|
|
|
|
|
|
|
|
IPage<PickAddr> pickAddrs = pickAddrService.page(page, new LambdaQueryWrapper<PickAddr>()
|
|
|
|
|
|
|
|
.like(StrUtil.isNotBlank(pickAddr.getAddrName()), PickAddr::getAddrName, pickAddr.getAddrName())
|
|
|
|
|
|
|
|
.orderByDesc(PickAddr::getAddrId));
|
|
|
|
|
|
|
|
return ServerResponseEntity.success(pickAddrs); // 返回分页结果
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 获取自提点地址详细信息
|
|
|
|
|
|
|
|
* @param id 自提点地址ID
|
|
|
|
|
|
|
|
* @return 服务器响应实体,包含自提点地址的详细信息
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@GetMapping("/info/{id}")
|
|
|
|
|
|
|
|
@PreAuthorize("@pms.hasPermission('shop:pickAddr:info')") // 权限检查
|
|
|
|
|
|
|
|
public ServerResponseEntity<PickAddr> info(@PathVariable("id") Long id) {
|
|
|
|
|
|
|
|
PickAddr pickAddr = pickAddrService.getById(id);
|
|
|
|
|
|
|
|
return ServerResponseEntity.success(pickAddr); // 返回自提点地址信息
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 保存自提点地址
|
|
|
|
|
|
|
|
* @param pickAddr 自提点地址信息
|
|
|
|
|
|
|
|
* @return 服务器响应实体
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@PostMapping
|
|
|
|
|
|
|
|
@PreAuthorize("@pms.hasPermission('shop:pickAddr:save')") // 权限检查
|
|
|
|
|
|
|
|
public ServerResponseEntity<Void> save(@Valid @RequestBody PickAddr pickAddr) {
|
|
|
|
|
|
|
|
pickAddr.setShopId(SecurityUtils.getSysUser().getShopId()); // 设置店铺ID
|
|
|
|
|
|
|
|
pickAddrService.save(pickAddr); // 保存自提点地址
|
|
|
|
|
|
|
|
return ServerResponseEntity.success(); // 返回成功响应
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 修改自提点地址
|
|
|
|
|
|
|
|
* @param pickAddr 自提点地址信息
|
|
|
|
|
|
|
|
* @return 服务器响应实体
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@PutMapping
|
|
|
|
|
|
|
|
@PreAuthorize("@pms.hasPermission('shop:pickAddr:update')") // 权限检查
|
|
|
|
|
|
|
|
public ServerResponseEntity<Void> update(@Valid @RequestBody PickAddr pickAddr) {
|
|
|
|
|
|
|
|
PickAddr dbPickAddr = pickAddrService.getById(pickAddr.getAddrId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!Objects.equals(dbPickAddr.getShopId(), SecurityUtils.getSysUser().getShopId())) {
|
|
|
|
|
|
|
|
throw new YamiShopBindException(ResponseEnum.UNAUTHORIZED);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
pickAddrService.updateById(pickAddr); // 修改自提点地址
|
|
|
|
|
|
|
|
return ServerResponseEntity.success(); // 返回成功响应
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 删除自提点地址
|
|
|
|
|
|
|
|
* @param ids 自提点地址ID数组
|
|
|
|
|
|
|
|
* @return 服务器响应实体
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@DeleteMapping
|
|
|
|
|
|
|
|
@PreAuthorize("@pms.hasPermission('shop:pickAddr:delete')") // 权限检查
|
|
|
|
|
|
|
|
public ServerResponseEntity<Void> delete(@RequestBody Long[] ids) {
|
|
|
|
|
|
|
|
pickAddrService.removeByIds(Arrays.asList(ids)); // 删除自提点地址
|
|
|
|
|
|
|
|
return ServerResponseEntity.success(); // 返回成功响应
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|