package com.jeeplus.test.jobPosion.service;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jeeplus.sys.utils.StringUtils;
import com.jeeplus.test.jobPosion.domain.PositionCategory;
import com.jeeplus.test.jobPosion.mapper.PositionCategoryMapper;
import com.jeeplus.test.jobPosion.service.dto.PositionCategoryDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service
@Transactional
public class PositionCategoryService extends ServiceImpl<PositionCategoryMapper, PositionCategory> {

    @Autowired
    private PositionCategoryMapper positionCategoryMapper;

    public void updateSortByIdList(List<PositionCategoryDTO> positionCategoryDTOList){
        List<PositionCategoryDTO> list = new ArrayList<>();
        positionCategoryDTOList.stream().forEach(item->{
            if(ObjectUtil.isNotEmpty(item)){
                if(StringUtils.isNotBlank(item.getId())&&ObjectUtil.isNotEmpty(item.getSort())){
                    list.add(item);
                }
            }
        });
        positionCategoryMapper.updateSortByIdList(list);
    }
}
