Compare commits
11 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
70052aabac | 2 years ago |
|
|
0a62da90aa | 2 years ago |
|
|
fc578f8ac4 | 2 years ago |
|
|
464ece7a27 | 2 years ago |
|
|
06e6416394 | 2 years ago |
|
|
54f7e5c166 | 2 years ago |
|
|
c2131d095b | 2 years ago |
|
|
ef14a0052f | 2 years ago |
|
|
9ba6f6fa22 | 2 years ago |
|
|
c18c04f61a | 2 years ago |
|
|
c26fd66e04 | 2 years ago |
26 changed files with 1233 additions and 10 deletions
@ -0,0 +1,146 @@ |
|||||
|
package cc.hiver.mall.shoprelations.controller; |
||||
|
|
||||
|
import cc.hiver.core.common.utils.ResultUtil; |
||||
|
import cc.hiver.core.common.vo.Result; |
||||
|
import cc.hiver.mall.shoprelations.entity.ShopRelations; |
||||
|
import cc.hiver.mall.shoprelations.service.ShopRelationsService; |
||||
|
import cc.hiver.mall.shoprelations.vo.ShopRelationsVo; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMethod; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 店铺关联 |
||||
|
* |
||||
|
* @author 王富康 |
||||
|
* @date 2024/8/3 |
||||
|
*/ |
||||
|
|
||||
|
@Slf4j |
||||
|
@RestController |
||||
|
@Api(tags = "店铺关联接口") |
||||
|
@RequestMapping("/hiver/shopRelations/") |
||||
|
@Transactional |
||||
|
public class ShopRelationsController { |
||||
|
|
||||
|
@Autowired |
||||
|
private ShopRelationsService shopRelationsService; |
||||
|
|
||||
|
/** |
||||
|
* 新增店铺关联信息 |
||||
|
* |
||||
|
* @param shopRelations |
||||
|
* @return Result |
||||
|
* @author 王富康 |
||||
|
* @date 2024/8/4 |
||||
|
*/ |
||||
|
@RequestMapping(value = "/addShopRelations", method = RequestMethod.POST) |
||||
|
@ApiOperation("新增店铺关联信息") |
||||
|
public Result addShopRelations(@RequestBody ShopRelations shopRelations) { |
||||
|
|
||||
|
if (StringUtils.isEmpty(shopRelations.getShopOwnerId())) { |
||||
|
return ResultUtil.error("店主id不能为空"); |
||||
|
} |
||||
|
if (StringUtils.isEmpty(shopRelations.getShopId())) { |
||||
|
return ResultUtil.error("店铺id不能为空"); |
||||
|
} |
||||
|
try { |
||||
|
shopRelationsService.addShopRelations(shopRelations); |
||||
|
return ResultUtil.success("新增店铺关联信息成功"); |
||||
|
} catch (Exception e) { |
||||
|
log.error(e.getMessage(), e); |
||||
|
return ResultUtil.error("新增店铺关联信息失败"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 删除分组
|
||||
|
@RequestMapping(value = "/deleteShopRelations", method = RequestMethod.POST) |
||||
|
@ApiOperation("删除店铺关联信息") |
||||
|
public Result deleteShopRelations(String id) { |
||||
|
|
||||
|
if (StringUtils.isEmpty(id)) { |
||||
|
return ResultUtil.error("id不能为空"); |
||||
|
} |
||||
|
try { |
||||
|
shopRelationsService.deleteShopRelations(id); |
||||
|
return ResultUtil.success("删除店铺关联信息成功"); |
||||
|
} catch (Exception e) { |
||||
|
log.error(e.getMessage(), e); |
||||
|
return ResultUtil.error("删除店铺关联信息失败"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据店铺id获取关联的店铺信息 |
||||
|
* |
||||
|
* @param shopId |
||||
|
* @return Result |
||||
|
* @author 王富康 |
||||
|
* @date 2024/8/4 |
||||
|
*/ |
||||
|
@RequestMapping(value = "/getShopRelations", method = RequestMethod.POST) |
||||
|
@ApiOperation("根据店铺id获取关联的店铺信息") |
||||
|
public Result getShopRelations(String shopId) { |
||||
|
|
||||
|
if (StringUtils.isEmpty(shopId)) { |
||||
|
return ResultUtil.error("店铺id不能为空"); |
||||
|
} |
||||
|
try { |
||||
|
List<ShopRelationsVo> shopRelationsVoList = shopRelationsService.getShopRelations(shopId); |
||||
|
return new ResultUtil<List<ShopRelationsVo>>().setData(shopRelationsVoList); |
||||
|
} catch (Exception e) { |
||||
|
log.error(e.getMessage(), e); |
||||
|
return ResultUtil.error("获取店铺关联信息失败"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据店主id查询分组 |
||||
|
* |
||||
|
* @param shopOwnerId |
||||
|
* @return Result |
||||
|
* @author 王富康 |
||||
|
* @date 2024/8/4 |
||||
|
*/ |
||||
|
@RequestMapping(value = "/getShopRelationsByShopOwnerId", method = RequestMethod.POST) |
||||
|
@ApiOperation("查询店主的分组") |
||||
|
public Result getShopRelationsByShopOwnerId(String shopOwnerId) { |
||||
|
|
||||
|
if (StringUtils.isEmpty(shopOwnerId)) { |
||||
|
return ResultUtil.error("店主id不能为空"); |
||||
|
} |
||||
|
try { |
||||
|
List<ShopRelations> shopRelationsVoList = shopRelationsService.getShopRelationsByShopOwnerId(shopOwnerId); |
||||
|
return new ResultUtil<List<ShopRelations>>().setData(shopRelationsVoList); |
||||
|
} catch (Exception e) { |
||||
|
log.error(e.getMessage(), e); |
||||
|
return ResultUtil.error("查询店主的分组失败"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 修改分组店铺信息
|
||||
|
@RequestMapping(value = "/updateShopRelations", method = RequestMethod.POST) |
||||
|
@ApiOperation("修改分组店铺信息") |
||||
|
public Result updateShopRelations(@RequestBody ShopRelations shopRelations) { |
||||
|
|
||||
|
if (StringUtils.isEmpty(shopRelations.getId())) { |
||||
|
return ResultUtil.error("id不能为空"); |
||||
|
} |
||||
|
try { |
||||
|
shopRelationsService.updateShopRelations(shopRelations); |
||||
|
return ResultUtil.success("修改分组店铺信息成功"); |
||||
|
} catch (Exception e) { |
||||
|
log.error(e.getMessage(), e); |
||||
|
return ResultUtil.error("修改分组店铺信息失败"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,32 @@ |
|||||
|
package cc.hiver.mall.shoprelations.entity; |
||||
|
|
||||
|
import cc.hiver.core.base.HiverBaseEntity; |
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel(value = "店铺关联表") |
||||
|
@TableName(value = "t_shop_relations", autoResultMap = true) |
||||
|
public class ShopRelations extends HiverBaseEntity { |
||||
|
|
||||
|
@ApiModelProperty(value = "创建人姓名") |
||||
|
private String createByName; |
||||
|
|
||||
|
@ApiModelProperty(value = "分组名称") |
||||
|
private String groupName; |
||||
|
|
||||
|
@ApiModelProperty(value = "关联店铺id") |
||||
|
private String shopId; |
||||
|
|
||||
|
@ApiModelProperty(value = "关联店铺名称") |
||||
|
private String shopName; |
||||
|
|
||||
|
@ApiModelProperty(value = "店主id") |
||||
|
private String shopOwnerId; |
||||
|
|
||||
|
@ApiModelProperty(value = "店主id") |
||||
|
private String shopOwnerName; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,30 @@ |
|||||
|
package cc.hiver.mall.shoprelations.mapper; |
||||
|
|
||||
|
import cc.hiver.mall.shoprelations.entity.ShopRelations; |
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
public interface ShopRelationsMapper extends BaseMapper<ShopRelations> { |
||||
|
|
||||
|
/** |
||||
|
* 根据店铺id获取关联的店铺信息 |
||||
|
* |
||||
|
* @param shopId |
||||
|
* @return List<ShopRelations> |
||||
|
* @author 王富康 |
||||
|
* @date 2024/8/4 |
||||
|
*/ |
||||
|
List<ShopRelations> getShopRelations(@Param("shopId") String shopId); |
||||
|
|
||||
|
/** |
||||
|
* 根据店主id查询分组 |
||||
|
* |
||||
|
* @param shopOwnerId |
||||
|
* @return List<ShopRelations> |
||||
|
* @author 王富康 |
||||
|
* @date 2024/8/4 |
||||
|
*/ |
||||
|
List<ShopRelations> getShopRelationsByShopOwnerId(@Param("shopOwnerId") String shopOwnerId); |
||||
|
} |
||||
@ -0,0 +1,56 @@ |
|||||
|
package cc.hiver.mall.shoprelations.service; |
||||
|
|
||||
|
import cc.hiver.mall.shoprelations.entity.ShopRelations; |
||||
|
import cc.hiver.mall.shoprelations.vo.ShopRelationsVo; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
public interface ShopRelationsService { |
||||
|
|
||||
|
/** |
||||
|
* 新增店铺关联信息 |
||||
|
* |
||||
|
* @param shopRelations |
||||
|
* @author 王富康 |
||||
|
* @date 2024/8/4 |
||||
|
*/ |
||||
|
void addShopRelations(ShopRelations shopRelations); |
||||
|
|
||||
|
/** |
||||
|
* 根据店铺id获取关联的店铺信息 |
||||
|
* |
||||
|
* @param shopId |
||||
|
* @return List<ShopRelationsVo> |
||||
|
* @author 王富康 |
||||
|
* @date 2024/8/4 |
||||
|
*/ |
||||
|
List<ShopRelationsVo> getShopRelations(String shopId); |
||||
|
|
||||
|
/** |
||||
|
* 删除店铺关联信息 |
||||
|
* |
||||
|
* @param id |
||||
|
* @author 王富康 |
||||
|
* @date 2024/8/4 |
||||
|
*/ |
||||
|
void deleteShopRelations(String id); |
||||
|
|
||||
|
/** |
||||
|
* 根据店主id查询分组 |
||||
|
* |
||||
|
* @param shopOwnerId |
||||
|
* @return List<ShopRelations> |
||||
|
* @author 王富康 |
||||
|
* @date 2024/8/4 |
||||
|
*/ |
||||
|
List<ShopRelations> getShopRelationsByShopOwnerId(String shopOwnerId); |
||||
|
|
||||
|
/** |
||||
|
* 修改分组店铺信息 |
||||
|
* |
||||
|
* @param shopRelations |
||||
|
* @author 王富康 |
||||
|
* @date 2024/8/4 |
||||
|
*/ |
||||
|
void updateShopRelations(ShopRelations shopRelations); |
||||
|
} |
||||
@ -0,0 +1,117 @@ |
|||||
|
package cc.hiver.mall.shoprelations.service.impl; |
||||
|
|
||||
|
import cc.hiver.mall.shoprelations.entity.ShopRelations; |
||||
|
import cc.hiver.mall.shoprelations.mapper.ShopRelationsMapper; |
||||
|
import cc.hiver.mall.shoprelations.service.ShopRelationsService; |
||||
|
import cc.hiver.mall.shoprelations.vo.ShopRelationsVo; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
@Service |
||||
|
public class ShopRelationsServiceImpl implements ShopRelationsService { |
||||
|
|
||||
|
@Autowired |
||||
|
private ShopRelationsMapper shopRelationsMapper; |
||||
|
|
||||
|
/** |
||||
|
* 新增店铺关联信息 |
||||
|
* |
||||
|
* @param shopRelations |
||||
|
* @author 王富康 |
||||
|
* @date 2024/8/4 |
||||
|
*/ |
||||
|
@Override |
||||
|
public void addShopRelations(ShopRelations shopRelations) { |
||||
|
shopRelationsMapper.insert(shopRelations); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据店铺id获取关联的店铺信息 |
||||
|
* |
||||
|
* @param shopId |
||||
|
* @return List<ShopRelationsVo> |
||||
|
* @author 王富康 |
||||
|
* @date 2024/8/4 |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<ShopRelationsVo> getShopRelations(String shopId) { |
||||
|
// 查询出来包含当前店铺的分组信息
|
||||
|
final List<ShopRelations> shopRelations = shopRelationsMapper.getShopRelations(shopId); |
||||
|
// 需要返回的跟当前店铺有关联的店铺信息
|
||||
|
final List<ShopRelationsVo> shopRelationsVo = new ArrayList<>(); |
||||
|
// 存放已经添加过的店铺id,用于去重
|
||||
|
final List<String> shopIds = new ArrayList<>(); |
||||
|
if (shopRelations != null && !shopRelations.isEmpty()) { |
||||
|
for (ShopRelations shopRelation : shopRelations) { |
||||
|
final String groupShopId = shopRelation.getShopId(); |
||||
|
final String shopName = shopRelation.getShopName(); |
||||
|
if (StringUtils.isEmpty(groupShopId)) { |
||||
|
// 根据都好分隔
|
||||
|
final String[] groupShopIdArray = groupShopId.split(","); |
||||
|
final String[] groupshopNameArray = shopName.split(","); |
||||
|
for (int i = 0; i < groupShopIdArray.length; i++) { |
||||
|
// 判断是否已经添加过
|
||||
|
if (!shopIds.contains(groupShopIdArray[i])) { |
||||
|
// 没有添加过,放进集合
|
||||
|
shopIds.add(groupShopIdArray[i]); |
||||
|
// 没有添加过,放回返回集合
|
||||
|
final ShopRelationsVo relationsVo = new ShopRelationsVo(); |
||||
|
relationsVo.setShopId(groupShopIdArray[i]); |
||||
|
relationsVo.setShopName(groupshopNameArray[i]); |
||||
|
shopRelationsVo.add(relationsVo); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return shopRelationsVo; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除店铺关联信息 |
||||
|
* |
||||
|
* @param id |
||||
|
* @author 王富康 |
||||
|
* @date 2024/8/4 |
||||
|
*/ |
||||
|
@Override |
||||
|
public void deleteShopRelations(String id) { |
||||
|
shopRelationsMapper.deleteById(id); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据店主id查询分组 |
||||
|
* |
||||
|
* @param shopOwnerId |
||||
|
* @return List<ShopRelations> |
||||
|
* @author 王富康 |
||||
|
* @date 2024/8/4 |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<ShopRelations> getShopRelationsByShopOwnerId(String shopOwnerId) { |
||||
|
return shopRelationsMapper.getShopRelationsByShopOwnerId(shopOwnerId); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 修改分组店铺信息 |
||||
|
* |
||||
|
* @param shopRelations |
||||
|
* @author 王富康 |
||||
|
* @date 2024/8/4 |
||||
|
*/ |
||||
|
@Override |
||||
|
public void updateShopRelations(ShopRelations shopRelations) { |
||||
|
// 只能修改分组名称及店铺信息,这里不要动其他数据
|
||||
|
// 获取到之前的数据
|
||||
|
final ShopRelations oldShopRelations = shopRelationsMapper.selectById(shopRelations.getId()); |
||||
|
oldShopRelations.setGroupName(shopRelations.getGroupName()); |
||||
|
oldShopRelations.setShopId(shopRelations.getShopId()); |
||||
|
oldShopRelations.setShopName(shopRelations.getShopName()); |
||||
|
// 更新
|
||||
|
shopRelationsMapper.updateById(oldShopRelations); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
package cc.hiver.mall.shoprelations.vo; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
public class ShopRelationsVo { |
||||
|
|
||||
|
@ApiModelProperty(value = "关联店铺名称") |
||||
|
private String shopName; |
||||
|
|
||||
|
@ApiModelProperty(value = "被关联店铺id") |
||||
|
private String shopId; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,100 @@ |
|||||
|
package cc.hiver.mall.utils; |
||||
|
|
||||
|
import com.google.zxing.BarcodeFormat; |
||||
|
import com.google.zxing.EncodeHintType; |
||||
|
import com.google.zxing.MultiFormatWriter; |
||||
|
import com.google.zxing.WriterException; |
||||
|
import com.google.zxing.client.j2se.MatrixToImageWriter; |
||||
|
import com.google.zxing.common.BitMatrix; |
||||
|
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
|
||||
|
import javax.imageio.ImageIO; |
||||
|
import java.awt.*; |
||||
|
import java.awt.image.BufferedImage; |
||||
|
import java.io.IOException; |
||||
|
import java.nio.file.FileSystems; |
||||
|
import java.nio.file.Path; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
@Slf4j |
||||
|
public class QRCodeUtils { |
||||
|
|
||||
|
public static void main(String[] args) { |
||||
|
//type是1,生成活动详情、报名的二维码,type是2,生成活动签到的二维码
|
||||
|
String content = "https://u.wechat.com/EOykWgVw3wwnB_JIawG96wY?1111111111112323232323231111112123132132111"; |
||||
|
//获取一个二维码图片
|
||||
|
try { |
||||
|
BitMatrix bitMatrix = createCode(content); |
||||
|
BufferedImage qrImage = MatrixToImageWriter.toBufferedImage(bitMatrix); |
||||
|
|
||||
|
// 调整图像大小
|
||||
|
BufferedImage resizedQrImage = new BufferedImage(250, 250, BufferedImage.TYPE_INT_RGB); |
||||
|
Graphics2D g2d = resizedQrImage.createGraphics(); |
||||
|
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); |
||||
|
g2d.drawImage(qrImage, 0, 0, 250, 250, null); |
||||
|
g2d.dispose(); |
||||
|
|
||||
|
Path path = FileSystems.getDefault().getPath("测试"); |
||||
|
ImageIO.write(resizedQrImage, "png", path.toFile()); |
||||
|
}catch (Exception e){ |
||||
|
log.error("生成二维码失败",e); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 生成二维码 |
||||
|
* @param content 二维码的内容 |
||||
|
* @return BitMatrix对象 |
||||
|
* */ |
||||
|
public static BitMatrix createCode(String content) throws IOException { |
||||
|
//二维码的宽高
|
||||
|
int width = 200; |
||||
|
int height = 200; |
||||
|
|
||||
|
//其他参数,如字符集编码
|
||||
|
Map<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>(); |
||||
|
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8"); |
||||
|
//容错级别为H
|
||||
|
hints.put(EncodeHintType.ERROR_CORRECTION , ErrorCorrectionLevel.H); |
||||
|
//白边的宽度,可取0~4
|
||||
|
hints.put(EncodeHintType.MARGIN , 0); |
||||
|
|
||||
|
BitMatrix bitMatrix = null; |
||||
|
try { |
||||
|
//生成矩阵,因为我的业务场景传来的是编码之后的URL,所以先解码
|
||||
|
bitMatrix = new MultiFormatWriter().encode(content, |
||||
|
BarcodeFormat.QR_CODE, width, height, hints); |
||||
|
|
||||
|
//bitMatrix = deleteWhite(bitMatrix);
|
||||
|
} catch (WriterException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
|
||||
|
return bitMatrix; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除生成的二维码周围的白边,根据审美决定是否删除 |
||||
|
* @param matrix BitMatrix对象 |
||||
|
* @return BitMatrix对象 |
||||
|
* */ |
||||
|
private static BitMatrix deleteWhite(BitMatrix matrix) { |
||||
|
int[] rec = matrix.getEnclosingRectangle(); |
||||
|
int resWidth = rec[2] + 1; |
||||
|
int resHeight = rec[3] + 1; |
||||
|
|
||||
|
BitMatrix resMatrix = new BitMatrix(resWidth, resHeight); |
||||
|
resMatrix.clear(); |
||||
|
for (int i = 0; i < resWidth; i++) { |
||||
|
for (int j = 0; j < resHeight; j++) { |
||||
|
if (matrix.get(i + rec[0], j + rec[1])) { |
||||
|
resMatrix.set(i, j); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return resMatrix; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,20 @@ |
|||||
|
package cc.hiver.mall.warehouse.constant; |
||||
|
|
||||
|
/** |
||||
|
* 仓库常量 |
||||
|
* |
||||
|
* @author 王富康 |
||||
|
* @date 2024/8/3 |
||||
|
*/ |
||||
|
public interface WarehouseConstant { |
||||
|
|
||||
|
/** |
||||
|
* 是否启用:0:是;1:否 |
||||
|
*/ |
||||
|
int[] IS_USE = {0,1}; |
||||
|
|
||||
|
/** |
||||
|
* 店铺状态:0:共用;1:按需分配 |
||||
|
*/ |
||||
|
int[] WAREHOUSE_STATUS = {0,0}; |
||||
|
} |
||||
@ -0,0 +1,119 @@ |
|||||
|
package cc.hiver.mall.warehouse.controller; |
||||
|
|
||||
|
import cc.hiver.core.common.utils.ResultUtil; |
||||
|
import cc.hiver.core.common.vo.Result; |
||||
|
import cc.hiver.mall.warehouse.entity.Warehouse; |
||||
|
import cc.hiver.mall.warehouse.service.WarehouseService; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMethod; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Slf4j |
||||
|
@RestController |
||||
|
@Api(tags = "仓库接口") |
||||
|
@RequestMapping("/hiver/warehouse/") |
||||
|
@Transactional |
||||
|
public class WarehouseController { |
||||
|
|
||||
|
@Autowired |
||||
|
private WarehouseService warehouseService; |
||||
|
|
||||
|
/** |
||||
|
* 新增仓库 |
||||
|
* |
||||
|
* @param warehouse |
||||
|
* @return Result |
||||
|
* @author 王富康 |
||||
|
* @date 2024/8/3 |
||||
|
*/ |
||||
|
@RequestMapping(value = "/addWarehouse", method = RequestMethod.POST) |
||||
|
public Result addWarehouse(@RequestBody Warehouse warehouse) { |
||||
|
if (StringUtils.isEmpty(warehouse.getWarehouseName())) { |
||||
|
return ResultUtil.error("仓库名称不能为空"); |
||||
|
} |
||||
|
if (StringUtils.isEmpty(warehouse.getShopOwnerId())) { |
||||
|
return ResultUtil.error("店主id不能为空"); |
||||
|
} |
||||
|
try { |
||||
|
warehouse = warehouseService.addWarehouse(warehouse); |
||||
|
return new ResultUtil<Warehouse>().setData(warehouse, "新增仓库成功"); |
||||
|
} catch (Exception e) { |
||||
|
log.error("新增仓库失败", e); |
||||
|
return ResultUtil.error("新增仓库失败"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 修改仓库信息 |
||||
|
* |
||||
|
* @param warehouse |
||||
|
* @return Result |
||||
|
* @author 王富康 |
||||
|
* @date 2024/8/3 |
||||
|
*/ |
||||
|
@RequestMapping(value = "/updateWarehouse", method = RequestMethod.POST) |
||||
|
public Result updateWarehouse(@RequestBody Warehouse warehouse) { |
||||
|
if (StringUtils.isEmpty(warehouse.getWarehouseName())) { |
||||
|
return ResultUtil.error("仓库名称不能为空"); |
||||
|
} |
||||
|
if (StringUtils.isEmpty(warehouse.getShopOwnerId())) { |
||||
|
return ResultUtil.error("店主id不能为空"); |
||||
|
} |
||||
|
try { |
||||
|
warehouse = warehouseService.updateWarehouse(warehouse); |
||||
|
return new ResultUtil<Warehouse>().setData(warehouse, "修改仓库成功"); |
||||
|
} catch (Exception e) { |
||||
|
log.error("修改仓库失败", e); |
||||
|
return ResultUtil.error("修改仓库失败"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除仓库 |
||||
|
* |
||||
|
* @param id |
||||
|
* @return Result |
||||
|
* @author 王富康 |
||||
|
* @date 2024/8/3 |
||||
|
*/ |
||||
|
@RequestMapping(value = "/deleteWarehouse", method = RequestMethod.POST) |
||||
|
public Result deleteWarehouse(String id) { |
||||
|
try { |
||||
|
boolean b = warehouseService.deleteWarehouse(id); |
||||
|
if (b) { |
||||
|
return ResultUtil.success("删除仓库成功"); |
||||
|
} else { |
||||
|
return ResultUtil.error("删除仓库失败"); |
||||
|
} |
||||
|
} catch (Exception e) { |
||||
|
log.error("删除仓库失败", e); |
||||
|
return ResultUtil.error("删除仓库失败"); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
// 根据店主id查询仓库信息
|
||||
|
@RequestMapping(value = "/getWarehouseByShopOwnerId", method = RequestMethod.POST) |
||||
|
public Result getWarehouseByShopOwnerId(String shopOwnerId) { |
||||
|
if (StringUtils.isEmpty(shopOwnerId)) { |
||||
|
return ResultUtil.error("店主id不能为空"); |
||||
|
} |
||||
|
try { |
||||
|
List<Warehouse> warehouseList = warehouseService.getWarehouseByShopOwnerId(shopOwnerId); |
||||
|
return new ResultUtil<List<Warehouse>>().setData(warehouseList, "查询仓库信息成功"); |
||||
|
} catch (Exception e) { |
||||
|
log.error("查询仓库信息失败", e); |
||||
|
return ResultUtil.error("查询仓库信息失败"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,101 @@ |
|||||
|
package cc.hiver.mall.warehouse.controller; |
||||
|
|
||||
|
import cc.hiver.core.common.utils.ResultUtil; |
||||
|
import cc.hiver.core.common.vo.Result; |
||||
|
import cc.hiver.mall.warehouse.entity.WarehouseShop; |
||||
|
import cc.hiver.mall.warehouse.service.WarehouseShopService; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMethod; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Slf4j |
||||
|
@RestController |
||||
|
@Api(tags = "仓库-店铺关联接口") |
||||
|
@RequestMapping("/hiver/warehouseShop/") |
||||
|
@Transactional |
||||
|
public class WarehouseShopController { |
||||
|
|
||||
|
@Autowired |
||||
|
private WarehouseShopService warehouseShopService; |
||||
|
|
||||
|
/** |
||||
|
* 添加仓库-店铺关联 |
||||
|
* |
||||
|
* @param warehouseShop |
||||
|
* @return Result |
||||
|
* @author 王富康 |
||||
|
* @date 2024/8/3 |
||||
|
*/ |
||||
|
@RequestMapping(value = "/addWarehouseShop", method = RequestMethod.POST) |
||||
|
public Result addWarehouseShop(@RequestBody WarehouseShop warehouseShop) { |
||||
|
// 仓库id不能为空
|
||||
|
if (StringUtils.isEmpty(warehouseShop.getWarehouseId())) { |
||||
|
return ResultUtil.error("仓库id不能为空"); |
||||
|
} |
||||
|
try { |
||||
|
warehouseShopService.addWarehouseShop(warehouseShop); |
||||
|
return ResultUtil.success("添加仓库-店铺关联成功"); |
||||
|
} catch (Exception e) { |
||||
|
log.error("添加仓库-店铺关联失败", e); |
||||
|
return ResultUtil.error("添加仓库-店铺关联失败"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除仓库-店铺关联 |
||||
|
* |
||||
|
* @param id |
||||
|
* @return Result |
||||
|
* @author 王富康 |
||||
|
* @date 2024/8/3 |
||||
|
*/ |
||||
|
@RequestMapping(value = "/deleteWarehouseShop", method = RequestMethod.POST) |
||||
|
public Result deleteWarehouseShop(String id) { |
||||
|
try { |
||||
|
warehouseShopService.deleteWarehouseShop(id); |
||||
|
return ResultUtil.success("删除仓库-店铺关联成功"); |
||||
|
} catch (Exception e) { |
||||
|
log.error("删除仓库-店铺关联失败", e); |
||||
|
return ResultUtil.error("删除仓库-店铺关联失败"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 根据仓库id获取关联的店铺信息
|
||||
|
@RequestMapping(value = "/getWarehouseShopByWarehouseId", method = RequestMethod.POST) |
||||
|
public Result getWarehouseShopByWarehouseId(String warehouseId) { |
||||
|
if(StringUtils.isEmpty(warehouseId)){ |
||||
|
return ResultUtil.error("仓库id不能为空"); |
||||
|
} |
||||
|
try { |
||||
|
List<WarehouseShop> warehouseShopList = warehouseShopService.getWarehouseShopByWarehouseId(warehouseId); |
||||
|
return new ResultUtil<List<WarehouseShop>>().setData(warehouseShopList); |
||||
|
} catch (Exception e) { |
||||
|
log.error("查询仓库-店铺关联失败", e); |
||||
|
return ResultUtil.error("查询仓库-店铺关联失败"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 查询当前店铺下的仓库信息
|
||||
|
@RequestMapping(value = "/getWarehouseShopByShopId", method = RequestMethod.POST) |
||||
|
public Result getWarehouseShopByShopId(String shopId) { |
||||
|
if(StringUtils.isEmpty(shopId)){ |
||||
|
return ResultUtil.error("店铺id不能为空"); |
||||
|
} |
||||
|
try { |
||||
|
List<WarehouseShop> warehouseShopList = warehouseShopService.getWarehouseShopByShopId(shopId); |
||||
|
return new ResultUtil<List<WarehouseShop>>().setData(warehouseShopList); |
||||
|
}catch (Exception e){ |
||||
|
log.error("查询仓库-店铺关联失败", e); |
||||
|
return ResultUtil.error("查询仓库-店铺关联失败"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,41 @@ |
|||||
|
package cc.hiver.mall.warehouse.entity; |
||||
|
|
||||
|
import cc.hiver.core.base.HiverBaseEntity; |
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel(value = "仓库表") |
||||
|
@TableName(value = "t_warehouse", autoResultMap = true) |
||||
|
public class Warehouse extends HiverBaseEntity { |
||||
|
|
||||
|
@ApiModelProperty(value = "创建人名称") |
||||
|
private String createByName; |
||||
|
|
||||
|
@ApiModelProperty(value = "仓库名称") |
||||
|
private String warehouseName; |
||||
|
|
||||
|
@ApiModelProperty(value = "仓库地址") |
||||
|
private String warehouseAddress; |
||||
|
|
||||
|
@ApiModelProperty(value = "店铺状态:0:共用;1:按需分配") |
||||
|
private Integer warehouseStatus; |
||||
|
|
||||
|
@ApiModelProperty(value = "是否启用:0:是;1:否") |
||||
|
private Integer isUse; |
||||
|
|
||||
|
@ApiModelProperty(value = "店主id") |
||||
|
private String shopOwnerId; |
||||
|
|
||||
|
@ApiModelProperty(value = "店主名称") |
||||
|
private String shopOwnerName; |
||||
|
|
||||
|
@ApiModelProperty(value = "备注") |
||||
|
private String remark; |
||||
|
|
||||
|
@ApiModelProperty(value = "排序") |
||||
|
private Integer sort; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,40 @@ |
|||||
|
package cc.hiver.mall.warehouse.entity; |
||||
|
|
||||
|
import cc.hiver.core.base.HiverBaseEntity; |
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel(value = "仓库-店铺关联表") |
||||
|
@TableName(value = "t_warehouse_shop", autoResultMap = true) |
||||
|
public class WarehouseShop extends HiverBaseEntity { |
||||
|
|
||||
|
@ApiModelProperty(value = "创建人名称") |
||||
|
private String createByName; |
||||
|
|
||||
|
@ApiModelProperty(value = "店主id") |
||||
|
private String shopOwnerId; |
||||
|
|
||||
|
@ApiModelProperty(value = "店主名称") |
||||
|
private String shopOwnerName; |
||||
|
|
||||
|
@ApiModelProperty(value = "仓库id") |
||||
|
private String warehouseId; |
||||
|
|
||||
|
@ApiModelProperty(value = "仓库名称") |
||||
|
private String warehouseName; |
||||
|
|
||||
|
@ApiModelProperty(value = "仓库地址") |
||||
|
private String warehouseAddress; |
||||
|
|
||||
|
@ApiModelProperty(value = "店铺id") |
||||
|
private String shopId; |
||||
|
|
||||
|
@ApiModelProperty(value = "店铺名称") |
||||
|
private String shopName; |
||||
|
|
||||
|
@ApiModelProperty(value = "备注") |
||||
|
private String remark; |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
package cc.hiver.mall.warehouse.mapper; |
||||
|
|
||||
|
import cc.hiver.mall.warehouse.entity.Warehouse; |
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
public interface WarehouseMappper extends BaseMapper<Warehouse> { |
||||
|
int addWarehouse(@Param("warehouse") Warehouse warehouse); |
||||
|
|
||||
|
int updateWarehouse(@Param("warehouse") Warehouse warehouse); |
||||
|
|
||||
|
int deleteWarehouse(@Param("id") String id); |
||||
|
|
||||
|
List<Warehouse> getWarehouseByShopOwnerId(@Param("shopOwnerId") String shopOwnerId); |
||||
|
|
||||
|
Warehouse getWarehouseById(@Param("id") String id); |
||||
|
} |
||||
@ -0,0 +1,17 @@ |
|||||
|
package cc.hiver.mall.warehouse.mapper; |
||||
|
|
||||
|
import cc.hiver.mall.warehouse.entity.WarehouseShop; |
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
public interface WarehouseShopMapper extends BaseMapper<WarehouseShop> { |
||||
|
void addWarehouseShop(@Param("warehouseShop") WarehouseShop warehouseShop); |
||||
|
|
||||
|
void deleteWarehouseShop(@Param("id") String id); |
||||
|
|
||||
|
List<WarehouseShop> getWarehouseShopByWarehouseId(@Param("warehouseId") String warehouseId); |
||||
|
|
||||
|
List<WarehouseShop> getWarehouseShopByShopId(@Param("shopId") String shopId); |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
package cc.hiver.mall.warehouse.service; |
||||
|
|
||||
|
import cc.hiver.mall.warehouse.entity.Warehouse; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
public interface WarehouseService { |
||||
|
Warehouse addWarehouse(Warehouse warehouse); |
||||
|
|
||||
|
Warehouse updateWarehouse(Warehouse warehouse); |
||||
|
|
||||
|
boolean deleteWarehouse(String id); |
||||
|
|
||||
|
List<Warehouse> getWarehouseByShopOwnerId(String shopOwnerId); |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
package cc.hiver.mall.warehouse.service; |
||||
|
|
||||
|
import cc.hiver.mall.warehouse.entity.WarehouseShop; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
public interface WarehouseShopService { |
||||
|
|
||||
|
void addWarehouseShop(WarehouseShop warehouseShop); |
||||
|
|
||||
|
void deleteWarehouseShop(String id); |
||||
|
|
||||
|
List<WarehouseShop> getWarehouseShopByWarehouseId(String warehouseId); |
||||
|
|
||||
|
List<WarehouseShop> getWarehouseShopByShopId(String shopId); |
||||
|
} |
||||
@ -0,0 +1,41 @@ |
|||||
|
package cc.hiver.mall.warehouse.service.impl; |
||||
|
|
||||
|
import cc.hiver.mall.warehouse.entity.Warehouse; |
||||
|
import cc.hiver.mall.warehouse.mapper.WarehouseMappper; |
||||
|
import cc.hiver.mall.warehouse.service.WarehouseService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Service |
||||
|
public class WarehouseServiceImpl implements WarehouseService { |
||||
|
|
||||
|
@Autowired |
||||
|
private WarehouseMappper warehouseMappper; |
||||
|
|
||||
|
@Override |
||||
|
public Warehouse addWarehouse(Warehouse warehouse) { |
||||
|
final String id = warehouse.getId(); |
||||
|
warehouseMappper.insert(warehouse); |
||||
|
return warehouseMappper.getWarehouseById(id); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Warehouse updateWarehouse(Warehouse warehouse) { |
||||
|
final String id = warehouse.getId(); |
||||
|
warehouseMappper.updateById(warehouse); |
||||
|
return warehouseMappper.getWarehouseById(id); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public boolean deleteWarehouse(String id) { |
||||
|
final int i = warehouseMappper.deleteWarehouse(id); |
||||
|
return i > 0; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<Warehouse> getWarehouseByShopOwnerId(String shopOwnerId) { |
||||
|
return warehouseMappper.getWarehouseByShopOwnerId(shopOwnerId); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,36 @@ |
|||||
|
package cc.hiver.mall.warehouse.service.impl; |
||||
|
|
||||
|
import cc.hiver.mall.warehouse.entity.WarehouseShop; |
||||
|
import cc.hiver.mall.warehouse.mapper.WarehouseShopMapper; |
||||
|
import cc.hiver.mall.warehouse.service.WarehouseShopService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Service |
||||
|
public class WarehouseShopServiceImpl implements WarehouseShopService { |
||||
|
|
||||
|
@Autowired |
||||
|
private WarehouseShopMapper warehouseShopMapper; |
||||
|
|
||||
|
@Override |
||||
|
public void addWarehouseShop(WarehouseShop warehouseShop) { |
||||
|
warehouseShopMapper.insert(warehouseShop); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void deleteWarehouseShop(String id) { |
||||
|
warehouseShopMapper.deleteWarehouseShop(id); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<WarehouseShop> getWarehouseShopByWarehouseId(String warehouseId) { |
||||
|
return warehouseShopMapper.getWarehouseShopByWarehouseId(warehouseId); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<WarehouseShop> getWarehouseShopByShopId(String shopId) { |
||||
|
return warehouseShopMapper.getWarehouseShopByShopId(shopId); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,46 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
<mapper namespace="cc.hiver.mall.shoprelations.mapper.ShopRelationsMapper"> |
||||
|
<resultMap id="BaseResultMap" type="cc.hiver.mall.shoprelations.entity.ShopRelations"> |
||||
|
<id column="id" jdbcType="VARCHAR" property="id" /> |
||||
|
<result column="create_by" jdbcType="VARCHAR" property="createBy" /> |
||||
|
<result column="create_by_name" jdbcType="VARCHAR" property="createByName" /> |
||||
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> |
||||
|
<result column="del_flag" jdbcType="INTEGER" property="delFlag" /> |
||||
|
<result column="update_by" jdbcType="VARCHAR" property="updateBy" /> |
||||
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> |
||||
|
<result column="group_name" jdbcType="VARCHAR" property="groupName" /> |
||||
|
<result column="shop_owner_id" jdbcType="VARCHAR" property="shopOwnerId" /> |
||||
|
<result column="shop_owner_name" jdbcType="VARCHAR" property="shopOwnerName" /> |
||||
|
<result column="shop_id" jdbcType="VARCHAR" property="shopId" /> |
||||
|
<result column="shop_name" jdbcType="VARCHAR" property="shopName" /> |
||||
|
|
||||
|
|
||||
|
</resultMap> |
||||
|
<sql id="Base_Column_List"> |
||||
|
id, create_by,create_by_name, create_time, del_flag, update_by, update_time, |
||||
|
group_name,shop_owner_id, shop_owner_name,shop_id,shop_name |
||||
|
</sql> |
||||
|
<insert id="insert" parameterType="cc.hiver.mall.shoprelations.entity.ShopRelations"> |
||||
|
insert into t_shop_relations (id, create_by, create_by_name, create_time, del_flag, update_by, update_time, |
||||
|
group_name,shop_owner_id, shop_owner_name,shop_id,shop_name) |
||||
|
values (#{id,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, #{createByName,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, |
||||
|
#{delFlag,jdbcType=INTEGER}, #{updateBy,jdbcType=VARCHAR}, #{updateTime,jdbcType=TIMESTAMP}, |
||||
|
#{groupName,jdbcType=VARCHAR},#{shopOwnerId,jdbcType=VARCHAR},#{shopOwnerName,jdbcType=VARCHAR}, |
||||
|
#{shopId,jdbcType=VARCHAR},#{shopName,jdbcType=VARCHAR}) |
||||
|
</insert> |
||||
|
<select id="getShopRelations" resultMap="BaseResultMap"> |
||||
|
select |
||||
|
<include refid="Base_Column_List" /> |
||||
|
from t_shop_relations |
||||
|
where shop_id like concat('%',#{shopId},'%') |
||||
|
</select> |
||||
|
|
||||
|
<select id="getShopRelationsByShopOwnerId" resultMap="BaseResultMap"> |
||||
|
select |
||||
|
<include refid="Base_Column_List" /> |
||||
|
from t_shop_relations |
||||
|
where shop_owner_id = #{shopOwnerId} |
||||
|
</select> |
||||
|
|
||||
|
</mapper> |
||||
@ -0,0 +1,85 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
<mapper namespace="cc.hiver.mall.warehouse.mapper.WarehouseMappper"> |
||||
|
<resultMap id="BaseResultMap" type="cc.hiver.mall.warehouse.entity.Warehouse"> |
||||
|
<id column="id" jdbcType="VARCHAR" property="id" /> |
||||
|
<result column="create_by" jdbcType="VARCHAR" property="createBy" /> |
||||
|
<result column="create_by_name" jdbcType="VARCHAR" property="createByName" /> |
||||
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> |
||||
|
<result column="del_flag" jdbcType="INTEGER" property="delFlag" /> |
||||
|
<result column="update_by" jdbcType="VARCHAR" property="updateBy" /> |
||||
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> |
||||
|
<result column="warehouse_name" jdbcType="VARCHAR" property="warehouseName" /> |
||||
|
<result column="warehouse_address" jdbcType="VARCHAR" property="warehouseAddress" /> |
||||
|
<result column="warehouse_status" jdbcType="INTEGER" property="warehouseStatus" /> |
||||
|
<result column="is_use" jdbcType="INTEGER" property="isUse" /> |
||||
|
<result column="shop_owner_id" jdbcType="VARCHAR" property="shopOwnerId" /> |
||||
|
<result column="shop_owner_name" jdbcType="VARCHAR" property="shopOwnerName" /> |
||||
|
<result column="remark" jdbcType="VARCHAR" property="remark" /> |
||||
|
<result column="sort" jdbcType="INTEGER" property="sort" /> |
||||
|
</resultMap> |
||||
|
<sql id="Base_Column_List"> |
||||
|
id, create_by,create_by_name, create_time, del_flag, update_by, update_time, |
||||
|
warehouse_name, warehouse_address, warehouse_status, is_use, shop_owner_id, |
||||
|
shop_owner_name, remark, sort |
||||
|
</sql> |
||||
|
|
||||
|
<insert id="addWarehouse" parameterType="cc.hiver.mall.warehouse.entity.Warehouse"> |
||||
|
insert into t_warehouse |
||||
|
(id, create_by, create_by_name, create_time, del_flag, update_by, update_time, |
||||
|
warehouse_name, warehouse_address, warehouse_status, is_use, shop_owner_id, |
||||
|
shop_owner_name, remark, sort) |
||||
|
values (#{warehouse.id,jdbcType=VARCHAR}, #{warehouse.createBy,jdbcType=VARCHAR},#{warehouse.createByName,jdbcType=VARCHAR}, |
||||
|
#{warehouse.createTime,jdbcType=TIMESTAMP}, #{warehouse.delFlag,jdbcType=INTEGER}, #{warehouse.updateBy,jdbcType=VARCHAR}, |
||||
|
#{warehouse.updateTime,jdbcType=TIMESTAMP}, #{warehouse.warehouseName,jdbcType=VARCHAR}, #{warehouse.warehouseAddress,jdbcType=VARCHAR}, |
||||
|
#{warehouse.warehouseStatus,jdbcType=INTEGER}, #{warehouse.isUse,jdbcType=INTEGER}, #{warehouse.shopOwnerId,jdbcType=VARCHAR}, |
||||
|
#{warehouse.shopOwnerName,jdbcType=VARCHAR}, #{warehouse.remark,jdbcType=VARCHAR}, #{warehouse.sort,jdbcType=INTEGER}) |
||||
|
</insert> |
||||
|
|
||||
|
<update id="updateWarehouse" parameterType="cc.hiver.mall.warehouse.entity.Warehouse"> |
||||
|
update t_warehouse |
||||
|
<set> |
||||
|
<if test="warehouse.delFlag != null"> |
||||
|
del_flag = #{warehouse.delFlag}, |
||||
|
</if> |
||||
|
<if test="warehouse.updateBy != null"> |
||||
|
update_by = #{warehouse.updateBy}, |
||||
|
</if> |
||||
|
<if test="warehouse.updateTime != null"> |
||||
|
update_time = #{warehouse.updateTime}, |
||||
|
</if> |
||||
|
<if test="warehouse.warehouseName != null"> |
||||
|
warehouse_name = #{warehouse.warehouseName}, |
||||
|
</if> |
||||
|
<if test="warehouse.warehouseAddress != null"> |
||||
|
warehouse_address = #{warehouse.warehouseAddress}, |
||||
|
</if> |
||||
|
<if test="warehouse.remark != null"> |
||||
|
remark = #{warehouse.remark}, |
||||
|
</if> |
||||
|
<if test="warehouse.sort != null"> |
||||
|
sort = #{warehouse.sort}, |
||||
|
</if> |
||||
|
</set> |
||||
|
where id = #{warehouse.id,jdbcType=VARCHAR} |
||||
|
</update> |
||||
|
|
||||
|
<update id="deleteWarehouse" parameterType="java.lang.String"> |
||||
|
update t_warehouse set del_flag = 1 where id = #{id} |
||||
|
</update> |
||||
|
|
||||
|
<select id="getWarehouseByShopOwnerId" resultMap="BaseResultMap"> |
||||
|
select |
||||
|
<include refid="Base_Column_List"/> |
||||
|
from t_warehouse |
||||
|
where shop_owner_id = #{shopOwnerId} |
||||
|
</select> |
||||
|
|
||||
|
<!--根据主键id获取仓库信息--> |
||||
|
<select id="getWarehouseById" parameterType="java.lang.String" resultMap="BaseResultMap"> |
||||
|
select |
||||
|
<include refid="Base_Column_List"/> |
||||
|
from t_warehouse |
||||
|
where id = #{id} |
||||
|
</select> |
||||
|
</mapper> |
||||
@ -0,0 +1,61 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
<mapper namespace="cc.hiver.mall.warehouse.mapper.WarehouseShopMapper"> |
||||
|
<resultMap id="BaseResultMap" type="cc.hiver.mall.warehouse.entity.WarehouseShop"> |
||||
|
<id column="id" jdbcType="VARCHAR" property="id" /> |
||||
|
<result column="create_by" jdbcType="VARCHAR" property="createBy" /> |
||||
|
<result column="create_by_name" jdbcType="VARCHAR" property="createByName" /> |
||||
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> |
||||
|
<result column="del_flag" jdbcType="INTEGER" property="delFlag" /> |
||||
|
<result column="update_by" jdbcType="VARCHAR" property="updateBy" /> |
||||
|
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> |
||||
|
<result column="shop_owner_id" jdbcType="VARCHAR" property="shopOwnerId" /> |
||||
|
<result column="shop_owner_name" jdbcType="VARCHAR" property="shopOwnerName" /> |
||||
|
<result column="warehouse_id" jdbcType="VARCHAR" property="warehouseId" /> |
||||
|
<result column="warehouse_name" jdbcType="VARCHAR" property="warehouseName" /> |
||||
|
<result column="warehouse_address" jdbcType="VARCHAR" property="warehouseAddress" /> |
||||
|
<result column="shop_id" jdbcType="VARCHAR" property="shopId" /> |
||||
|
<result column="shop_name" jdbcType="VARCHAR" property="shopName" /> |
||||
|
<result column="remark" jdbcType="VARCHAR" property="remark" /> |
||||
|
|
||||
|
</resultMap> |
||||
|
<sql id="Base_Column_List"> |
||||
|
id, create_by,create_by_name, create_time, del_flag, update_by, update_time, |
||||
|
shop_owner_id, shop_owner_name, warehouse_id, warehouse_name, warehouse_address, |
||||
|
shop_id, shop_name, remark |
||||
|
</sql> |
||||
|
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap"> |
||||
|
select |
||||
|
<include refid="Base_Column_List" /> |
||||
|
from t_warehouse_shop |
||||
|
where id = #{id,jdbcType=VARCHAR} |
||||
|
</select> |
||||
|
<insert id="addWarehouseShop" parameterType="cc.hiver.mall.warehouse.entity.WarehouseShop"> |
||||
|
insert into t_warehouse_shop (id, create_by, create_by_name, create_time, del_flag, update_by, update_time, |
||||
|
shop_owner_id, shop_owner_name, warehouse_id, warehouse_name, warehouse_address, |
||||
|
shop_id, shop_name, remark) |
||||
|
values (#{warehouseShop.id,jdbcType=VARCHAR}, #{warehouseShop.createBy,jdbcType=VARCHAR},#{warehouseShop.createByName,jdbcType=VARCHAR}, |
||||
|
#{warehouseShop.createTime,jdbcType=TIMESTAMP}, #{warehouseShop.delFlag,jdbcType=INTEGER}, #{warehouseShop.updateBy,jdbcType=VARCHAR}, |
||||
|
#{warehouseShop.updateTime,jdbcType=TIMESTAMP},#{warehouseShop.shopOwnerId,jdbcType=VARCHAR}, #{warehouseShop.shopOwnerName,jdbcType=VARCHAR}, |
||||
|
#{warehouseShop.warehouseId,jdbcType=VARCHAR}, #{warehouseShop.warehouseName,jdbcType=VARCHAR}, #{warehouseShop.warehouseAddress,jdbcType=VARCHAR}, |
||||
|
#{warehouseShop.shopId,jdbcType=VARCHAR}, #{warehouseShop.shopName,jdbcType=VARCHAR}, #{warehouseShop.remark,jdbcType=VARCHAR}) |
||||
|
</insert> |
||||
|
|
||||
|
<delete id="deleteWarehouseShop" parameterType="java.lang.String"> |
||||
|
delete from t_warehouse_shop where id = #{id,jdbcType=VARCHAR} |
||||
|
</delete> |
||||
|
|
||||
|
<select id="getWarehouseShopByShopId" parameterType="java.lang.String" resultMap="BaseResultMap"> |
||||
|
select |
||||
|
<include refid="Base_Column_List" /> |
||||
|
from t_warehouse_shop |
||||
|
where shop_id = #{shopId,jdbcType=VARCHAR} |
||||
|
</select> |
||||
|
|
||||
|
<select id="getWarehouseShopByWarehouseId" parameterType="java.lang.String" resultMap="BaseResultMap"> |
||||
|
select |
||||
|
<include refid="Base_Column_List" /> |
||||
|
from t_warehouse_shop |
||||
|
where warehouse_id = #{warehouseId,jdbcType=VARCHAR} |
||||
|
</select> |
||||
|
</mapper> |
||||
Loading…
Reference in new issue