package com.goafanti.common.dao;

import com.goafanti.admin.bo.*;
import com.goafanti.common.bo.AdminNoticeBo;
import com.goafanti.common.model.Admin;
import com.goafanti.common.model.AdminUserCount;
import com.goafanti.common.model.Department;
import com.goafanti.common.model.Role;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.domain.Pageable;

import java.math.BigDecimal;
import java.util.List;

/**
 * (Admin)表数据库访问层
 *
 * @author makejava
 * @since 2024-11-19 11:09:35
 */
public interface AdminMapper {

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    Admin selectById(String id);


    /**
     * 查询指定行数据
     *
     * @param admin    查询条件
     * @param pageable 分页对象
     * @return 对象列表
     */
    List<Admin> findAdminList(Admin admin, @Param("pageable") Pageable pageable);

    /**
     * 统计总行数
     *
     * @param admin 查询条件
     * @return 总行数
     */
    int findAdminCount(Admin admin);

    /**
     * 新增数据
     *
     * @param admin 实例对象
     * @return 影响行数
     */
    int insert(Admin admin);

    /**
     * 批量新增数据（MyBatis原生foreach方法）
     *
     * @param entities List<Admin> 实例对象列表
     * @return 影响行数
     */
    int insertBatch(@Param("entities") List<Admin> entities);

    /**
     * 批量新增或按主键更新数据（MyBatis原生foreach方法）
     *
     * @param entities List<Admin> 实例对象列表
     * @return 影响行数
     * @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常，请自行校验入参
     */
    int insertOrUpdateBatch(@Param("entities") List<Admin> entities);

    /**
     * 修改数据
     *
     * @param admin 实例对象
     * @return 影响行数
     */
    int update(Admin admin);

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 影响行数
     */
    int deleteById(String id);

    Admin selectByMobile(String mobile);

    List<Role> selectRolesByPrimaryKey(String uid);

    List<Admin> selectCognizanceConsultant();

    List<Admin> selectCognizancePrincipal();

    List<Admin> selectPatentAuthor();

    List<Admin> selectPatentPrincipal();

    List<Admin> selectCopyrightConsultant();

    List<Admin> selectCopyrightPrincipal();

    List<Admin> selectTechprojectConsultant();

    List<Admin> selectTechprojectPrincipal();

    List<String> selectRoleByPrimaryKey(String uid);

    List<Admin> selectAccoutManager();

    List<Admin> selectTechnician();

    List<Admin> selectSalesman();

    List<Admin> selectContractManager();

    List<Admin> selectTechBroder();

    List<Admin> listAdminSelectBySuperAdmin();

    List<Admin> listAdminSelectByAreaAdmin(@Param("provinceList")List<Integer> provinceList, @Param("cityList")List<Integer> cityList);

    List<Admin> listAdminByName(@Param("name")String name,@Param("status")Integer status);


    int insertn(Admin record);

    String selectUserNoBySuperiorId(String superiorId);

    int selectCountBySuperiorId(String superiorId);

    String selectIdByUserNo(String userNo);

    Admin selectAllByid(@Param("id") String id);

    String selectNameByid(String id);

    List<Role> selectRolesByUid(String id);



    String selectStatusByMobile(@Param("mobile")String mobile);


    List<Admin> selectIDNBySuperiorId(String superiorId);

    String selectUserNoById(String superiorId);

    int updateByUserNo(Admin record);

    List<String>selectIdBySuperiorId(String superiorId);

    /**
     * 查询下级人员
     * @param adminId
     * @return
     */
    List<AdminListBo> selectSubList(@Param("adminId")String adminId);

    /**
     * @return
     */
    Admin selectAdminByRoleId(@Param("roleId")String roleId);
    /**
     * 查询部门下的员工
     * @param departmentId
     * @param name
     * @return
     */
    List<AdminListBo> selectDepartmentStaff(String departmentId, String name);

    Admin selectAdminName(@Param("name")String name);

    List<Admin> selectAllAdmin(@Param("depId")String depId);

    int updateLockIds(@Param("lockIds")String lockIds);


    int getCountById(String id);
    AdminListBo getDeptNameByAid(String id);

    List<Admin> getAdminRoleNameList(String roleName);
    List<Admin> getAdminRoleNamesList(List<String> list);

    List<Admin> getAdminRoleTypesList(List<String> list);
    List<Admin> getAdminRoleTypeList(String roleType);

    int addAdminContacts(AdminContacts a);

    int deleteFrequentContacts(String id);

    List<String> getaidFrequentContacts(String id);

    /**
     * 获取属于某部门的角色
     * @param depId
     * @param roleType
     * @return
     */
    List<String> listNameByDepAndName(@Param("depId")String depId,@Param("roleType")String roleType);

    List<Admin> listAdminBydepIdAndRoleType(@Param("depId")String depId,@Param("roleType")String roleType);

    List<String> selectBySuperId(String aid);

    Admin selectFinanceAdminByOrderDep(String orderDep);

    Admin selectFinanceAdminByAid(String aid);
    Admin selectExpenseFinanceByAid(String aid);

    String getPermission(String transferId);

    List<String> selectDepIdWithSpuerId(String superId);


    List<String> getAdminRoleListByAid(String id);

    Admin selectByOpeid(String openid);

    AdminNoticeBo selectMyAndSuperBySuperId(String id);

    List<String> getFinanceDep(String aid);

    List<String> getLowerFinanceDep(String aid);


    int selectByAmbIdCount(String id);

    List<Admin> selectAdminByRoleType(@Param("roleType") String roleType);

    List<AdminCustomerBo > selectByDeps(@Param("depIds") List<Department> depIds,@Param("seniorStaff") Integer seniorStaff);



    List<Integer> selectRoleTypeByid(String aid);
    AdminStatisticsBo adminStatisticsInfo(@Param("aid") String aid);
    AdminStatisticsBo adminStatisticsInfoByTime(@Param("aid") String aid, @Param("startTime") String startTime, @Param("endTime") String endTime);

    List<AdminUserCount> thisMonthUser( @Param("firstDay")String firstDay, @Param("endDay")String endDay,
                                        @Param("aid")String aid);





    List<AdminUserCount> selectAdminPublicRelease(String aid);
    List<AdminUserCount> selectAdminUserFollow(String aid);
    List<AdminUserCount> selectAdminOrder(String aid);


    Integer adminStatisticsPublicReleaseByAidAndTime(@Param("aid") String aid, @Param("startTime") String startTime, @Param("endTime") String endTime);

    BigDecimal addAdminContactsRangeReceivables(@Param("aid") String aid, @Param("startTime") String startTime, @Param("endTime") String endTime);

    ConsultantStatisticsBo consultantStatisticsInfo(@Param("aid") String aid,@Param("type") Integer type);

    ConsultantStatisticsBo consultantStatisticsInfoByTime(@Param("aid") String aid, @Param("startTime") String startTime, @Param("endTime") String endTime);

    List<ConsultantUserCount> consultantthisMonthUser(@Param("firstDay")String firstDay, @Param("endDay")String endDay,
                                                      @Param("aid")String aid);

    Admin selectOrderByFinanace(String orderNo);

    List<Admin> selectAdminByRoleTypes(List<String> roles);

    OutFinanceCount financeInfo(@Param("aid") String aid, @Param("startTime") String startTime, @Param("endTime") String endTime);

    OutFinanceCount selectFinanceChangeCount(String aid);

    BigDecimal selectFinanceReceivablesCount(@Param("aid") String aid, @Param("startTime") String startTime, @Param("endTime") String endTime);


    void updateDepExpenseFinance(@Param("id") String id, @Param("expenseFinanceId") String expenseFinanceId);

    List<Admin> agentList();

    Admin selectByCallStaffNo(String staffNo);

    List<Admin> queryByTeamId(Integer id);

    AdminStatisticsBo selectUserCount(@Param("aid") String aid, @Param("startTime") String startTime, @Param("endTime") String endTime);

    void updateManagerId(Admin ad);

    List<selectAllUserDataBo> selectAllUserData(@Param("d1") String d1, @Param("d2") String d2, @Param("w1") String w1, @Param("w2") String w2, @Param("m1") String m1, @Param("m2") String m2, @Param("y1") String y1, @Param("y2") String y2);
}




