| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.model.LoginUserInfo; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.dao.business.YwContractMapper; |
| | | import com.doumee.dao.business.YwCustomerMapper; |
| | | import com.doumee.dao.business.YwProjectMapper; |
| | | import com.doumee.dao.business.YwRoomMapper; |
| | | import com.doumee.dao.business.dao.CompanyMapper; |
| | | import com.doumee.dao.business.model.Company; |
| | | import com.doumee.dao.business.model.YwContract; |
| | | import com.doumee.dao.system.SystemUserMapper; |
| | | import com.doumee.service.business.YwContractService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private YwContractMapper ywContractMapper; |
| | | @Autowired |
| | | private CompanyMapper companyMapper; |
| | | @Autowired |
| | | private YwProjectMapper projectMapper; |
| | | @Autowired |
| | | private YwRoomMapper roomMapper; |
| | | @Autowired |
| | | private SystemUserMapper systemUserMapper; |
| | | @Autowired |
| | | private YwCustomerMapper customerMapper; |
| | | |
| | | @Override |
| | | public Integer create(YwContract ywContract) { |
| | | ywContractMapper.insert(ywContract); |
| | | return ywContract.getId(); |
| | | @Transactional(rollbackFor = {BusinessException.class,Exception.class}) |
| | | public Integer create(YwContract model) { |
| | | isParamValidCreated(model); |
| | | |
| | | model.setCreator(model.getLoginUserInfo().getId()); |
| | | model.setIsdeleted(Constants.ZERO); |
| | | model.setCreateDate(new Date()); |
| | | model.setStatus(Constants.ZERO); |
| | | model.setEditDate(model.getCreateDate()); |
| | | model.setEditor(model.getCreator()); |
| | | |
| | | ywContractMapper.insert(model); |
| | | |
| | | return model.getId(); |
| | | } |
| | | |
| | | private void isParamValidCreated(YwContract model) { |
| | | if(model.getCompanyId()==null){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,请选择正确的公司信息"); |
| | | } |
| | | Company ywProject = companyMapper.selectById(model.getCompanyId()); |
| | | if(ywProject ==null || Constants.equalsInteger(ywProject.getIsdeleted(),Constants.ONE) |
| | | || !Constants.equalsInteger(ywProject.getType(),Constants.TWO)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"对不起,请选择正确的公司信息!"); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |