| | |
| | | // |
| | | // Created by pans on 4/28/18. |
| | | // |
| | | /*** |
| | | * 说明,本文件主要是sql语句拼接及获取已定义的sql语句 |
| | | * 目前仅支持单表sql语句拼接 |
| | | */ |
| | | |
| | | #ifndef TESTSQLITE_SQLITETOOLKIT_HPP |
| | | #define TESTSQLITE_SQLITETOOLKIT_HPP |
| | |
| | | */ |
| | | typedef std::vector<unsigned char> FaceFeature; |
| | | |
| | | /*** |
| | | * 添加人脸的数据结构 |
| | | */ |
| | | struct AddFaceData { |
| | | std::string uuid; |
| | | FaceFeature feature; |
| | |
| | | std::string feature_base64; |
| | | }; |
| | | |
| | | /*** |
| | | * 人脸信息的数据结构 |
| | | */ |
| | | struct FaceInfo { |
| | | std::string uuid; |
| | | std::string personName; |
| | |
| | | typedef std::vector<FaceInfo> FaceInfos; |
| | | typedef std::map<std::string, FaceInfo> FaceInfosCache; |
| | | |
| | | /*** |
| | | * 表信息数据结构 |
| | | */ |
| | | struct TableInfo { |
| | | std::string uuid; |
| | | std::string tableName; |
| | |
| | | |
| | | //typedef std::map<std::string, FaceFeatures> FeatureDBCache; |
| | | |
| | | /*** |
| | | * 带有URL和其他属性的人脸特征数据结构 |
| | | */ |
| | | struct FaceFeatureWithUrl { |
| | | std::string uuid; |
| | | std::string faceurl; |
| | |
| | | #define SQLERR(message) fprintf(stderr, "%s->%d-> SQLite error: %s\n",__FILE__,__LINE__, message); |
| | | |
| | | |
| | | //#todo 数据库wenjian名称 |
| | | //#todo 数据库文件名称 |
| | | //是否需要从配置文件读取? |
| | | static std::string file_dbName = "TestFaceDB.db"; |
| | | //#todo 数据库名称 |
| | | static std::string g_dbName = "main"; |
| | | //#todo 管理表的表名 |
| | | static std::string g_tableName = "sys_o_tables"; |
| | | |
| | | // |
| | | /*** |
| | | * 获取人脸特征查询的sqlite语句 |
| | | * @param tableName 表名,不带 _fea |
| | | * @return |
| | | */ |
| | | std::string getFacesFromTableSql(std::string tableName) { |
| | | // #todo get monLevel 联合查询 |
| | | std::string sql = |
| | |
| | | return sql; |
| | | } |
| | | |
| | | /*** |
| | | * 根据表类型获取数据表列表 |
| | | * @param type |
| | | * @return |
| | | */ |
| | | std::string getTableListSqlWithType(std::string type) { |
| | | std::string sql = "select tableName,del_flag from '" + g_tableName + "' where del_flag = 0"; |
| | | if (type.size() > 0) { |
| | |
| | | return sql; |
| | | } |
| | | |
| | | /*** |
| | | * 查询任意表的所有字段 |
| | | * @param tableName |
| | | * @return |
| | | */ |
| | | std::string getTableInfosSql(std::string tableName) { |
| | | std::string sql = "select * from '" + tableName + "';";// + " where del_flag = 0"; |
| | | return sql; |
| | | } |
| | | |
| | | |
| | | /*** |
| | | * 获取当前已创建的表 |
| | | * @return |
| | | */ |
| | | std::string getTableInfosSql() { |
| | | //uuid,tableName,tableDesc,tableType,bwType,startTime,endTime |
| | | std::string sql = |
| | |
| | | return sql; |
| | | } |
| | | |
| | | |
| | | /*** |
| | | * 获取更新人脸业务信息表的sql语句 |
| | | * @param tableName |
| | | * @param fieldValues |
| | | * @return |
| | | */ |
| | | std::string getUpdateFaceTableSql(std::string tableName, FieldValues &fieldValues) { |
| | | if (tableName.size() == 0) { |
| | | //#todo errInfo |
| | |
| | | |
| | | |
| | | //#TODO 人脸表需要删除两个 |
| | | /*** |
| | | * 获取删除人脸表的sql语句 |
| | | * @param tableName |
| | | * @return |
| | | */ |
| | | std::string getDeleteFaceTableSql(std::string tableName) { |
| | | if (tableName.size() == 0) { |
| | | //#todo errInfo |