package com.srs.comprehensive.service.impl;

import com.srs.common.utils.DateUtils;
import com.srs.comprehensive.domain.CphDormitoryGood;
import com.srs.comprehensive.mapper.CphDormitoryGoodMapper;
import com.srs.comprehensive.service.ICphDormitoryGoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 优秀宿舍Service业务层处理
 * 
 * @author srs
 * @date 2023-07-04
 */
@Service
public class CphDormitoryGoodServiceImpl implements ICphDormitoryGoodService 
{
    @Autowired
    private CphDormitoryGoodMapper cphDormitoryGoodMapper;

    /**
     * 查询优秀宿舍
     * 
     * @param id 优秀宿舍主键
     * @return 优秀宿舍
     */
    @Override
    public CphDormitoryGood selectCphDormitoryGoodById(Long id)
    {
        return cphDormitoryGoodMapper.selectCphDormitoryGoodById(id);
    }

    /**
     * 查询优秀宿舍列表
     * 
     * @param cphDormitoryGood 优秀宿舍
     * @return 优秀宿舍
     */
    @Override
    public List<CphDormitoryGood> selectCphDormitoryGoodList(CphDormitoryGood cphDormitoryGood)
    {
        return cphDormitoryGoodMapper.selectCphDormitoryGoodList(cphDormitoryGood);
    }

    /**
     * 新增优秀宿舍
     * 
     * @param cphDormitoryGood 优秀宿舍
     * @return 结果
     */
    @Override
    public int insertCphDormitoryGood(CphDormitoryGood cphDormitoryGood)
    {
        cphDormitoryGood.setCreateTime(DateUtils.getNowDate());
        String number = "bj" + System.currentTimeMillis(); // 生成编号为 "cj+时间戳"
        cphDormitoryGood.setNumber(number);
        return cphDormitoryGoodMapper.insertCphDormitoryGood(cphDormitoryGood);
    }

    /**
     * 修改优秀宿舍
     * 
     * @param cphDormitoryGood 优秀宿舍
     * @return 结果
     */
    @Override
    public int updateCphDormitoryGood(CphDormitoryGood cphDormitoryGood)
    {
        cphDormitoryGood.setUpdateTime(DateUtils.getNowDate());
        return cphDormitoryGoodMapper.updateCphDormitoryGood(cphDormitoryGood);
    }

    /**
     * 批量删除优秀宿舍
     * 
     * @param ids 需要删除的优秀宿舍主键
     * @return 结果
     */
    @Override
    public int deleteCphDormitoryGoodByIds(Long[] ids)
    {
        return cphDormitoryGoodMapper.deleteCphDormitoryGoodByIds(ids);
    }

    /**
     * 删除优秀宿舍信息
     * 
     * @param id 优秀宿舍主键
     * @return 结果
     */
    @Override
    public int deleteCphDormitoryGoodById(Long id)
    {
        return cphDormitoryGoodMapper.deleteCphDormitoryGoodById(id);
    }
}
