package com.jwipc.sys.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jwipc.sys.entity.PurchaseGroup;
import com.jwipc.sys.entity.UserPurchaseGroup;
import com.jwipc.sys.mapper.UserPurchaseGroupMapper;
import com.jwipc.sys.model.po.UserPurchaseGroupPO;
import com.jwipc.sys.model.query.UserPurchaseGroupUpdateQuery;
import com.jwipc.sys.service.IUserPurchaseGroupService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

/**
 * <p>
 * 采购组分配人员关联表 服务实现类
 * </p>
 *
 * @author zhangjie
 * @since 2024-01-29
 */
@Service
public class UserPurchaseGroupServiceImpl extends ServiceImpl<UserPurchaseGroupMapper, UserPurchaseGroup> implements IUserPurchaseGroupService {

    /**
     * 根据用户id获取优先展示的采购组编码
     *
     * @param userId 用户id
     * @return 采购组编码
     */
    @Override
    public String getMarkPurchaseGroupCodeByUserId(Long userId) {
        return baseMapper.getMarkPurchaseGroupCodeByUserId(userId);
    }

    @Override
    public Set<String> getUserPurchaseGroupCode(Long userId) {
        return baseMapper.getUserPurchaseGroupCode(userId);
    }

    @Override
    public List<UserPurchaseGroupPO> findPageByQueryC(Page<PurchaseGroup> dbPage, UserPurchaseGroupUpdateQuery query) {
        if (dbPage==null){
            return baseMapper.findPageByQuery(query);
        }
        return baseMapper.findPageByQuery(dbPage,query);
    }
}
