package org.springblade.modules.martial.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.modules.martial.pojo.entity.MartialDeductionItem;
import org.springblade.modules.martial.mapper.MartialDeductionItemMapper;
import org.springblade.modules.martial.service.IMartialDeductionItemService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * DeductionItem 服务实现类
 *
 * @author BladeX
 */
@Service
public class MartialDeductionItemServiceImpl extends ServiceImpl<MartialDeductionItemMapper, MartialDeductionItem> implements IMartialDeductionItemService {

	@Override
	public boolean updateOrder(List<MartialDeductionItem> sortData) {
		if (sortData == null || sortData.isEmpty()) {
			return false;
		}

		// 批量更新排序
		for (MartialDeductionItem item : sortData) {
			if (item.getId() != null && item.getSortOrder() != null) {
				MartialDeductionItem updateItem = new MartialDeductionItem();
				updateItem.setId(item.getId());
				updateItem.setSortOrder(item.getSortOrder());
				this.updateById(updateItem);
			}
		}

		return true;
	}

}
