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.user.dao.BbFaceDao;
|
import com.cloud.user.model.BbFace;
|
import com.cloud.user.service.BbFaceService;
|
import com.cloud.user.service.TokenService;
|
import com.cloud.user.vo.BbFaceVO;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.util.Collections;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 人脸特征
|
* 业务层
|
*/
|
@Service
|
public class BbFaceServiceImpl implements BbFaceService {
|
|
@Autowired
|
private BbFaceDao dao;
|
|
@Autowired
|
private TokenService tokenService;
|
|
/**
|
* 根据主键查询
|
* @param orgId
|
*/
|
public BbFace findById(Long id, Long orgId) {
|
Map<String, Object> params = new HashMap<String, Object>();
|
params.put("id", id);
|
if (orgId != null && !"".equals(orgId)) {
|
params.put("orgId", orgId);
|
}
|
return dao.findById(params);
|
}
|
|
/**
|
* 根据主键删除
|
* @param orgId
|
*/
|
public Integer deleteById(Long id, Long orgId) {
|
Map<String, Object> params = new HashMap<String, Object>();
|
params.put("id", id);
|
if (orgId != null && !"".equals(orgId)) {
|
params.put("orgId", orgId);
|
}
|
return dao.deleteById(params);
|
}
|
|
/**
|
* 添加, 没有业务
|
*/
|
public BbFace add(BbFace bean) {
|
bean.preInsert(tokenService.currentUser());
|
// 设置创建属性
|
|
dao.save(bean);
|
return bean;
|
}
|
|
/**
|
* 编辑, 没有业务
|
*/
|
public BbFace update(BbFace bean) {
|
bean.preUpdate(tokenService.currentUser());
|
// 查找要编辑的数据库实体
|
BbFace dbBean = findById(bean.getId(), bean.getOrgId());
|
if (dbBean != null) {
|
|
// 设置要修改的属性
|
dbBean.setResourceId(bean.getResourceId()); //关联人Id(eployeeid
|
dbBean.setFeature(bean.getFeature()); //人脸特征
|
|
dao.update(dbBean);
|
return dbBean;
|
} else {
|
return null;
|
}
|
}
|
|
|
/**
|
* 添加,包含业务
|
*/
|
public BbFace addBbFace(BbFaceVO beanVO) {
|
add(beanVO);
|
return beanVO;
|
}
|
|
/**
|
* 编辑,包含业务
|
*/
|
public BbFace updateBbFace(BbFaceVO beanVO) {
|
// 查找要编辑的数据库实体
|
BbFace dbBean = findById(beanVO.getId(), beanVO.getOrgId());
|
if (dbBean != null) {
|
// 设置要修改的属性
|
dbBean.setResourceId(beanVO.getResourceId()); //关联人Id(eployeeid
|
dbBean.setFeature(beanVO.getFeature()); //人脸特征
|
update(dbBean);
|
return dbBean;
|
} else {
|
return null;
|
}
|
}
|
|
/**
|
* 去编辑,包含业务
|
*/
|
public BbFace toUpdateBbFace(Long id, Long orgId) {
|
// 查找要编辑的数据库实体
|
BbFace dbBean = findById(id, orgId);
|
return dbBean;
|
}
|
|
/**
|
* 分页查询
|
*/
|
public Page<BbFace> findBbFaces(Map<String, Object> params) {
|
params.put("orgId", tokenService.currentUser().getOrgId()+"");
|
int total = dao.count(params);
|
List<BbFace> list = Collections.emptyList();
|
if (total > 0) {
|
PageUtil.pageParamConver(params, true);
|
|
list = dao.findData(params);
|
}
|
return new Page<>(total, list);
|
}
|
|
/**
|
* 根据人脸ID获取人员Id
|
* @param params
|
* @return
|
*/
|
public Map<String, Object> findEmpIdByFaceId(Map<String, Object> params) {
|
Map<String, Object> map = new HashMap<>();
|
List<Integer> empIds = dao.findEmpIdByFaceId(params);
|
if(empIds.size() > 0){
|
map.put("total",empIds.size());
|
map.put("data",empIds);
|
return map;
|
}
|
map.put("提示","暂无数据!");
|
return map;
|
}
|
}
|