package com.xingxi.system.service.impl;

import com.xingxi.system.domain.SysUserPost;
import com.xingxi.system.mapper.SysUserPostMapper;
import com.xingxi.system.service.ISysUserPostService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 用户与岗位关联Service业务层处理
 *
 * @author xingxi
 * @date 2025-03-06
 */
@Service
public class SysUserPostServiceImpl implements ISysUserPostService {
    @Resource
    private SysUserPostMapper sysUserPostMapper;

    /**
     * 通过用户ID删除用户和岗位关联
     *
     * @param userId 用户ID
     * @return 结果
     */
    @Override
    public int deleteUserPostByUserId(Long userId) {
        return sysUserPostMapper.deleteUserPostByUserId(userId);
    }

    /**
     * 通过岗位ID查询岗位使用数量
     *
     * @param postId 岗位ID
     * @return 结果
     */
    @Override
    public int countUserPostById(Long postId) {
        return sysUserPostMapper.countUserPostById(postId);
    }

    /**
     * 批量删除用户和岗位关联
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteUserPost(Long[] ids) {
        return sysUserPostMapper.deleteUserPost(ids);
    }

    /**
     * 批量新增用户岗位信息
     *
     * @param userPostList 用户岗位列表
     */
    @Override
    public int batchUserPost(List<SysUserPost> userPostList) {
        return sysUserPostMapper.batchUserPost(userPostList);
    }
}
