| | |
| | | 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.getKey()),"name",brand.getName()) |
| | | .and(user.getType().equals(Constants.UserType.COMPANY.getKey()), |
| | | 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); |
| | |
| | | @Override |
| | | public void updateById(Brand brand) { |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(brandMapper.selectCount(new QueryWrapper<Brand>().eq("ISDELETED",Constants.ZERO).ne("id",brand.getId()).eq("name",brand.getName()))>0){ |
| | | if(brandMapper.selectCount(new QueryWrapper<Brand>() |
| | | .eq("ISDELETED",Constants.ZERO) |
| | | .eq(user.getType().equals(Constants.UserType.SYSTEM.getKey()),"name",brand.getName()) |
| | | .and(user.getType().equals(Constants.UserType.COMPANY.getKey()), |
| | | 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); |
| | |
| | | |
| | | @Override |
| | | public List<Brand> findList(Brand brand) { |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | QueryWrapper<Brand> wrapper = new QueryWrapper<>(brand); |
| | | wrapper.lambda().eq(Brand::getIsdeleted,Constants.ZERO); |
| | | wrapper.lambda().eq(Brand::getStatus,Constants.ZERO); |
| | | wrapper.lambda().orderByAsc(Brand::getSortnum); |
| | | // 类型 0企业 1平台 |
| | | if (Objects.isNull(user.getCompanyId())) { |
| | | wrapper.lambda().eq(Brand::getType,Constants.ONE); |
| | | }else { |
| | | wrapper.lambda().eq(Brand::getType,brand.getCompanyId()) |
| | | .or().eq(Brand::getType,Constants.ZERO); |
| | | } |
| | | List<Brand> list = brandMapper.selectList(wrapper); |
| | | String prefixUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode() |
| | | + systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.PROJECTS).getCode(); |
| | |
| | | |
| | | @Override |
| | | public PageData<Brand> findPage(PageWrap<Brand> pageWrap) { |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | IPage<Brand> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | | QueryWrapper<Brand> queryWrapper = new QueryWrapper<>(); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | |
| | | if (pageWrap.getModel().getStatus() != null) { |
| | | queryWrapper.lambda().eq(Brand::getStatus, pageWrap.getModel().getStatus()); |
| | | } |
| | | // 类型 0企业 1平台 |
| | | if (Objects.isNull(user.getCompanyId())) { |
| | | queryWrapper.lambda().eq(Brand::getType,Constants.ONE); |
| | | }else { |
| | | queryWrapper.lambda().eq(Brand::getType,pageWrap.getModel().getCompanyId()) |
| | | .or().eq(Brand::getType,Constants.ZERO); |
| | | } |
| | | queryWrapper.lambda().orderByAsc(Brand::getSortnum); |
| | | IPage<Brand> brandIPage = brandMapper.selectPage(page, queryWrapper); |
| | | String prefixUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode() |