package com.cool.store.dao;

import cn.hutool.core.bean.BeanUtil;
import com.cool.store.dto.content.ContentAddDto;
import com.cool.store.dto.content.ContentQueryListDto;
import com.cool.store.dto.content.ContentUpdateDto;
import com.cool.store.entity.HyContentInfoDO;
import com.cool.store.mapper.HyContentInfoMapper;
import com.cool.store.vo.HyContentInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Deprecated
public class ContentDAO {

    @Autowired
    private HyContentInfoMapper contentInfoMapper;

    public String addContentInfo(ContentAddDto dto) {
        HyContentInfoDO hyContentInfoDO = new HyContentInfoDO();
        BeanUtil.copyProperties(dto, hyContentInfoDO);
        hyContentInfoDO.setUpdateUserId(dto.getCreateUserId());
        return Integer.toString(contentInfoMapper.insertSelective(hyContentInfoDO));
    }

    public void deleteContent(String contentId) {
        contentInfoMapper.deleteSelective(contentId);
    }

    public void updateContent(ContentUpdateDto dto) {
        HyContentInfoDO hyContentInfoDO = new HyContentInfoDO();
        BeanUtil.copyProperties(dto, hyContentInfoDO);
        hyContentInfoDO.setId(Long.parseLong(dto.getContentId()));
        contentInfoMapper.updateByPrimaryKeySelective(hyContentInfoDO);
    }

    public List<HyContentInfoVO> queryContentList(ContentQueryListDto dto) {
        return contentInfoMapper.queryContentList(dto);
    }

    public HyContentInfoDO queryContentInfo(String contentId) {
        return contentInfoMapper.queryContentInfo(contentId);
    }
}
