package cn.hmsoft.skill.school.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.util.FrameAssertUtil;
import cn.hmsoft.skill.data.dao.school.SchoolAspectDao;
import cn.hmsoft.skill.data.dao.school.SchoolRegDao;
import cn.hmsoft.skill.data.model.school.SchoolAspect;
import cn.hmsoft.skill.data.model.school.SchoolReg;
import cn.hmsoft.skill.service.cf.SchoolAspectService;

@RestController
public class SchoolAspectControl extends SchoolAbstractControl {

	@Autowired
	private SchoolRegDao daoSchool;
	@Autowired
	private SchoolAspectDao daoAspect;
	@Autowired
	private SchoolAspectService sService;

	@RequestMapping("/school/school/aspect/list")
	public Ajax list() {
		SchoolReg school = this.daoSchool.find(this.getSchool().getSchool_id());
		return new Ajax(this.daoAspect.totalAspect(school.getSchool_id()));

	}

	@RequestMapping("/school/school/aspect/find")
	public Ajax find(int aspect_id) {
		SchoolReg school = this.getSchool();
		SchoolAspect aspect = this.daoAspect.find(aspect_id);
		FrameAssertUtil.isNotNull(aspect, "未找到指定的专业信息");
		FrameAssertUtil.isEqual(school.getSchool_id(), aspect.getSchool_id(), "越权查询，禁止操作！");
		return new Ajax(aspect);

	}

	@RequestMapping("/school/school/aspect/edit")
	public Ajax edit(SchoolAspect aspect) {
		SchoolReg school = this.getSchool();
		FrameAssertUtil.isEqual(school.getSchool_id(), aspect.getSchool_id(), "越权查询，禁止操作！");
		this.sService.save(aspect);
		return new Ajax();

	}
	
}
