k94314517
2023-09-11 008d985cc68391844a12a0bfc77ecc852e8b8adb
基础字段
已修改1个文件
11 ■■■■■ 文件已修改
server/service/src/main/java/com/doumee/service/business/impl/BrandServiceImpl.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
server/service/src/main/java/com/doumee/service/business/impl/BrandServiceImpl.java
@@ -11,11 +11,13 @@
import com.doumee.dao.business.BrandMapper;
import com.doumee.dao.business.model.Brand;
import com.doumee.dao.business.model.Category;
import com.doumee.dao.business.model.Goods;
import com.doumee.service.business.BrandService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -41,7 +43,14 @@
    @Override
    public Integer create(Brand brand) {
        LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        if(brandMapper.selectCount(new QueryWrapper<Brand>().eq("ISDELETED",Constants.ZERO).eq("name",brand.getName()))>0){
        if(brandMapper.selectCount(new QueryWrapper<Brand>()
                .eq("ISDELETED",Constants.ZERO)
                .eq(user.getType().equals(Constants.UserType.SYSTEM),"name",brand.getName())
                .and(user.getType().equals(Constants.UserType.COMPANY),
                        i->i.apply(" name = '"+brand.getName()+"' and type = 1 ")
                                .or().apply( "  name = '"+brand.getName()+"' and COMPANY_ID = '"+user.getCompanyId()+"' and type = 0 ")
                )
        )>0){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+brand.getName()+"】已存在");
        };
        brand.setStatus(Constants.ZERO);