feat: 1.地址档案、2.区域档案、3.商店基础档案
This commit is contained in:
parent
ffdef043fc
commit
90dc40dd8b
|
|
@ -26,8 +26,8 @@ import org.springframework.context.annotation.Bean;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@Configuration
|
||||
@MapperScan("com.wansenai.mappers")
|
||||
//@Configuration
|
||||
//@MapperScan("com.wansenai.mappers")
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
public final RedisUtil redisUtil;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>商店档案</p>
|
||||
|
|
@ -81,10 +83,10 @@ public class ShopController {
|
|||
return Response.responseData(shopService.updateShop(shop));
|
||||
}
|
||||
|
||||
@Operation(summary = "删除店铺")
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public Response<Boolean> deleteShop(@Parameter(description = "店铺ID") @PathVariable Long id) {
|
||||
return Response.responseData(shopService.deleteShop(id));
|
||||
@Operation(summary = "批量删除店铺")
|
||||
@DeleteMapping("/delete")
|
||||
public Response<Boolean> deleteShop(@Parameter(description = "店铺ID数组") @RequestParam("ids") List<Long> ids) {
|
||||
return Response.responseData(shopService.removeByIds(ids));
|
||||
}
|
||||
|
||||
@Operation(summary = "根据渠道获取店铺列表")
|
||||
|
|
|
|||
|
|
@ -25,9 +25,8 @@ public class BasAddressController {
|
|||
|
||||
@PostMapping("addOrUpdate")
|
||||
@Operation(summary = "新增or更新地址", description = "新增or更新地址")
|
||||
public Response<String> getList(@RequestBody BasAddressDto basAddressDto) {
|
||||
basAddressService.addOrUpdate(basAddressDto);
|
||||
return Response.success();
|
||||
public Response<String> addOrUpdate(@RequestBody BasAddressDto basAddressDto) {
|
||||
return Response.responseData(basAddressService.addOrUpdate(basAddressDto));
|
||||
}
|
||||
|
||||
@GetMapping("getDetail")
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ public class BasAddressDto {
|
|||
|
||||
private Long regionId;
|
||||
|
||||
private Long streetId;
|
||||
|
||||
private String detail;
|
||||
|
||||
private String fullAddress;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.wansenai.entities.shop;
|
|||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Accessors;
|
||||
|
|
@ -24,6 +25,7 @@ public class BasShop implements Serializable {
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "主键ID")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "店铺编码")
|
||||
|
|
@ -39,6 +41,7 @@ public class BasShop implements Serializable {
|
|||
private String type;
|
||||
|
||||
@Schema(description = "地址ID")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||
private Long addressId;
|
||||
|
||||
@Schema(description = "价格类型")
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ public class BasAddress implements Serializable {
|
|||
|
||||
private Long regionId;
|
||||
|
||||
private Long streetId;
|
||||
|
||||
private String detail;
|
||||
|
||||
private String fullAddress;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,11 @@ public class BasAddressVo {
|
|||
|
||||
private BasAreaVo region;
|
||||
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||
private Long streetId;
|
||||
|
||||
private BasAreaVo street;
|
||||
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||
private String detail;
|
||||
|
||||
|
|
|
|||
|
|
@ -66,8 +66,8 @@ public class JWTInterceptor implements HandlerInterceptor { //校验类
|
|||
}
|
||||
}
|
||||
// 这里先不做token的判断,不然首次前端加载会出现token无效给用户造成误解 2024-08-12
|
||||
// map.put("msg", "token无效");
|
||||
// map.put("code", "A0312");
|
||||
map.put("msg", "token无效");
|
||||
map.put("code", "A0312");
|
||||
|
||||
String value = new ObjectMapper().writeValueAsString(map);
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
|
|
|
|||
|
|
@ -56,10 +56,10 @@ public interface BasShopService extends IService<BasShop> {
|
|||
boolean updateShop(BasShop shop);
|
||||
|
||||
/**
|
||||
* 删除店铺信息
|
||||
* 批量删除店铺信息
|
||||
*
|
||||
* @param id 店铺ID
|
||||
* @param ids 店铺ID列表
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteShop(Long id);
|
||||
boolean deleteShop(List<Long> ids);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
import com.wansenai.entities.shop.BasShop;
|
||||
import com.wansenai.mappers.shop.BasShopMapper;
|
||||
import com.wansenai.service.shop.BasShopService;
|
||||
import com.wansenai.service.user.ISysUserService;
|
||||
import com.wansenai.utils.SnowflakeIdUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
|
@ -14,8 +18,11 @@ import java.util.List;
|
|||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
public class BasShopServiceImpl extends ServiceImpl<BasShopMapper, BasShop> implements BasShopService {
|
||||
|
||||
private final ISysUserService sysUserService;
|
||||
|
||||
@Override
|
||||
public BasShop getShopByCode(String code) {
|
||||
return baseMapper.getShopByCode(code);
|
||||
|
|
@ -53,9 +60,10 @@ public class BasShopServiceImpl extends ServiceImpl<BasShopMapper, BasShop> impl
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean addShop(BasShop shop) {
|
||||
// 设置创建时间
|
||||
shop.setId(SnowflakeIdUtil.nextId());
|
||||
shop.setCreateTime(new Date());
|
||||
// 这里可以设置创建人,通常从当前登录用户中获取
|
||||
// shop.setCreateBy(getCurrentUsername());
|
||||
shop.setCreateBy(sysUserService.getCurrentUserName());
|
||||
|
||||
return save(shop);
|
||||
}
|
||||
|
|
@ -66,14 +74,17 @@ public class BasShopServiceImpl extends ServiceImpl<BasShopMapper, BasShop> impl
|
|||
// 设置更新时间
|
||||
shop.setUpdateTime(new Date());
|
||||
// 这里可以设置更新人,通常从当前登录用户中获取
|
||||
// shop.setUpdateBy(getCurrentUsername());
|
||||
shop.setUpdateBy(sysUserService.getCurrentUserName());
|
||||
|
||||
return updateById(shop);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean deleteShop(Long id) {
|
||||
return removeById(id);
|
||||
public boolean deleteShop(List<Long> ids) {
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return false;
|
||||
}
|
||||
return removeByIds(ids);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import com.wansenai.vo.support.BasAddressVo;
|
|||
|
||||
public interface BasAddressService extends IService<BasAddress> {
|
||||
|
||||
void addOrUpdate(BasAddressDto basAddressDto);
|
||||
String addOrUpdate(BasAddressDto basAddressDto);
|
||||
|
||||
BasAddressVo getDetail(Long id);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,20 +24,22 @@ public class BasAddressServiceImpl extends ServiceImpl<BasAddressMapper, BasAddr
|
|||
private final ISysUserService sysUserService;
|
||||
|
||||
@Override
|
||||
public void addOrUpdate(BasAddressDto basAddressDto) {
|
||||
public String addOrUpdate(BasAddressDto basAddressDto) {
|
||||
BasAddress address;
|
||||
if(basAddressDto.getId() != null){
|
||||
BasAddress address = this.getById(basAddressDto.getId());
|
||||
address = this.getById(basAddressDto.getId());
|
||||
BeanUtils.copyProperties(basAddressDto, address);
|
||||
address.setUpdateBy(sysUserService.getCurrentUserName());
|
||||
address.setUpdateTime(null);
|
||||
this.updateById(address);
|
||||
}else {
|
||||
var address = new BasAddress();
|
||||
address = new BasAddress();
|
||||
BeanUtils.copyProperties(basAddressDto, address);
|
||||
address.setId(SnowflakeIdUtil.nextId());
|
||||
address.setCreateBy(sysUserService.getCurrentUserName());
|
||||
this.save(address);
|
||||
}
|
||||
return String.valueOf(address.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -60,6 +62,9 @@ public class BasAddressServiceImpl extends ServiceImpl<BasAddressMapper, BasAddr
|
|||
if(result.getRegionId() != null){
|
||||
result.setRegion(basAreaService.getDetail(result.getRegionId()));
|
||||
}
|
||||
if(result.getStreetId() != null){
|
||||
result.setStreet(basAreaService.getDetail(result.getStreetId()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue