k94314517
2023-09-11 008d985cc68391844a12a0bfc77ecc852e8b8adb
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);
@@ -104,7 +113,7 @@
        String prefixUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode()
                + systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.PROJECTS).getCode();
        Brand brand = brandMapper.selectById(id);
        brand.setPrefixUrl(prefixUrl);
        brand.setImgfullurl(prefixUrl+brand.getImgurl());
        return brand;
    }
@@ -124,11 +133,11 @@
        String prefixUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode()
                + systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.PROJECTS).getCode();
        for (Brand b:list) {
            b.setPrefixUrl(prefixUrl);
            b.setImgfullurl(prefixUrl+b.getImgurl());
        }
        return list;
    }
    @Override
    public PageData<Brand> findPage(PageWrap<Brand> pageWrap) {
        IPage<Brand> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
@@ -146,7 +155,7 @@
        String prefixUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode()
                + systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.PROJECTS).getCode();
        brandIPage.getRecords().forEach(i->{
            i.setPrefixUrl(prefixUrl);
            i.setImgfullurl(prefixUrl+i.getImgurl());
        });
        return PageData.from(brandIPage);
    }