package cn.hmsoft.hmplatform.wxtoken.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.wxtoken.data.dao.PWxDefineDao;
import cn.hmsoft.hmplatform.wxtoken.data.model.PWxDefine;
import cn.hmsoft.hmplatform.wxtoken.service.PlatformTokenDefineService;

@RestController
public class WeixinTokenDefineControl extends FrameControl {

	@Autowired
	private PWxDefineDao daoDefine;
	@Autowired
	private PlatformTokenDefineService sToken;

	@RequestMapping("platform/wxtoken/page")
	public Ajax page(String query, Integer limit, Integer start, String order, String type) {
		return new Ajax(this.daoDefine.pageDefine(start, limit, query, getQueryOrder(order, type)));
	}

	@RequestMapping("platform/wxtoken/add")
	public Ajax add(final PWxDefine define) {
		this.sToken.addDefine(define);
		return new Ajax(define);
	}

	@RequestMapping("platform/wxtoken/edit")
	public Ajax edit(final PWxDefine define) {
		this.sToken.editDefine(define);
		return new Ajax();
	}

	@RequestMapping("platform/wxtoken/find")
	public Ajax find(final int token_id) {
		return new Ajax(this.daoDefine.find(token_id));
	}

	@RequestMapping("platform/wxtoken/delete")
	public Ajax delete(final int token_id) {
		this.sToken.deleteDefine(token_id);
		return new Ajax();
	}
}
