|
|
@@ -2,6 +2,8 @@ package com.ruoyi.clock.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.ruoyi.clock.domain.Agent;
|
|
|
+import com.ruoyi.clock.exception.AgentExceptionEnum;
|
|
|
import com.ruoyi.clock.exception.ShopExceptionEnum;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.BeanCopyUtils;
|
|
|
@@ -66,7 +68,7 @@ public class ShopServiceImpl implements IShopService {
|
|
|
lqw.eq(bo.getAgentId() != null, Shop::getAgentId, bo.getAgentId());
|
|
|
lqw.like(StringUtils.isNotBlank(bo.getShopName()), Shop::getShopName, bo.getShopName());
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getAddress()), Shop::getAddress, bo.getAddress());
|
|
|
- lqw.eq(StringUtils.isNotBlank(bo.getContact()), Shop::getContact, bo.getContact());
|
|
|
+ lqw.like(StringUtils.isNotBlank(bo.getContact()), Shop::getContact, bo.getContact());
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getPhonenumber()), Shop::getPhonenumber, bo.getPhonenumber());
|
|
|
return lqw;
|
|
|
}
|
|
|
@@ -92,7 +94,7 @@ public class ShopServiceImpl implements IShopService {
|
|
|
public Shop loadById(Long shopId, Boolean tw){
|
|
|
Shop info = this.baseMapper.selectById(shopId);
|
|
|
if(ObjectUtil.isEmpty(info) && tw){
|
|
|
- throw new ServiceException(ShopExceptionEnum.Shop_IS_NOT_EXISTS);
|
|
|
+ throw new ServiceException(ShopExceptionEnum.SHOP_IS_NOT_EXISTS);
|
|
|
}
|
|
|
return info;
|
|
|
}
|
|
|
@@ -105,8 +107,8 @@ public class ShopServiceImpl implements IShopService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Boolean insertByBo(ShopBo bo) {
|
|
|
+ validEntityBeforeSave(bo);
|
|
|
Shop add = BeanUtil.toBean(bo, Shop.class);
|
|
|
- validEntityBeforeSave(add);
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
if (flag) {
|
|
|
bo.setShopId(add.getShopId());
|
|
|
@@ -122,21 +124,31 @@ public class ShopServiceImpl implements IShopService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Boolean updateByBo(ShopBo bo) {
|
|
|
+ validEntityBeforeSave(bo);
|
|
|
Shop shop = baseMapper.selectById(bo.getShopId());
|
|
|
Shop update = BeanCopyUtils.copy(bo, shop);
|
|
|
- validEntityBeforeSave(update);
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 保存前的数据校验
|
|
|
*
|
|
|
- * @param entity 实体类数据
|
|
|
+ * @param bo 实体类数据
|
|
|
*/
|
|
|
- private void validEntityBeforeSave(Shop entity){
|
|
|
+ private void validEntityBeforeSave(ShopBo bo){
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
+ Shop shop = getShopByName(bo.getShopName());
|
|
|
+ if(ObjectUtil.isNotNull(shop)&& !shop.getShopId().equals(bo.getShopId())){
|
|
|
+ throw new ServiceException(ShopExceptionEnum.SHOP_REPEAT);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public Shop getShopByName(String shopName) {
|
|
|
+ return baseMapper.selectOne(new LambdaQueryWrapper<Shop>().eq(Shop::getShopName,shopName)
|
|
|
+ .last("limit 1"));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 批量删除门店信息
|
|
|
*
|