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