package com.xunmei.system.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xunmei.system.service.ISysOrgService;
import java.util.Arrays;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xunmei.common.core.web.page.TableDataInfo;
import com.xunmei.system.mapper.SysWorkTimeSetDayofweekMapper;
import com.xunmei.system.domain.SysWorkTimeSetDayofweek;
import com.xunmei.system.service.ISysWorkTimeSetDayofweekService;

/**
 * 【请填写功能名称】Service业务层处理
 *
 * @author xunmei
 * @date 2023-08-15
 */
@Service
public class SysWorkTimeSetDayofweekServiceImpl extends ServiceImpl<SysWorkTimeSetDayofweekMapper, SysWorkTimeSetDayofweek> implements ISysWorkTimeSetDayofweekService {
    @Autowired
    private SysWorkTimeSetDayofweekMapper sysWorkTimeSetDayofweekMapper;
    @Autowired
    private ISysOrgService orgService;

    @Override
    public TableDataInfo<SysWorkTimeSetDayofweek> selectPage(SysWorkTimeSetDayofweek sysWorkTimeSetDayofweek) {

        Page<SysWorkTimeSetDayofweek> page;
        //分页
        if (sysWorkTimeSetDayofweek.getPageNum()!=null&&sysWorkTimeSetDayofweek.getPageSize()!=null)
        {
            page = new Page<>(sysWorkTimeSetDayofweek.getPageNum(), sysWorkTimeSetDayofweek.getPageSize());
        }else{
            page = new Page<>();
        }
        //查询条件
        QueryWrapper<SysWorkTimeSetDayofweek> query = new QueryWrapper<>(sysWorkTimeSetDayofweek);

        //时间范围查询
        if (sysWorkTimeSetDayofweek.getParams().get("beginTime")!=null&&sysWorkTimeSetDayofweek.getParams().get("endTime")!=null){
            query.between("create_time", sysWorkTimeSetDayofweek.getParams().get("beginTime"), sysWorkTimeSetDayofweek.getParams().get("endTime"));
        }
        //获取数据
        page = sysWorkTimeSetDayofweekMapper.selectPage(page, query);
        //抓换为TableDataInfo适配前端
        return TableDataInfo.build(page);

    }


    /**
     * 查询【请填写功能名称】
     *
     * @param id 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public SysWorkTimeSetDayofweek selectSysWorkTimeSetDayofweekById(Long id) {
        return sysWorkTimeSetDayofweekMapper.selectById(id);
    }

    /**
     * 查询【请填写功能名称】列表
     *
     * @param sysWorkTimeSetDayofweek 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<SysWorkTimeSetDayofweek> selectSysWorkTimeSetDayofweekList(SysWorkTimeSetDayofweek sysWorkTimeSetDayofweek) {
        return sysWorkTimeSetDayofweekMapper.selectList(new QueryWrapper<>(sysWorkTimeSetDayofweek));
    }

    /**
     * 新增【请填写功能名称】
     *
     * @param sysWorkTimeSetDayofweek 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertSysWorkTimeSetDayofweek(SysWorkTimeSetDayofweek sysWorkTimeSetDayofweek) {
            return sysWorkTimeSetDayofweekMapper.insert(sysWorkTimeSetDayofweek);
    }

    /**
     * 修改【请填写功能名称】
     *
     * @param sysWorkTimeSetDayofweek 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateSysWorkTimeSetDayofweek(SysWorkTimeSetDayofweek sysWorkTimeSetDayofweek) {
        return sysWorkTimeSetDayofweekMapper.updateById(sysWorkTimeSetDayofweek);
    }

    /**
     * 批量删除【请填写功能名称】
     *
     * @param ids 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteSysWorkTimeSetDayofweekByIds(Long[] ids) {
        return sysWorkTimeSetDayofweekMapper.deleteBatchIds(Arrays.asList((ids)));
    }

    /**
     * 删除【请填写功能名称】信息
     *
     * @param id 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteSysWorkTimeSetDayofweekById(Long id) {
        return sysWorkTimeSetDayofweekMapper.deleteById(id);
    }
}
