#pragma once

#include "DataFields.h"

struct PageInfo;



namespace DMOperator
{
    const string TABLENAME = "operator";
    const string FID_ID = "id";
    const string FID_USERNAME = "username";
    const string FID_PASSWD = "passwd";
    const string FID_REALNAME = "real_name";
    const string FID_PHONE = "phone";
    const string FID_ROLE = "role_name";
    const string FID_CREATETIME = "create_time";
    const string FID_UPDATETIME = "update_time";
}

namespace DMRole
{
    const string TABLENAME = "role";
    const string FID_ID = "id";
    const string FID_ROLE_NAME = "role_name";
    const string FID_ROLE_NO = "role_no";
    const string FID_TYPE = "type";
    const string FID_DESCRIBE = "describe";
    const string FID_IS_OPEN = "is_open";
}

namespace DMPermission
{
    const string TABLENAME = "permission";
    const string FID_ID = "id";
    const string FID_FUNC = "func";
    const string FID_URL = "url";
    const string FID_REMARK = "remark";
}

namespace DMRolePermission
{
    const string TABLENAME = "role_permission";
    const string FID_ID = "id";
    const string FID_ROLE_ID = "role_id";
    const string FID_PERMISSION_ID = "permission_id";
}

namespace DMPolicy
{
    const string TABLENAME = "policy";
    const string FID_ID = "id";
    const string FID_TYPE = "type";
    const string FID_CODE = "code";
    const string FID_NAME = "name";
    const string FID_VALUE = "value";
    const string FID_REMARK = "remark";
    const string FID_IS_OPEN = "is_open";
    const string FID_UPDATE_TIME = "update_time";
}




class DaoAdmin
{
public:
    // ************************************************************************************************
    // 操作员账号管理
    /**
    * 更新操作员信息
    * @param: fields 更新的字段信息
    * @param: sql_c 更新条件, 例："where id='1'"
    */
    static bool insert_operator(DataFields& fields);

    /**
    * 更新操作员信息
    * @param: fields 更新的字段信息
    */
    static bool update_operator_by_id(DataFields& fields);

    /**
    * 分页查询操作员信息
    * @param: pageinfo 分页信息
    * @param：result 查询结果数据集
    */
    static bool query_operator_page(PageInfo& pageinfo, vector<DataFields>& result);

    static bool query_operator_by_name(string name, vector<DataFields>& result);

    // ************************************************************************************************
    // 权限管理
    // 
    static int insert_permission(DataFields& fields);
    static bool query_permission(PageInfo& pageinfo, vector<DataFields>& result, string sql_c);
    static bool update_permission(DataFields& fields, const string& sql_c);

    // ************************************************************************************************
    // 角色管理
    static bool query_role(vector<DataFields>& result);
    static bool update_role_by_id(DataFields& fields);



    static bool query_admin_permission(string account, vector<DataFields>& result);

    // ************************************************************************************************
    // 策略管理
    static int insert_policy(DataFields& fields);
    static bool query_policy(PageInfo& pageinfo, vector<DataFields>& result, string sql_c);
    static bool update_policy(DataFields& fields, const string& sql_c);




};