| | |
| | | cateBudgetMapper.insert(cateBudget); |
| | | } |
| | | } |
| | | |
| | | |
| | | return category.getId(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Integer companyCreate(Category category) { |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(categoryMapper.selectCount(new QueryWrapper<Category>().eq("ISDELETED",Constants.ZERO) |
| | | .eq("COMPANY_ID",user.getCompanyId()).eq("name",category.getName()))>0){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+category.getName()+"】已存在"); |
| | | }; |
| | | category.setStatus(Constants.ZERO); |
| | | category.setCreateDate(new Date()); |
| | | category.setCreator(user.getId()); |
| | | category.setIsdeleted(Constants.ZERO); |
| | | //处理拼音问题 |
| | | category.setPinyin(PinYinUtil.getFullSpell(category.getName())); |
| | | category.setShortPinyin(PinYinUtil.getFirstSpell(category.getName())); |
| | | categoryMapper.insert(category); |
| | | List<CateParam> paramList = category.getParamList(); |
| | | if(!Objects.isNull(paramList)&¶mList.size()> Constants.ZERO){ |
| | | for (int i = 0; i < paramList.size(); i++) { |
| | | CateParam cateParam = paramList.get(i); |
| | | cateParam.setCreator(user.getId()); |
| | | cateParam.setCreateDate(new Date()); |
| | | cateParam.setIsdeleted(Constants.ZERO); |
| | | cateParam.setSortnum(i+Constants.ONE); |
| | | cateParam.setStatus(Constants.ZERO); |
| | | cateParam.setCategoryId(category.getId()); |
| | | cateParamMapper.insert(cateParam); |
| | | } |
| | | } |
| | | List<CateBudget> budgetList = category.getBudgetList(); |
| | | if(!Objects.isNull(budgetList)&&budgetList.size()> Constants.ZERO){ |
| | | for (int i = 0; i < budgetList.size(); i++) { |
| | | CateBudget cateBudget = budgetList.get(i); |
| | | cateBudget.setCreator(user.getId()); |
| | | cateBudget.setCreateDate(new Date()); |
| | | cateBudget.setIsdeleted(Constants.ZERO); |
| | | cateBudget.setSortnum(i+Constants.ONE); |
| | | cateBudget.setStatus(Constants.ZERO); |
| | | cateBudget.setCategoryId(category.getId()); |
| | | cateBudgetMapper.insert(cateBudget); |
| | | } |
| | | } |
| | | return category.getId(); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void deleteById(Integer id) { |
| | |
| | | // } |
| | | // } |
| | | |
| | | cateBudgetMapper.delete(new QueryWrapper<CateBudget>().eq("CATEGORY_ID",category.getId())); |
| | | List<CateBudget> budgetList = category.getBudgetList(); |
| | | if(!Objects.isNull(budgetList)&&budgetList.size()> Constants.ZERO){ |
| | | for (int i = 0; i < budgetList.size(); i++) { |
| | | CateBudget cateBudget = budgetList.get(i); |
| | | cateBudget.setCreator(user.getId()); |
| | | cateBudget.setCreateDate(new Date()); |
| | | cateBudget.setIsdeleted(Constants.ZERO); |
| | | cateBudget.setSortnum(i+Constants.ONE); |
| | | cateBudget.setStatus(Constants.ZERO); |
| | | cateBudget.setCategoryId(category.getId()); |
| | | cateBudgetMapper.insert(cateBudget); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void companyUpdateById(Category category) { |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | if(categoryMapper.selectCount(new QueryWrapper<Category>().eq("ISDELETED",Constants.ZERO).ne("id",category.getId()).eq("name",category.getName()))>0){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+category.getName()+"】已存在"); |
| | | }; |
| | | category.setStatus(Constants.ZERO); |
| | | category.setEditDate(new Date()); |
| | | category.setEditor(user.getId()); |
| | | category.setIsdeleted(Constants.ZERO); |
| | | //处理拼音问题 |
| | | category.setPinyin(PinYinUtil.getFullSpell(category.getName())); |
| | | category.setShortPinyin(PinYinUtil.getFirstSpell(category.getName())); |
| | | categoryMapper.updateById(category); |
| | | //处理属性配置 |
| | | cateParamMapper.delete(new QueryWrapper<CateParam>().eq("CATEGORY_ID",category.getId())); |
| | | List<CateParam> paramList = category.getParamList(); |
| | | if(!Objects.isNull(paramList)&¶mList.size()> Constants.ZERO){ |
| | | for (int i = 0; i < paramList.size(); i++) { |
| | | CateParam cateParam = paramList.get(i); |
| | | cateParam.setCreator(user.getId()); |
| | | cateParam.setCreateDate(new Date()); |
| | | cateParam.setIsdeleted(Constants.ZERO); |
| | | cateParam.setSortnum(i+Constants.ONE); |
| | | cateParam.setStatus(Constants.ZERO); |
| | | cateParam.setCategoryId(category.getId()); |
| | | cateParamMapper.insert(cateParam); |
| | | } |
| | | } |
| | | cateBudgetMapper.delete(new QueryWrapper<CateBudget>().eq("CATEGORY_ID",category.getId())); |
| | | List<CateBudget> budgetList = category.getBudgetList(); |
| | | if(!Objects.isNull(budgetList)&&budgetList.size()> Constants.ZERO){ |
| | |
| | | QueryWrapper<Category> wrapper = new QueryWrapper<>(category); |
| | | return categoryMapper.selectCount(wrapper); |
| | | } |
| | | |
| | | |
| | | /**********************************************************************************/ |
| | | |
| | | @Override |
| | | public List<Category> companyFindList(Category category) { |
| | | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); |
| | | QueryWrapper<Category> wrapper = new QueryWrapper<>(category) |
| | | .eq("STATUS",Constants.ZERO) |
| | | .eq("COMPANY_ID",user.getCompanyId()) |
| | | .eq("ISDELETED",Constants.ZERO) |
| | | .orderByAsc(" SORTNUM "); |
| | | List<Category> list = categoryMapper.selectList(wrapper); |
| | | String prefixUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode() |
| | | + systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.PROJECTS).getCode(); |
| | | for (Category c:list) { |
| | | c.setPrefixUrl(prefixUrl); |
| | | c.setBudgetList(cateBudgetMapper.selectList(new QueryWrapper<CateBudget>().eq("STATUS",Constants.ZERO).eq("CATEGORY_ID",c.getId()).orderByAsc(" SORTNUM "))); |
| | | c.setParamList(cateParamMapper.selectList(new QueryWrapper<CateParam>().eq("STATUS",Constants.ZERO).eq("CATEGORY_ID",c.getId()).orderByAsc("SORTNUM"))); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | |
| | | |
| | | } |