| | |
| | | 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; |
| | |
| | | @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); |