package com.djhk.uav.sysPolice.service.impl;


import com.djhk.common.core.domain.entity.SysDept;
import com.djhk.common.core.domain.model.LoginUser;
import com.djhk.common.exception.ServiceException;
import com.djhk.common.utils.SecurityUtils;
import com.djhk.system.mapper.SysDeptMapper;
import com.djhk.uav.sysPolice.domain.PoliceInfoEs;
import com.djhk.uav.sysPolice.mapper.PoliceInfoEsMapper;
import com.djhk.uav.sysPolice.service.IPoliceInfoEsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 警员信息ES
Service业务层处理
 * 
 * @author qpc
 * @date 2025-04-14
 */
@Service
public class PoliceInfoEsServiceImpl implements IPoliceInfoEsService
{
    @Autowired
    private PoliceInfoEsMapper policeInfoEsMapper;

    @Autowired
    private SysDeptMapper sysDeptMapper;

    /**
     * 查询警员信息ES

     * 
     * @param fhRksj 警员信息ES
主键
     * @return 警员信息ES

     */
    @Override
    public PoliceInfoEs selectPoliceInfoEsByFhRksj(String fhRksj)
    {
        return policeInfoEsMapper.selectPoliceInfoEsByFhRksj(fhRksj);
    }

    /**
     * 查询警员信息ES列表
     * 
     * @param policeInfoEs 警员信息ES

     * @return 警员信息ES

     */
    @Override
    public List<PoliceInfoEs> selectPoliceInfoEsList(PoliceInfoEs policeInfoEs)
    {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        if (null == loginUser) {
            throw new ServiceException("登录失效，请重新登录！", 500);
        }
        Long deptId = SecurityUtils.getDeptId();
        if (deptId != 1){
            SysDept sysDept = sysDeptMapper.selectDeptById(deptId);
//            if (StringUtils.equals( sysDept.getDeptName(),))
            policeInfoEs.setMC(sysDept.getDeptName());

        }
        return policeInfoEsMapper.selectPoliceInfoEsList(policeInfoEs);
    }

    /**
     * 新增警员信息ES

     * 
     * @param policeInfoEs 警员信息ES

     * @return 结果
     */
    @Override
    public int insertPoliceInfoEs(PoliceInfoEs policeInfoEs)
    {
        return policeInfoEsMapper.insertPoliceInfoEs(policeInfoEs);
    }

    /**
     * 修改警员信息ES

     * 
     * @param policeInfoEs 警员信息ES

     * @return 结果
     */
    @Override
    public int updatePoliceInfoEs(PoliceInfoEs policeInfoEs)
    {
        return policeInfoEsMapper.updatePoliceInfoEs(policeInfoEs);
    }

    /**
     * 批量删除警员信息ES

     * 
     * @param fhRksjs 需要删除的警员信息ES
主键
     * @return 结果
     */
    @Override
    public int deletePoliceInfoEsByFhRksjs(String[] fhRksjs)
    {
        return policeInfoEsMapper.deletePoliceInfoEsByFhRksjs(fhRksjs);
    }

    /**
     * 删除警员信息ES
信息
     * 
     * @param fhRksj 警员信息ES
主键
     * @return 结果
     */
    @Override
    public int deletePoliceInfoEsByFhRksj(String fhRksj)
    {
        return policeInfoEsMapper.deletePoliceInfoEsByFhRksj(fhRksj);
    }
}
