package cn.hmsoft.frame.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.data.dao.FrameModuleDao;
import cn.hmsoft.frame.data.model.FrameModule;
import cn.hmsoft.frame.service.FrameModuleService;

@RestController
public class FrameModuleControl extends FrameControl {

	@Autowired
	private FrameModuleService sModule;
	@Autowired
	private FrameModuleDao daoModule;

	@RequestMapping("frame/module/page")
	public Ajax page(String query, Integer limit, Integer start, String order, String type) {
		return new Ajax(this.daoModule.pageModule(start, limit, query, getQueryOrder(order, type)));
	}
	
	
	@RequestMapping("frame/module/add")
	public Ajax add(final FrameModule module) {
		this.authAdminRole();
		this.sModule.addModule(module);
		return new Ajax(module);
	}
	@RequestMapping("frame/module/edit")
	public Ajax edit(final FrameModule module) {
		this.authAdminRole();
		this.sModule.editModule(module);
		return new Ajax();
	}

	
	@RequestMapping("frame/module/delete")
	public Ajax delete(final int module_id) {
		this.authAdminRole();
		this.sModule.deleteModule(module_id);
		return new Ajax();
	}


}
