package cn.autoform.web.service.businesscategoryedit; import java.util.List; import java.util.UUID; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import cn.autoform.bean.BusinessCategoryCusEntity; import cn.autoform.db.entity.TemplateCategoryEntity; import cn.autoform.web.mapper.businesscategoryedit.BusinessCategoryEditMapper; /** * @author lt-wx * 业务功能分类编辑Service */ @Service public class BusinessCategoryEditService { @Autowired private BusinessCategoryEditMapper businessCategoryEditMapper = null; /** * 从业务分类管理表中取出数据 * @param businessCategoryID * @return */ public BusinessCategoryCusEntity getBusinessCategoryInfo(String businessCategoryID,String tenantID){ BusinessCategoryCusEntity businessCategoryCus = businessCategoryEditMapper.getBusinessCategoryInfo(businessCategoryID,tenantID); //判断是否设为精品和是否可见,供页面显示 if("1".equals(businessCategoryCus.getEssence())){ businessCategoryCus.setIsEssence(true); }else{ businessCategoryCus.setIsEssence(false); } if("1".equals(businessCategoryCus.getVisiblepermission())){ businessCategoryCus.setIsVisible(true); }else{ businessCategoryCus.setIsVisible(false); } return businessCategoryCus; } /** * 新增一条业务分类 * @param businessCategory * @return */ @Transactional public int createBusinessCategory(BusinessCategoryCusEntity businessCategory){ TemplateCategoryEntity templateCategoryEntity = new TemplateCategoryEntity(); String uuid = UUID.randomUUID().toString().replace("-", ""); templateCategoryEntity.setTenantID(businessCategory.getTenantID()); templateCategoryEntity.setBusinessCategoryID(businessCategory.getBusinessCategoryID()); templateCategoryEntity.setTemplateCategoryID(uuid); templateCategoryEntity.setTemplateCategoryName("未命名分类"); templateCategoryEntity.setCreateUser(businessCategory.getCreateUser()); templateCategoryEntity.setUpdateUser(businessCategory.getUpdateUser()); int businessCount = businessCategoryEditMapper.createBusinessCategory(businessCategory); int templateCount = businessCategoryEditMapper.createDefaultTemplateCategory(templateCategoryEntity); if(businessCount == 1 && templateCount == 1){ return 1; }else{ return 0; } } /** * 编辑一条业务分类 * @param businessCategory * @return */ public int saveBusinessCategory(BusinessCategoryCusEntity businessCategory){ return businessCategoryEditMapper.saveBusinessCategory(businessCategory); } /** * check业务分类名称唯一 * @param businessCategory * @return */ public int checkBusinessCategoryName(BusinessCategoryCusEntity businessCategory){ List list = businessCategoryEditMapper.checkBusinessCategoryName(businessCategory); if(list.isEmpty()){ return 1; }else{ return 0; } } }