package com.xhkjedu.sapi.service.itemtool;

import com.xhkjedu.sapi.mapper.itemtool.TodoMapper;
import com.xhkjedu.sapi.model.itemtool.TTodo;
import com.xhkjedu.utils.N_Utils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ywx
 * @classname TodoService
 * @description 
 * @date 2020/6/12 16:05
 **/
@Service
public class TodoService {
    @Resource
    private TodoMapper todoMapper;

    //添加
    public Integer save(TTodo model) {
        model.setTodostate(0);
        model.setCreatetime(N_Utils.getSecondTimestamp());
        todoMapper.insertUseGeneratedKeys(model);
        return model.getId();
    }

    //删除
    public Integer deleteById(Integer id) {
        return todoMapper.deleteByPrimaryKey(id);
    }

    //修改
    public Integer update(TTodo model) {
        return todoMapper.updateByPrimaryKeySelective(model);
    }

    //获取列表
    public List <TTodo> listAll(TTodo todo) {
        return todoMapper.listAll(todo);
    }

    /**
     * 代办事项完成
     * @Param [todoid]
     * @Author ywx
     * @Date 2020/6/12 16:24
     * @return java.lang.Integer
     **/
    public Integer finished(Integer todoid,Integer todostate) {
        return todoMapper.finished(todoid,todostate);
    }
}
