package com.fzzy.igds.sys;
|
|
import com.fzzy.igds.dzhwk.domain.Company;
|
import com.fzzy.igds.sys.repository.CompanyRepository;
|
import com.fzzy.igds.util.ContextUtil;
|
import com.ruoyi.common.core.domain.entity.SysDept;
|
import com.ruoyi.common.utils.StringUtils;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* @Description service层
|
* @Author CZT
|
* @Date 2024/11/28 15:03
|
*/
|
@Slf4j
|
@Service("sys.coreCompanyService")
|
public class CoreCompanyService {
|
|
@Resource
|
private CompanyRepository companyRepository;
|
|
/**
|
* jpa查询公司信息
|
* @param id
|
* @return
|
*/
|
public Company getDataById(String id) {
|
|
if (StringUtils.isEmpty(id)) {
|
return null;
|
}
|
return companyRepository.getDataById(id);
|
}
|
|
/**
|
* jpa查询公司信息
|
* @param companyId
|
* @return
|
*/
|
public List<Company> getAllData(String companyId) {
|
|
if (StringUtils.isEmpty(companyId)) {
|
|
companyId = ContextUtil.getCompanyId();
|
}
|
return companyRepository.getAllData(companyId);
|
}
|
|
/**
|
* jpa查询公司信息
|
* @param sysDept
|
* @return
|
*/
|
public Company initCompanyData(SysDept sysDept) {
|
|
if (null == sysDept) {
|
return null;
|
}
|
Company company = new Company();
|
company.setId(sysDept.getDeptId() + "");
|
company.setDwmc(sysDept.getDeptName());
|
company.setCompanyId(sysDept.getCompanyId());
|
this.saveOrUpdate(company);
|
return company;
|
}
|
|
/**
|
* 保存仓房信息
|
* @param data
|
*/
|
public void saveOrUpdate(Company data) {
|
if (StringUtils.isEmpty(data.getCompanyId())) {
|
data.setCompanyId(ContextUtil.getCompanyId());
|
}
|
data.setZhgxsj(new Date());
|
companyRepository.save(data);
|
}
|
|
/**
|
* 删除仓房信息
|
* @param data
|
* @return
|
*/
|
public void delData(Company data) {
|
companyRepository.delete(data);
|
}
|
}
|