package lingtao.net.service;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import lingtao.net.bean.Bug;
import lingtao.net.bean.Msg;
import lingtao.net.bean.SysUser;
import lingtao.net.dao.BugMapper;

@Service
public class BugService {

    @Autowired
    private BugMapper bugMapper;

    public List<Bug> getBugs(Bug bug) {
        return bugMapper.getBugs(bug);
    }

    public Msg addBug(Bug bug, HttpSession session) {
        SysUser user = (SysUser) session.getAttribute("USER_SESSION");
        bug.setCreateBy(user.getRealname());
        int i = bugMapper.addBug(bug);
        if (i < 0) {
            return Msg.fail();
        }
        return Msg.success();
    }

    public Msg updateBug(Bug bug) {
        int i = bugMapper.updateBug(bug);
        if (i < 0) {
            return Msg.fail();
        }
        return Msg.success();
    }

}
