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.PSchoolDao;
import cn.hmsoft.hmplatform.project.data.model.PSchool;
import cn.hmsoft.hmplatform.project.service.PSchoolService;

@RestController
public class SchoolControl extends FrameControl {

	@Autowired
	private PSchoolService serviceSchool;
	@Autowired
	private PSchoolDao daoSchool;
	
	@RequestMapping("platform/conf/school/page")
	public Ajax page(String query, Integer limit, Integer start, String order, String type) {
		return new Ajax(this.daoSchool.pageSchool(start, limit, query, getQueryOrder(order, type)));
	}

	@RequestMapping("platform/conf/school/find")
	public Ajax find(int daoSchool) {
		return new Ajax(this.daoSchool.find(daoSchool));
	}

	@RequestMapping("platform/conf/school/add")
	public Ajax add(PSchool school) {
		this.serviceSchool.addSchool(school, this.getFrameOptr());
		return new Ajax(school);
	}

	@RequestMapping("platform/conf/school/edit")
	public Ajax edit(PSchool school) {
		this.serviceSchool.editSchool(school, this.getFrameOptr());
		return new Ajax(school);
	}

	@RequestMapping("platform/conf/school/delete")
	public Ajax delete(Integer daoSchool) {
		this.serviceSchool.deleteSchool(daoSchool, this.getFrameOptr());
		return new Ajax();
	}
	
	@RequestMapping("platform/conf/school/list")
	public Ajax list(Integer daoSchool) {
		return new Ajax(this.daoSchool.all());
	}
}
