@Override public int delete(Long id) { return productAttributeCategoryMapper.deleteByPrimaryKey(id); }
@Override public PmsProductAttributeCategory getItem(Long id) { return productAttributeCategoryMapper.selectByPrimaryKey(id); }
@Override public int create(PmsProductAttributeParam pmsProductAttributeParam) { PmsProductAttribute pmsProductAttribute = new PmsProductAttribute(); BeanUtils.copyProperties(pmsProductAttributeParam, pmsProductAttribute); int count = productAttributeMapper.insertSelective(pmsProductAttribute); //新增商品属性以后需要更新商品属性分类数量 PmsProductAttributeCategory pmsProductAttributeCategory = productAttributeCategoryMapper.selectByPrimaryKey(pmsProductAttribute.getProductAttributeCategoryId()); if(pmsProductAttribute.getType()==0){ pmsProductAttributeCategory.setAttributeCount(pmsProductAttributeCategory.getAttributeCount()+1); }else if(pmsProductAttribute.getType()==1){ pmsProductAttributeCategory.setParamCount(pmsProductAttributeCategory.getParamCount()+1); } productAttributeCategoryMapper.updateByPrimaryKey(pmsProductAttributeCategory); return count; }
@Override public int create(String name) { PmsProductAttributeCategory productAttributeCategory = new PmsProductAttributeCategory(); productAttributeCategory.setName(name); return productAttributeCategoryMapper.insertSelective(productAttributeCategory); }
@Override public List<PmsProductAttributeCategory> getList(Integer pageSize, Integer pageNum) { PageHelper.startPage(pageNum,pageSize); return productAttributeCategoryMapper.selectByExample(new PmsProductAttributeCategoryExample()); }
@Override public int update(Long id, String name) { PmsProductAttributeCategory productAttributeCategory = new PmsProductAttributeCategory(); productAttributeCategory.setName(name); productAttributeCategory.setId(id); return productAttributeCategoryMapper.updateByPrimaryKeySelective(productAttributeCategory); }
@Override public int delete(List<Long> ids) { //获取分类 PmsProductAttribute pmsProductAttribute = productAttributeMapper.selectByPrimaryKey(ids.get(0)); Integer type = pmsProductAttribute.getType(); PmsProductAttributeCategory pmsProductAttributeCategory = productAttributeCategoryMapper.selectByPrimaryKey(pmsProductAttribute.getProductAttributeCategoryId()); PmsProductAttributeExample example = new PmsProductAttributeExample(); example.createCriteria().andIdIn(ids); int count = productAttributeMapper.deleteByExample(example); //删除完成后修改数量 if(type==0){ if(pmsProductAttributeCategory.getAttributeCount()>=count){ pmsProductAttributeCategory.setAttributeCount(pmsProductAttributeCategory.getAttributeCount()-count); }else{ pmsProductAttributeCategory.setAttributeCount(0); } }else if(type==1){ if(pmsProductAttributeCategory.getParamCount()>=count){ pmsProductAttributeCategory.setParamCount(pmsProductAttributeCategory.getParamCount()-count); }else{ pmsProductAttributeCategory.setParamCount(0); } } productAttributeCategoryMapper.updateByPrimaryKey(pmsProductAttributeCategory); return count; }