MyBatis -Implementierung liest die Baumstrukturdaten im Detail wie folgt:
Tabellenstruktur
Erstellen Sie die Tabelle `lscrm_function_privilege` (` id` int (10) Unsigned NOUL NULL AUTO_INCREMENT 'NUMMER', `CREATE_ID` VARCHAR (30) NICHT NULL DEFAULT 'SYS' SYS ',` UPDATE_ID_ "VARCHAR (30) NICHT NULL MATION' SYS ',` CREATE_MOTHE_MODTEL. Zeitstempel nicht null Standard Current_Timestamp auf Update current_timestamp Kommentar 'Modifikationszeit', "Gültigkeit" Tinyint (3) Nicht signiert nicht null Standard '1' Kommentar 'Validität 1. Tinyint (3) nicht signiertes Null -Standard '0' Kommentar 'übergeordneter Knoten', `is_leaf_node` Tinyint (3) Nicht signiert Null -Standard '1' Kommentar 'der Blattknoten (ein Blattknoten ist ein Knoten mit einem Grad von 0, der ein Knoten ohne untergeordnete Knoten ist). 0 ', `sub_system_id` int (10) nicht signiert null Standard' 0 'Kommentar' Subsystem ',` is_hidden` tinyint (3) Unsigned Null Null Standard' 0 'Kommentar' ist die UI versteckt? Nicht auf UI angezeigt, Primärschlüssel (`id`)) Engine = InnoDB Auto_increment = 22 Standard charSet = utf8 comment = 'subcode create /r /n gemäß dem übergeordneten Code, wie z. B.: customer.add';
Daten konstruieren
Einfügen in "lscrm_function_privilege" Werte ('1', 'sys', 'sys', '2016-09-07 15:20:40,', 2016-09-07 15:21:17 ',' 1 ',' Web.Permission ',' Erlaubnismanagement ',' 0 ',' 0 ',', ',' 0 '; `lscrm_function_privilege` VALUES ('2', 'sys', 'sys', '2016-09-07 15:21:12', '2016-09-07 15:21:40', '1', 'WEB.PERMISSION.USER-MGMT', 'User Management', '1', '0', '1', '1', '0');INSERT INTO `lscrm_function_privilege` Werte ('3', 'sys', 'sys', '2016-09-07 15:22:16', '2016-09-07 15:22:35', '1', 'Web.Permission.User-Mgmt.add.add.add,' add add add usa add add. ',' 2 ',' 1 ',' `lscrm_function_privilege` Werte ('4', 'sys', 'sys', '2016-09-07 15:23:17', '2016-09-07 15:23:17', '1', 'Web.Permission.User-Mgmt.modify', 'modify’,', ',', ',', ',', ',', ',', ',', ',', ','. `lscrm_function_privilege` Werte ('5', 'sys', 'sys', 2016-09-07 16:10:37 ',' 2016-09-07 16:10:42 ',' 1 ',' App.Customer ',' Customer Management ',' 0 ',' 0 ',' 2 ','; ('6', 'sys', 'sys', 'sys', '2016-09-07 16:11:06', '2016-09-07 16:11:20', '1', 'App.Customer.add', 'add Customer', '5', '1', '2', '0'; 'sys', '2016-09-07 16:11:06', '2016-09-07 16:11:20', '1', 'App.Customer.modify', '5', '1', '2', '0'; 16:12:33 ',' 2016-09-07 16:14:10 ',' 1 ',' App.Customer.ViewDetail ',' Customer Details ',' 5 ',' 1 ',' 2 ',' 0 '; '2016-09-07 16:12:33', '1', 'APP.CUSTOMER.ADDVISIT', 'Add Visit', '5', '1', '2', '0');INSERT INTO 'lscrm_function_privilege` VALUES ('10', 'sys', 'sys', '2016-09-07 16:13:59', '2016-09-07 16:14:17', '1', 'APP.CUSTOMER.VIEWDEMAND', 'View Customer Procurement Requirements', '5', '1', '2', '0');INSERT INTO `lscrm_function_privilege` VALUES ('11', 'sys', 'sys', '2016-09-07 16:13:59', '2016-09-07 16:14:17', '1', 'APP.CUSTOMER.VIEWORDER', 'View Customer Order', '5', '1', '2', '0');INSERT INTO `lscrm_function_privilege` VALUES ('12', 'sys', 'sys', '2016-09-07 16:13:59', '2016-09-07 16:14:17', '1', 'App.Customer.ViewShop', 'Customer Order', '5', '1', '2', '0'; 'App.customer.viewreeply', 'order order gabing liste', '5', '1', '2', '0'); Einfügen in "lscrm_function_privilege`) ('14', 'Sys', 'Sys', 2016-07-07 16:19:32 ',' 2016-09-09-07 16:51, '1', ' 'APP.CUSTOMER.FASTOPENSHOP', 'Quick Store Opening', '5', '1', '2', '0');INSERT INTO `lscrm_function_privilege` VALUES ('15', 'sys', 'sys', '2016-09-07 16:22:33', '2016-09-07 16:22:33', '1', 'APP.DEMAND', 'Demand Management', '0', '0', '2', '0');INSERT INTO `lscrm_function_privilege` VALUES ('17', 'sys', 'sys', '2016-09-07 16:23:21', '2016-09-07 16:23:21', '1', 'APP.DEMAND.PRIVATE', 'Private sea demand', '15', '1', '1', '2', '0'); Einfügen in "lscrm_function_privilege`) ('18', 'sys', 'sys', '2016-09-07 16:23:58', '2016-09-07 16:23:58' '2', '0');INSERT INTO `lscrm_function_privilege` VALUES ('19', 'sys', 'sys', '2016-09-07 16:24:47', '1', 'APP.DEMAND.PUSHSEARCH', 'Pull Seller Search', '15', '1', '2', '0');INSERT INTO '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1'; '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', ',', ',', ',', ',', ',' '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', ',', ',', ',', ',', ',' '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', App.Kpi.ViewData ',' Performance Data ',' 20 ',' 1 ',', '0');Entitätsbohne
Paket com.lianshang.crm.biz.entity; import com.google.common.base CreateTime;/** Änderungszeit **/privates Datum UpdateTime = new Date ();/** Validität 1.Valid 0. Ungültiges **/private int Validität = 1;/** codieren **/privater String -Code;/** Name **/private String -Funktionsname;/** übergeordnete Note **/privat intid. Beim Hinzufügen von untergeordneten Knoten muss parent_id is_leaf_node auf 0 **/private int isLeafNode;/** verbundenes Subsystem **/privat int subsystemid;/** ist die UI versteckt? Es wird nicht auf der UI **/private int ishidden = 1; private Liste <lscrmfunctionPrivileGeEntity> privilegelist = new ArrayList <> (); // get ()/set () angezeigt. . . } Paket com.lianshang.crm.biz.entity; import java.util.arraylist; import Java.util.date; Import Java.util.List;/*** Erstellt von Zhenyu am 2016/9/8. updatetime = new Date ();/** Validität 1.Valid 0. Ungültig **/private int validity = 1;/** codieren **/privater String -Code;/** Name **/private String -Funktionsname;/** übergeordneter Knoten **/privat intid;/** ist der Blattknoten (Urlaub des Node mit einem Grad von 0 und einem Knoten ohne Knoten). Beim Hinzufügen von untergeordneten Knoten muss parent_id is_leaf_node auf 0 **/private int isLeafNode;/** verbundenes Subsystem **/privat int subsystemid;/** ist die UI versteckt? Es wird nicht auf der UI **/private int ishidden = 1; private Liste <lscrmfunctionPrivileGeEttity> privilegelist = new ArrayList <> ();} angezeigt
Mapper -Konfiguration
<? namespace = "com.lianshang.crm.biz.dao.lscrmfunctionPrivileggedao"> <cacheeviction = "FIFO" FlushInterval = "60000" size = "1024" Readonly = "True"/> <resultMap id = "lscrmfunctionPrivileThy"> "> Eigenschaft = "id" column = "id"/> <resulting Eigenschaft = "createId" column = "create_id"/> <resulting Eigenschaft = "updateId" column = "update_id"/> <resulting Eigenschaft = "createtime" column = "create_time"/> <resulting Properation = "updatetime" coole "code column = "function_name"/> <result properation = "parentId" column = "parent_id"/> <resulting properation = "isleafnode" column = "is_leaf_node"/> <resulting property = "subSystemId" column = "sub_system_id"/> <resulting probiode column="is_hidden"/><result property="SubPrivilegesResult" type="LscrmFunctionPrivilegeEntity" extends="LscrmFunctionPrivilegeResult"><collection property="privilegeList" javaType="java.util.ArrayList" column="id"ofType="LscrmFunctionPrivilegeEntity" select = "selectSubPrivileges"> </collection> </resultMap> <resultMap id = "lscrmfunctionPrivileGetreeresult" type = "lscrmfunctionRivileGetree" Extends = "subprivileGegesResult"> <! resultMap="LscrmFunctionPrivilegeResult"/>--><collection property="privilegeList" javaType="java.util.ArrayList" column="id"ofType="LscrmFunctionPrivilegeEntity" select="selectSubPrivileges"></collection></resultMap><sql id="tbl_name">lscrm_function_privilege</sql><sql id="role_privilege_tbl_name">lscrm_role_privilege</sql><sql id="select_sql">select id, create_id, update_id, create_time, update_time, validity, code, function_name, parent_id, is_leaf_node, sub_system_id, is_hidden aus <include refid = "tbl_name"/> </sql> <select id = "readAllPrivileges" resultMap = "lscrmfunctionPrivileGetreeResult" usecache = "true". sub_system_id = #{subsystemid} </wenn com.lianshang.crm.api.dto.lscrmfunctionPrivilege; Import com.lianshang.crm.biz.entity.lscrmfunctionPrivileGeentity; LscrmfunctionPrivilegegedao {list <lscrmfunctionPrivileGetree> readAllPrivileges (@param ("subsystemid") int subsystemid);}Service
Paket com.lianshang.crm.biz.service.impl; import com.alibaba.fastjson.json; import com.google.common.base com.lianshang.common.utils.general.stringutil; import com.lianshang.crm.api.dto.lscrmfunctionPrivilege; Import com.lianshang.crm.api.Service.lscrmfunctionPrivileService; com.lianshang.crm.biz.entity.lscrmfunctionPrivileGeEentity; Import Com.lianshang.crm.biz.Entity.LSCRMFunctionPriviletree; Import org.springframework.bean.factory.Annotation.autowired; java.util.list; static com.google.common.collect.fluentiterable.From; ReadAllPrivileges (int subsystemid) {list <lscrmfunctionPrivileGetree> privilegegrees = lscrmfunctionPrivilegedao.readAllPrivileges (subsystemid);Rückgabeergebnis
[{"code": "WEB.PERMISSION","createId": "sys","createTime": 1473232840000,"functionName": "Permission Management","hidden": 0,"id": 1,"leafNode": 0,"parentId": 0,"privilegeList": [{"code": "WEB.PERMISSION.USER-MGMT","createId": "sys","createTime": 1473232872000,"functionName": "User Management","hidden": 0,"id": 2,"leafNode": 0,"parentId": 1,"privilegeList": [{"code": "WEB.PERMISSION.USER-MGMT.ADD","createId": "sys","createTime": 1473232936000,"functionName": "New user","hidden": 0,"id": 3,"leafNode": 1,"parentId": 2,"privilegeList": [],"subSystemId": 1,"updateId": "sys","updateTime": 1473232955000,"validity": 1},{"code": "WEB.PERMISSION.USER-MGMT.MODIFY","createId": "sys","createTime": 1473232997000,"functionName": "Modify user","hidden": 0,"id": 4,"leafNode": 1,"parentId": 2,"privilegeList": [],"subSystemId": 1,"updateId": "sys", "updatetime": 1473232997000, "Validität": 1}], "Subsysteme": 1, "UpdateId": "Sys", "Updatetime": 1473232900000, "Gültigkeit": 1}, "Subsystem": 1, "Update": ":" SYSS ":" 1473232877000, "Gültigkeit": 1}] Das obige ist der Beispielcode für die Implementierung von MyBatis Lese -Baumstrukturdaten, die Ihnen vorgelegt wurden. Ich hoffe, es wird Ihnen hilfreich sein. Wenn Sie Fragen haben, hinterlassen Sie mir bitte eine Nachricht und der Editor wird Ihnen rechtzeitig antworten. Vielen Dank für Ihre Unterstützung auf der Wulin.com -Website!