package com.ekexiu.portal.service;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

import org.jfw.apt.annotation.Autowrie;
import org.jfw.apt.web.annotation.Path;
import org.jfw.apt.web.annotation.operate.Delete;
import org.jfw.apt.web.annotation.operate.Get;
import org.jfw.apt.web.annotation.operate.Post;
import org.jfw.apt.web.annotation.operate.Put;
import org.jfw.apt.web.annotation.param.JdbcConn;
import org.jfw.apt.web.annotation.param.PathVar;
import org.jfw.apt.web.annotation.param.RequestBody;
import org.jfw.util.StringUtil;

import com.ekexiu.portal.dao.PartTimeJobDao;
import com.ekexiu.portal.po.PartTimeJob;
@Path("/job")
public class PartTimeJobService {
	@Autowrie
	private PartTimeJobDao partTimeJobDao;
	
	public PartTimeJobDao getPartTimeJobDao() {
		return partTimeJobDao;
	}

	public void setPartTimeJobDao(PartTimeJobDao jobDao) {
		this.partTimeJobDao = jobDao;
	}

	@Get
	@Path("/{id}")
	public PartTimeJob query(@JdbcConn Connection con,@PathVar String id) throws SQLException
	{
		return this.partTimeJobDao.queryOne(con, id);
	}
	@Post
	@Path
	public void insert(@JdbcConn(true) Connection con, PartTimeJob honor) throws SQLException {
		String id = StringUtil.buildUUID();
		honor.setId(id);
		this.partTimeJobDao.insert(con, honor);
	}

	@Put
	@Path
	public void update(@JdbcConn(true) Connection con, @RequestBody PartTimeJob honor) throws SQLException {
		this.partTimeJobDao.update(con, honor);
	}

	@Get
	@Path("/professor")
	public List<PartTimeJob> queryByProfessor(@JdbcConn(false) Connection con, String professorId) throws SQLException {
		return this.partTimeJobDao.query(con, professorId);
	}

	@Delete
	@Path("/{id}")
	public void delete(@JdbcConn(true) Connection con, @PathVar String id) throws SQLException {
		this.partTimeJobDao.delete(con, id);
	}
}
