package cn.hmsoft.hmplatform.project.control;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.hmsoft.application.web.Ajax;
import cn.hmsoft.frame.control.FrameControl;
import cn.hmsoft.hmplatform.project.data.dao.PProjectDao;
import cn.hmsoft.hmplatform.project.data.model.PProject;
import cn.hmsoft.hmplatform.project.service.PProjectService;

@RestController
public class ProjectControl extends FrameControl {

	@Autowired
	private PProjectService serviceProject;
	@Autowired
	private PProjectDao daoProject;
	
	@RequestMapping("platform/conf/project/page")
	public Ajax page(Integer school_id, String query, Integer limit, Integer start, String order, String type) {
		return new Ajax(this.daoProject.pageProject(school_id, start, limit, query, getQueryOrder(order, type)));
	}

	@RequestMapping("platform/conf/project/find")
	public Ajax find(int project_id) {
		return new Ajax(this.daoProject.find(project_id));
	}

	@RequestMapping("platform/conf/project/add")
	public Ajax add(PProject project) {
		this.serviceProject.addProject(project, this.getFrameOptr());
		return new Ajax(project);
	}

	@RequestMapping("platform/conf/project/edit")
	public Ajax edit(PProject project) {
		this.serviceProject.editProject(project, this.getFrameOptr());
		return new Ajax(project);
	}

	@RequestMapping("platform/conf/project/delete")
	public Ajax delete(Integer subject_id) {
		this.serviceProject.deleteProject(subject_id, this.getFrameOptr());
		return new Ajax();
	}
}
