text: ###########################################
  # Generated by AutoCRUD                   #
  #                                         #
  # This file is used to create private     #
  # methods                                 #
  ###########################################
  
  from flask import Flask, request, jsonify
  from common import app, db, getJson, filterDict, convertDbModel
  from flask import Flask, request, jsonify
  from common import app, db, getJson
  from .model import {{MODULE_NAME}}
  
  def toJson(arg, filter=True):
      if arg is None:
          return jsonify({"id":None})
      elif filter:
          return jsonify(filterPrivate(arg))
      else:
          return jsonify(arg)
  
  def filterPrivate(obj):
      filterKeyList = [
  {%- for COLUMN in COLUMNS -%}
  {%- if COLUMN["props"]["private"] %}
          '{{COLUMN["name"]}}',
  {%- endif -%}
  {%- endfor %}
      ]
      return convertDbModel(obj, filterKeyList)
  
  def create_{{MODULE_NAME}}(
      {%- for COLUMN in COLUMNS %}
      {{ COLUMN["name"] }}
      {%- if not loop.last -%}
      ,
      {%- endif -%}
      {%- endfor %}
  ):
      obj = {{MODULE_NAME}}(
          {%- for COLUMN in COLUMNS %}
          {{ COLUMN["name"] }} = {{COLUMN["name"]}}
          {%- if not loop.last -%}
          ,
          {%- endif -%}
          {%- endfor %}
      )
      db.session.add(obj)
      db.session.commit()
      return {"id": obj.id}
  
  def delete_{{MODULE_NAME}}(id):
      obj = {{MODULE_NAME}}.query.filter_by(id=id, deleted=False).first()
      if obj is not None:
          db.session.delete(obj)
          db.session.commit()
          return {"id": obj.id}
      else:
          return {"id": None}
  
  def update_{{MODULE_NAME}}(
      id,
      {%- for COLUMN in COLUMNS %}
      {{ COLUMN["name"] }}
      {%- if not loop.last -%}
      ,
      {%- endif -%}
      {%- endfor %}
  ):
      obj = {{MODULE_NAME}}.query.filter_by(id=id, deleted=False).first()
      if obj is None:
          return {"id": None}
      {% for COLUMN in COLUMNS -%}
      obj.{{ COLUMN["name"] }} = {{ COLUMN["name"] }}
      {% endfor %}
      db.session.commit()
      return {"id": obj.id}
  
  def get_{{MODULE_NAME}}(id):
      obj = {{MODULE_NAME}}.query.filter_by(id=id, deleted=False).first()
      return obj
  
  def list_{{MODULE_NAME}}(page=1, perPage=10):
      objs = {{MODULE_NAME}}.query.paginate(page, perPage)
      return {"data":objs.items, "page":objs.page, "pages":objs.pages, "prev":objs.prev_num, "next": objs.next_num}
  
  {% for COLUMN in COLUMNS %}
  def find_{{MODULE_NAME}}_by_{{ COLUMN["name"] }}({{ COLUMN["name"] }}, page=1, perPage=10):
      objs = User.query.filter_by(
          {{ COLUMN["name"] }}={{ COLUMN["name"] }}, 
          deleted=False
      ).paginate(page, perPage)
      return {"data":objs.items, "page":objs.page, "pages":objs.pages, "prev":objs.prev_num, "next": objs.next_num}
  {% endfor %}
  
  {% for COLUMN in COLUMNS %}
  def search_{{MODULE_NAME}}_by_{{ COLUMN["name"] }}({{ COLUMN["name"] }}, page=1, perPage=10):
      objs = User.query.filter(
          {{MODULE_NAME}}.{{ COLUMN["name"] }}.like('%'+ {{ COLUMN["name"] }} +'%'), 
          {{MODULE_NAME}}.deleted==False
      ).paginate(page, perPage)
      return {"data":objs.items, "page":objs.page, "pages":objs.pages, "prev":objs.prev_num, "next": objs.next_num}
  {% endfor %}
  
  {% for COLUMN in COLUMNS %}
  def update_{{MODULE_NAME}}_prop_{{ COLUMN["name"] }}(id, {{ COLUMN["name"] }}):
      obj = {{MODULE_NAME}}.query.filter_by(id=id, deleted=False).first()
      if obj is None:
          return {"id": None}
      obj.{{ COLUMN["name"] }} = {{ COLUMN["name"] }}
      db.session.commit()
      return {"id": obj.id, '{{ COLUMN["name"] }}': obj.{{ COLUMN["name"] }}}
  {% endfor %}