package com.cloud.user.service.impl;
|
|
//import com.cloud.common.utils.AppUserUtil;
|
import com.cloud.common.utils.PageUtil;
|
import com.cloud.model.common.Page;
|
import com.cloud.model.sys.BbEmployeeRelation;
|
import com.cloud.user.dao.BbEmployeeRelationDao;
|
import com.cloud.user.service.BbEmployeeRelationService;
|
import com.cloud.user.service.TokenService;
|
import com.cloud.user.vo.BbEmployeeRelationVO;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.Collections;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 人员关系表
|
* 业务层
|
*/
|
@Service
|
public class BbEmployeeRelationServiceImpl implements BbEmployeeRelationService {
|
|
@Autowired
|
private BbEmployeeRelationDao dao;
|
|
@Autowired
|
private TokenService tokenService;
|
/**
|
* 根据主键查询
|
* @param id
|
* @param orgId
|
*/
|
public BbEmployeeRelation findById(Long id, Long orgId) {
|
Map<String, Object> params = new HashMap<>();
|
params.put("id", id);
|
if (orgId != null && !"".equals(orgId.toString())) {
|
params.put("orgId", orgId);
|
}
|
return dao.findById(params);
|
}
|
|
/**
|
* 根据主键删除
|
* @param params
|
* @param orgId
|
*/
|
public Integer deleteById(Map<String, Object> params, String orgId) {
|
if (orgId != null && !"".equals(orgId)) {
|
params.put("orgId", orgId);
|
}
|
return dao.deleteById(params);
|
}
|
|
/**
|
* 添加, 没有业务
|
*/
|
public Integer add(BbEmployeeRelation bean) {
|
|
// 设置创建属性
|
bean.preInsert(tokenService.currentUser()); //逻辑删除标记(0
|
bean.setDelFlag("0");
|
return dao.add(bean);
|
}
|
|
/**
|
* 编辑, 没有业务
|
*/
|
public BbEmployeeRelation update(BbEmployeeRelation bean) {
|
// 查找要编辑的数据库实体
|
BbEmployeeRelation dbBean = null;// findById(bean.getId(), bean.getOrgId());
|
|
// 设置要修改的属性
|
dbBean.setEmployeeId(bean.getEmployeeId()); //被关联人Id
|
dbBean.setRelationoId(bean.getRelationoId()); //关联人Id
|
dbBean.setRelation(bean.getRelation()); //家属关系
|
dbBean.setRemarks(bean.getRemarks()); //备注信息
|
dbBean.setRevJson1(bean.getRevJson1()); //预留json格式字段1
|
|
dao.update(dbBean);
|
return dbBean;
|
}
|
|
|
/**
|
* 添加,包含业务
|
*/
|
@Transactional
|
public Map<String,Object> addBbEmployeeRelation(List<BbEmployeeRelationVO> beanVOs) {
|
Map<String,Object> map = new HashMap<>();
|
for(BbEmployeeRelation bbEmployeeRelation:beanVOs){
|
Integer status = add(bbEmployeeRelation);
|
if(status == 0){
|
map.put("code","1");
|
map.put("message","保存失败!");
|
return map;
|
}
|
}
|
map.put("code","0");
|
map.put("message","保存成功!");
|
return map;
|
}
|
|
/**
|
* 编辑,包含业务
|
*/
|
public Map<String,Object> updateBbEmployeeRelation(BbEmployeeRelationVO beanVO) {
|
// 查找要编辑的数据库实体
|
BbEmployeeRelation dbBean = null;//findById(beanVO.getId(), beanVO.getOrgId());
|
|
// 设置要修改的属性
|
dbBean.setEmployeeId(beanVO.getEmployeeId()); //被关联人Id
|
dbBean.setRelationoId(beanVO.getRelationoId()); //关联人Id
|
dbBean.setRelation(beanVO.getRelation()); //家属关系
|
dbBean.setRemarks(beanVO.getRemarks()); //备注信息
|
dbBean.setRevJson1(beanVO.getRevJson1()); //预留json格式字段1
|
|
dao.update(dbBean);
|
return null;
|
}
|
|
/**
|
* 去编辑,包含业务
|
*/
|
public BbEmployeeRelation toUpdateBbEmployeeRelation(BbEmployeeRelationVO beanVO) {
|
// 查找要编辑的数据库实体
|
BbEmployeeRelation dbBean = null;// findById(beanVO.getId(), beanVO.getOrgId());
|
return dbBean;
|
}
|
|
/**
|
* 分页查询
|
*/
|
public Page<BbEmployeeRelation> findBbEmployeeRelations(Map<String, Object> params) {
|
params.put("orgId", tokenService.currentUser().getOrgId()+"");
|
int total = dao.count(params);
|
List<BbEmployeeRelation> list = Collections.emptyList();
|
if (total > 0) {
|
PageUtil.pageParamConver(params, true);
|
|
list = dao.findData(params);
|
}
|
return new Page<>(total, list);
|
}
|
|
@Override
|
public Map<String, Object> findRelationById(Map<String, Object> params) {
|
Map<String,Object> map = new HashMap<>();
|
List<Map<String,Object>> data = dao.findRelationById(params);
|
if(data.size()>0){
|
map.put("code","0");
|
map.put("data",data);
|
map.put("message","查询成功!");
|
}else {
|
map.put("code","1");
|
map.put("data","");
|
map.put("message","查询失败!");
|
}
|
return map;
|
}
|
|
}
|