package cn.hmsoft.weixin.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.hmsoft.frame.data.model.FrameOptr;
import cn.hmsoft.frame.service.FrameService;
import cn.hmsoft.frame.util.FrameAssertUtil;
import cn.hmsoft.weixin.data.dao.WxParamDao;
import cn.hmsoft.weixin.data.model.WxParam;

@Service
public class WxParamService extends FrameService {

	@Autowired
	private WxParamDao daoParam;

	public void editParam(int wx_id, WxParam param, FrameOptr optr) {
		FrameAssertUtil.checkParam(wx_id, param.getParam_name(), param.getParam_value());
		String sql = "delete from wx_param where  wx_id=? and param_name=?";
		this.daoParam.updateBySql(sql, wx_id, param.getParam_name());
		this.daoParam.insert(param);
	}

	public void delParam(int wx_id, String param_name, FrameOptr optr) {
		String sql = "delete from wx_param where wx_id=? and param_name=?";
		this.daoParam.updateBySql(sql, wx_id, param_name);
	}
}
