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


import com.djhk.common.api.domain.PoliceInfo;
import com.djhk.common.core.domain.entity.SysDept;
import com.djhk.common.core.domain.entity.SysUser;
import com.djhk.common.core.domain.model.LoginUser;
import com.djhk.common.exception.ServiceException;
import com.djhk.common.utils.SecurityUtils;
import com.djhk.system.service.ISysDeptService;
import com.djhk.system.service.ISysUserService;
import com.djhk.system.service.impl.SysDeptServiceImpl;
import com.djhk.uav.policeInfo.mapper.PoliceInfoMapper;
import com.djhk.uav.policeInfo.service.IPoliceInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 【请填写功能名称】Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-07-08
 */
@Service
public class PoliceInfoServiceImpl implements IPoliceInfoService
{
    @Autowired
    private PoliceInfoMapper policeInfoMapper;


    @Autowired
    private ISysUserService userService;

    @Autowired
    private ISysDeptService deptService;



    /**
     * 查询【请填写功能名称】
     * 
     * @param BGDH 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public PoliceInfo selectPoliceInfoByBGDH(String BGDH)
    {
        return policeInfoMapper.selectPoliceInfoByBGDH(BGDH);
    }

    /**
     * 查询【请填写功能名称】列表
     * 
     * @param policeInfo 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<PoliceInfo> selectPoliceInfoList(PoliceInfo policeInfo)
    {
        SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
        if (null == sysUser) {
            throw new ServiceException("登录失效，请重新登录！", 500);
        }
        Long deptId = sysUser.getDeptId();
//        SysDept dept = remoteDeptService.getDeptInfo(deptId, "inner").getData();
        SysDept dept = deptService.selectDeptById(deptId);
        if (!dept.getAdminCode().equals("500000000000"))
            policeInfo.setNbBh(dept.getAdminCode().substring(0, 6));
//        SysDept sysDept = new SysDept();
//        sysDept.setDeptId(deptId);
//        List<Object> inner = remoteDeptService.selectDeptTreeList(sysDept, "inner").getData();

        //NB_BH
        return policeInfoMapper.selectPoliceInfoList(policeInfo);
    }

    /**
     * 新增【请填写功能名称】
     * 
     * @param policeInfo 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertPoliceInfo(PoliceInfo policeInfo)
    {
        return policeInfoMapper.insertPoliceInfo(policeInfo);
    }

    /**
     * 修改【请填写功能名称】
     * 
     * @param policeInfo 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updatePoliceInfo(PoliceInfo policeInfo)
    {
        return policeInfoMapper.updatePoliceInfo(policeInfo);
    }

    /**
     * 批量删除【请填写功能名称】
     * 
     * @param BGDHs 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deletePoliceInfoByBGDHs(String[] BGDHs)
    {
        return policeInfoMapper.deletePoliceInfoByBGDHs(BGDHs);
    }

    /**
     * 删除【请填写功能名称】信息
     * 
     * @param BGDH 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deletePoliceInfoByBGDH(String BGDH)
    {
        return policeInfoMapper.deletePoliceInfoByBGDH(BGDH);
    }
}
