<?php
/**
 * UserMst Entity
 * $Id: UserMst.inc,v 1.1 2020/1/16 11:09:00 Exp $
 * @author lixq
 * @package jp.compass.entity
 * @access public
 */
class UserMst extends CompassDynamicData
{
	var $school_id;
	var $class_id;
	var $name;
	var $tel_no;
	var $unionid;
	var $status;
	var $account_id;
	var $child_age;
	var $role;
	var $point;
	var $longitude;
	var $latitude;
	var $organization_submit_date;
	var $organization_no;
	var $organization_title;
	var $legal_person;
	var $organization_contact;
	var $legal_person_imgage1;
	var $legal_person_imgage2;
	var $licensen_imgage;
	var $other_imgage;
	var $organization_status;
	var $ability_point;
	var $service_point;
	var $delete_flg;

	/**
	 * 构造实现。user_mst创建实例。
	 * 
	 * @access public
	 * @param mixed user_mst
	 */
	function constructor($record)
	{
		parent::constructor($record);

		$this->school_id                = $record["school_id"];
		$this->class_id                 = $record["class_id"];
		$this->name                     = $record["name"];
		$this->tel_no                   = $record["tel_no"];
		$this->unionid                  = $record["unionid"];
		$this->status                   = $record["status"];
		$this->account_id               = $record["account_id"];
		$this->child_age                = $record["child_age"];
		$this->role                     = $record["role"];
		$this->point                    = $record["point"];
		$this->longitude                = $record["longitude"];
		$this->latitude                 = $record["latitude"];
		$this->organization_submit_date = $record["organization_submit_date"];
		$this->organization_no          = $record["organization_no"];
		$this->organization_title       = $record["organization_title"];
		$this->legal_person             = $record["legal_person"];
		$this->organization_contact     = $record["organization_contact"];
		$this->legal_person_imgage1     = $record["legal_person_imgage1"];
		$this->legal_person_imgage2     = $record["legal_person_imgage2"];
		$this->licensen_imgage          = $record["licensen_imgage"];
		$this->other_imgage             = $record["other_imgage"];
		$this->organization_status      = $record["organization_status"];
		$this->ability_point            = $record["ability_point"];
		$this->service_point            = $record["service_point"];
		$this->delete_flg               = $record["delete_flg"];
	}

	/**
	 * 根据条件,获取数据列表。
	 * 条件与DBManager的doSelect相同。
	 * @access public
	 * @static
	 * @param array 检索条件
	 * @return array Entity的队列
	 */
	public static function getList($w_param = null, $orderkey = null, $direction = "ASC", $offset = null, $limit = null)
	{
		if ($w_param == null) {
			$w_param = array();
			$w_param["delete_flg"] = "false";
		}

		return CompassDBHandler::getList("UserMst", "user_mst", $w_param, $orderkey, $direction, $offset, $limit);
	}

	/**
	 * 根据条件，获取数据列表的件数。
	 * 条件与DBManager的doSelect相同。
	 * @access public
	 * @static
	 * @param array 检索条件
	 * @return array Entity的队列
	 */
	public static function getListCount($w_param = null)
	{
		if ($w_param == null) {
			$w_param = array();
			$w_param["delete_flg"] = "false";
		}
		$db = CompassDBManager::getInstance();
		$result = $db->doSelect("user_mst", $w_param, null, null, null, null, "count(*) as count");

		return $result[0]["count"];
	}

	/**
	 * 获得此类指定ID的实例。
	 */
	public static function getById($id)
	{
		// delete_flg
		$param = array();
		$param["delete_flg"] = false;

		return CompassDBHandler::getById("UserMst", "user_mst", $id, $param);
	}

	// -- 这里开始Dynamic ---
	/**
	 * 将此实例写入DB。
	 * DynamicData共用的保存方法。
	 * @access public
	 * @return int 写入实例的ID
	 */
	public function save()
	{
		$v_param = array();

		ParamUtil::copyObj2Array($v_param, $this, "school_id");
		ParamUtil::copyObj2Array($v_param, $this, "class_id");
		ParamUtil::copyObj2Array($v_param, $this, "name");
		ParamUtil::copyObj2Array($v_param, $this, "tel_no");
		ParamUtil::copyObj2Array($v_param, $this, "unionid");
		ParamUtil::copyObj2Array($v_param, $this, "status");
		ParamUtil::copyObj2Array($v_param, $this, "account_id");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "child_age");
		ParamUtil::copyObj2Array($v_param, $this, "role");
		ParamUtil::copyObj2Array($v_param, $this, "point");
		ParamUtil::copyObj2Array($v_param, $this, "longitude");
		ParamUtil::copyObj2Array($v_param, $this, "latitude");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "organization_submit_date");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "organization_no");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "organization_title");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "legal_person");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "organization_contact");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "legal_person_imgage1");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "legal_person_imgage2");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "licensen_imgage");
		ParamUtil::copyObj2ArrayNullField($v_param, $this, "other_imgage");
		ParamUtil::copyObj2Array($v_param, $this, "organization_status");
		ParamUtil::copyObj2Array($v_param, $this, "ability_point");
		ParamUtil::copyObj2Array($v_param, $this, "service_point");
		ParamUtil::copyObj2Array($v_param, $this, "delete_flg");

		// 保存
		parent::_save("user_mst", $v_param);
	}
}