|
@@ -15,27 +15,43 @@ import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-@RequiredArgsConstructor
|
|
|
+import java.util.Arrays;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 品牌服务实现
|
|
|
+ */
|
|
|
@Service
|
|
|
+@RequiredArgsConstructor
|
|
|
public class BrandServiceImpl implements BrandService {
|
|
|
|
|
|
private final BrandMapper brandMapper;
|
|
|
|
|
|
/**
|
|
|
- * 查询品牌列表
|
|
|
- * @param brand 品牌Bo对象
|
|
|
+ * 品牌类型
|
|
|
+ */
|
|
|
+ private static final String BRAND_TYPE = "2";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据Brand对象分页查询品牌数据
|
|
|
+ * @param brandBo BrandBo对象
|
|
|
* @param pageQuery 查询条件
|
|
|
* @return 分页结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public TableDataInfo<BrandVo> selectPageBrandList(BrandBo brand,PageQuery pageQuery) {
|
|
|
+ public TableDataInfo<BrandVo> selectPageBrandList(BrandBo brandBo,PageQuery pageQuery) {
|
|
|
QueryWrapper<Brand> qw = new QueryWrapper<>();
|
|
|
- qw.eq(StringUtils.isNotBlank(brand.getName()), "name", brand.getName());
|
|
|
- qw.eq("type", "2");
|
|
|
+ qw.eq(StringUtils.isNotBlank(brandBo.getName()), "name", brandBo.getName());
|
|
|
+ qw.eq(null != brandBo.getTenant_id(),"tenant_id", brandBo.getTenant_id());
|
|
|
+ qw.eq("type", BRAND_TYPE);
|
|
|
Page<BrandVo> page = brandMapper.selectVoPage(pageQuery.build(), qw);
|
|
|
return TableDataInfo.build(page);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 新增品牌
|
|
|
+ * @param brandBo BrandBo对象
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
@Override
|
|
|
public int insertBrand(BrandBo brandBo) {
|
|
|
Brand brand = MapstructUtils.convert(brandBo, Brand.class);
|
|
@@ -43,6 +59,11 @@ public class BrandServiceImpl implements BrandService {
|
|
|
return brandMapper.insert(brand);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 修改品牌
|
|
|
+ * @param brandBo BrandBo对象
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
@Override
|
|
|
public int updateBrand(BrandBo brandBo) {
|
|
|
Brand brand = MapstructUtils.convert(brandBo, Brand.class);
|
|
@@ -52,20 +73,27 @@ public class BrandServiceImpl implements BrandService {
|
|
|
return brandMapper.update(brand,qw);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 批量删除品牌
|
|
|
+ * @param brandIds BrandIds
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
@Override
|
|
|
- public int deleteBrandById(int brandId) {
|
|
|
- return brandMapper.deleteById(brandId);
|
|
|
+ public int deleteBrandById(Long[] brandIds) {
|
|
|
+ return brandMapper.deleteByIds(Arrays.asList(brandIds));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 保存前校验
|
|
|
- * @param entity 实体对象
|
|
|
+ * @param entity Brand实体对象
|
|
|
*/
|
|
|
private void validEntityBeforeSave(Brand entity) {
|
|
|
if (!StringUtils.isNotEmpty(entity.getName())) {
|
|
|
throw new ServiceException("名称不能为空!");
|
|
|
} else if (!StringUtils.isNoneBlank(entity.getType())) {
|
|
|
throw new ServiceException("类型不能为空!");
|
|
|
+ } else if (!(entity.getType().equals("1") || entity.getType().equals("2"))) {
|
|
|
+ throw new ServiceException("类型错误!");
|
|
|
}
|
|
|
}
|
|
|
|