package com.dk.mdm.service.mst;

import com.dk.common.infrastructure.annotaiton.Pagination;
import com.dk.common.model.pojo.PageList;
import com.dk.common.response.ResponseResultUtil;
import com.dk.common.response.ResponseResultVO;
import com.dk.mdm.infrastructure.util.AuthUtils;
import com.dk.mdm.model.pojo.mst.TableSet;
import com.dk.mdm.mapper.mst.TableSetMapper;
import com.dk.common.service.BaseService;
import com.dk.common.mapper.BaseMapper;
import com.dk.mdm.model.query.mst.GoodsSkuQuery;
import com.dk.mdm.model.response.mst.GoodsSkuResponse;
import com.dk.mdm.service.common.CommonService;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class TableSetService extends BaseService<TableSet> {

	@Override
	public BaseMapper<TableSet> getRepository() {
		return tableSetMapper;
	}

	@Autowired
	private TableSetMapper tableSetMapper;

	/**
	 * @desc   : 重写主键
	 * @author : 周兴
	 * @date   : 2024/7/31 14:51
	 */
	@Override
	public String getPrimaryKey() {
		return "set_id";
	}

	/**
	 * @desc : 查询
	 * @author : 周兴
	 * @date : 2024/7/31 9:39
	 */
	@Pagination
	public ResponseResultVO<PageList<TableSet>> selectByCond(TableSet tableSet) {
		return super.mergeListWithCount(tableSet, tableSetMapper.selectByCond(tableSet),
				tableSetMapper.countByCond(tableSet));
	}

	/**
	 * @desc : 保存表格设置
	 * @author : 周兴
	 * @date : 2023/3/28 13:22
	 */
	@Transactional(
			rollbackFor = {Exception.class}
	)
	public ResponseResultVO<?> saveTableSet(TableSet tableSet) {
		tableSetMapper.saveTableSet(tableSet);
		return ResponseResultUtil.success(tableSet);
	}
}
