Implementasi mybatis membaca data struktur pohon secara rinci sebagai berikut:
Struktur tabel
Buat tabel `lscrm_function_privilege` (` id` int (10) tidak ditandatangani bukan null auto_increment komentar 'nomor', `create_id` varchar (30) bukan null default 'sys',` update_id` varchar (30) bukan nol default 'sys', `create_time` not not `not not null default 'nol' timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Modification time',`validity` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT 'Validity 1. Valid 0. Invalid',`code` varchar(50) NOT NULL DEFAULT '' COMMENT 'Coding',`function_name` varchar(50) NOT NULL DEFAULT '' COMMENT 'name',`parent_id` TinyInt (3) Tidak ditandatangani Null default '0' Comment 'Parent Node', `is_leaf_node` tinyint (3) Tidak ditandatangani NULL DEFAULT '1' Komentar 'adalah node daun (node daun adalah node dengan tingkat 0, yang merupakan node tanpa node anak). 0 ', `sub_system_id` int (10) tidak ditandatangani bukan null default' 0 'komentar' subsystem ',` is_hidden` tinyint (3) tidak ditandatangani bukan null default' 0 'komentar' adalah UI tersembunyi? Tidak ditampilkan pada ui ', kunci utama (`id`)) engine = innodb auto_increment = 22 charset default = utf8 comment =' Sub-Code create /r /n sesuai dengan kode induk, seperti: customer.add ';
Bangun data
Masukkan ke `lscrm_function_privilege` values ('1', 'sys', 'sys', '2016-09-07 15:20:40', '2016-09-07 15:21:17', '1', 'Web.permission', 'LIFISION', '0,' 0, '1,' 1, '1,' 1, '1,' 1, '1,' 1, '1,' 1, '1,' 1, '1,' 1, '1,' 1, '1, Nilai ('2', 'sys', 'sys', '2016-09-07 15:21:12', '2016-09-07 15:21:40', '1', 'Web.permission.user-Mgmt', 'Manajemen Pengguna', '1', '0,' 1 ',' 1 ',' 0 '); (1', '1', '0', '1', '1', '1, 'sys', 'sys', '2016-09-07 15:22:16', '2016-09-07 15:22:35', '1', 'web.permission.user-mgmt.add', 'tambahkan pengguna', '2', '1', '1', '0'); `` `` `` `` `` `` `` `` `, ' 'Sys', '2016-09-07 15:23:17', '2016-09-07 15:23:17', '1', 'Web.permission.user-Mgmt.modify', 'Modifikasi Pengguna', '2', '1', '1', '0'); masukkan ke dalam `'' '' ',' 1, '1,' 1 ',' 1, '' '', '1,' 1, '1', '1', '1', '1,' 1, '1,' 1, '2016-09-07 16:10:37', '2016-09-07 16:10:42', '1', 'app.customer', 'Manajemen Pelanggan', '0', '0', '2', '0'); masukkan ke `lscrm_function_privilege` nilai ('6', ',', '6', ',' 6 ',', '6', ',' 6 ',', '6', ',' 6 ',' 6 ',' 6 ',' 6, '6,' 6, '6,' 6, '6,' 6, '6,' 6, '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6', '6 16:11:06 ',' 2016-09-07 16:11:20 ',' 1 ',' app.customer.add ',' Tambahkan Pelanggan ',' 5 ',' 1 ',' 2 ',' 0 '); masukkan ke' LSCRM_FUNCTION_PRIVILEGE` ('7', 'Sys', ', '09, '09- 2016- 2016:1109 (' 7 ',', ',', ',', '7', '7', '7', '7' 16:11:20 ',' 1 ',' app.customer.modify ',' 5 ',' 1 ',' 2 ',' 0 '); masukkan ke `lscrm_function_privilege` values (' 8 ',' sys ',' sys ',' 2016-09-07 16:12:33 ',' 2016-0 2016-09:0.09:10 '14, '1,' 1, '1 2016-09-07, 'App.customer.viewDetail', 'lihat detail pelanggan', '5', '1', '2', '0'); masukkan ke `lscrm_function_privilege` values ('9', 'sys', 'sys', '2016-09-07 16:12:33', '2016-09-09-09-07:12:12:12:12:33', '2016-09,' '2016-09,' '' 2016-09, '' 2016-09-09, '2016' 2016 'App.customer.addvisit', 'tambahkan kunjungan', '5', '1', '2', '0'); masukkan ke 'lscrm_function_privilege` nilai (' 10 ',' sys ',' sys ',' 2016-09-07 16:13:59 ',' 2016-09-07 16:17 16:17 ',' 1 ',' 1 ',' 2016 ',' 2016 ',' 2016-09, 'App.customer.viewDemand', 'Lihat Persyaratan Pengadaan Pelanggan', '5', '1', '2', '0'); masukkan ke `lscrm_function_privilege` values ('11', 'sys', 'sys', '2016-09-07 16:13:59', '2016-09-09.09.09-09-07 16:13:59', '' 2016 ',' '2016', '2016-09-09-07 16:13:13:13:13:59 'App.customer.vieworder', 'lihat pesanan pelanggan', '5', '1', '2', '0'); masukkan ke dalam `lscrm_function_privilege` values ('12', 'sys', 'sys', '2016-09-07 16:13:59', '2016-09-07 16:17', '1', '1', '2016', '2016', '2016', '2016', '2016', '2016', '2016', '2016' 2016 ' 'App.customer.viewshop', 'lihat pesanan pelanggan', '5', '1', '2', '0'); masukkan ke `lscrm_function_privilege` values ('13', 'sys', 'sys', '2016-09-07 16:17:28', '2016-09-07 16:17 16:17:17:28', '2016', '2016', '2016', '2016', '2016', '2016, 'App.customer.viewReply', 'Lihat daftar ambil pesanan', '5', '1', '2', '0'); masukkan ke `lscrm_function_privilege` values ('14', 'sys', 'sys', '2016-09-07 16:19:32', '2016-09-09-09:' '' '' '' '' 2016 '' '' 2016 '' '2016' '' 2016 '' '2016' 2016 '' 'App.customer.fastopenshop', 'pembukaan toko cepat', '5', '1', '2', '0'); masukkan ke `lscrm_function_privilege` values ('15', 'sys', 'Sys', '2016-09-07 16:22:33','.don ','doand', '2016-09-07 16:22:33', '2016-09-09-07:22:22:22:' 1, '1,' 2016-09-09, ' 'Manajemen Permintaan', '0', '0', '2', '0'); masukkan ke `lscrm_function_privilege` value ('17', 'sys', 'sys', '2016-09-07 16:23:21', '2016-09-07 16:23:21', '' ',' '', '', '16-09-07 16:23:21 ',' '', '' ',' '' ',' ',' 1, '1,' 1, '1,' '1', '2', '0');INSERT INTO `lscrm_function_privilege` VALUES ('18', 'sys', 'sys', '2016-09-07 16:23:58', '2016-09-07 16:23:58', '1', 'APP.DEMAND.FEEDBACK', 'Page Feedback', '15', '1', '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'); masukkan ke dalam `lscrm_function_privilege` nilai ('21', '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', '1', '1', 'app.kpi.viewData', 'lihat data kinerja', '20', '1', '2', '0');Entitas kacang
Paket com.lianshang.crm.biz.entity; import com.google.common.base.moreObjects; import java.util.arraylist; import java.util.date; import java.util.list; private createIon; private; createTime;/**Modification time**/private Date updateTime=new Date();/**Validity 1.Valid 0. Invalid**/private int validity=1;/**Encoding**/private String code;/**Name**/private String functionName;/**Parent node**/private int parentId;/**Is the leaf node (leave node is a node with a degree of 0 and a node without child node). Saat menambahkan node anak, parent_id is_leaf_node perlu diatur ke 0 **/private int isleafnode;/** subsistem afiliasi **/private int subsystemid;/** Apakah UI disembunyikan? Ini tidak ditampilkan pada UI **/private int isHidden = 1; Daftar Privat <LSCRMFunctionPrivileEntity> PrivilegeList = New ArrayList <> (); // get ()/set () dihilangkan. . . } paket com.lianshang.crm.biz.entity; import java.util.arraylist; import java.util.date; import java.util.list;/*** dibuat oleh zhenyu pada 2016/9/8.*/Kelas Public CreateD; PrivateDegetree {/** Jumlah ID ** PRIVATE; Date updateTime=new Date();/**Validity 1.Valid 0. Invalid**/private int validity=1;/**Encoding**/private String code;/**Name**/private String functionName;/**Parent node**/private int parentId;/**Is the leaf node (leave node is a node with a degree of 0 and a node without child nodes). Saat menambahkan node anak, parent_id is_leaf_node perlu diatur ke 0 **/private int isleafnode;/** subsistem afiliasi **/private int subsystemid;/** Apakah UI disembunyikan? Itu tidak ditampilkan pada UI **/private int isHidden = 1; Daftar Privat <LSCRMFunctionPrivileEntity> PrivilegeList = New ArrayList <> ();}Konfigurasi Mapper
<? Xml Version = "1.0" encoding = "utf-8"?> <! Doctype mapper public "-// mybatis.org//dtd mapper 3.0 // en" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> namespace = "com.lianshang.crm.biz.dao.lscrmfunctionPrivilEgao"> <cacheeviction = "fifo" flushinterval = "60000" size = "1024" readonly = "true"/> <resultMap id = "lscrmfunctionPrivilegereGerEsull" type = "lscrMfunctionPrivilegerEreger" lscreRy "lscreRy" lScrMfunchePrivileger " kolom = "id"/> <properti result = "createid" kolom = "create_id"/> <properti result = "updateid" kolom = "update_id"/> <properti hasil = "createTime" kolom = "create_time"/> <Properti hasil = "hasil" code "code =" FUMBUT "/> <Property =" FUMBUT "FUMBUT =" KOLOM = "KOLOK =" FUMBUT "KOLOM =" FUMBUT "FUMBUT"/<" kolom = "function_name"/> <properti result = "parentId" kolom = "parent_id"/> <properti hasil = "isleafnode" kolom = "is_leaf_node"/> <properti hasil = "subsystemid" kolom = "Sub_System_id"/> <hasil hasil = "ishidden" kolom = "IS_HIDID"/> <hiddid "ISHIDED =" ISHIDID "ISHIDDE =" IS_HIDID "ISHIDDE" ISHIDDE = " Properti = "SubprivilegesResult" type = "lscrmfunctionPrivileentity" meluas = "lscrmfunctionPrivilegeresult"> <collection properti = "privilegelist" javatype = "java.util.arraylist" kolom = "id" ofType = "lscrmfunction SELECT = "SelectSubPrivilegeing"> </colly> </resultMap> <resultMap id = "lscrmfunctionPriviletReeresult" type = "lscrmfunctionPrivileGetree" Extends = "SubprivilegesResult"> <!-<asosiasi properti = "functionPrivilege" colom "Id" javaty "> <! resultMap = "lscrmfunctionPrivilegeresult"/>-> <collection properti = "privilegeList" javatype = "java.util.arraylist" kolom = "id" ofType = "lscrmfunctionPrivilegeentity" select = "selectsubprivilges"> </collection> </hasilnya 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 from <incerted refid = "tbl_name"/> </sql> <pilih id = "readAllprivileS" resultMap = "lscrmfunctionPrivilegetReeresult" USECACHE = "true"> <termasuk refid = "select_sql" ifeDED "ifeD =" true "> <termasuk refid =" select_sql "" ife-teer = "ifter =" true "> <termasuk refid =" select_sql "" ife-teed = "true"> <incerting = "squal" ifeD 'ifeD = "ifter =" ifter = "ifeD' sub_system_id = #{subsystemid} </if> </select> <pilih id = "selectsubprivilege" resultMap = "subprivilegesResult"> <include refid = "select_sql"/> di mana parent_id = #{id} </select> </mapper> paket com.lianshang.bang. com.lianshang.crm.api.dto.lscrmfunctionPrivilege; impor com.lianshang.crm.biz.entity.lscrmFunctionPrivileentity; impor com.lianshang.crm.biz.entity.lscrmfunctionPrivilegetree; impor org.apache.annan.annotis. LscrmFunctionPrivilEgao {list <lscrmfunctionPrivilEgetree> readAllprivilege (@param ("subsystemid") int subsystemid);}melayani
Paket com.lianshang.crm.biz.service.impl; import com.alibaba.fastjson.json; import com.google.common.base.function; impor com.lianshang.common.utils.general.generalResult; impor com.lianshang.common.utils.guaer. com.lianshang.common.utils.general.stringutil; impor com.lianshang.crm.api.dto.lscrmfunctionPrivilege; import com.lianshang.crm.api.service.lscrmfunctionPrivilegeService; com.lianshang.scrm.dao.daooCnuncingcringcringcringcringcringcringcringcring; com.lianshang.crm.biz.entity.lscrmfunctionPrivilegeentity; impor com.lianshang.crm.biz.entity.lscrmFunctionPriviletree; impor org.springframework.beans.factory.annotation.Autowired; impor java.util.ravay.ravay.factory.annotation. java.util.list; impor statis com.google.common.collect.fluentitable.from; kelas publik lscrmfunctionPrivilegeServiceImpl mengimplementasikan lscrmFunctionPrivilegeService {@AutowiredPrivate lscrmfunctionPrivilEgao LSCRMFunctionPrunctionPrivingPriving @Overprivate; LSCRMICTRICTRIGEDAO LSCRMFUNCTIC readAllPrivileges (int subsystemid) {list <lscrmfunctionPriviletree> privilegetrees = lscrmFunctionPrivilEgao.readAllPrivileges (subsystemid); return GeneralResult baru <> (json.toJsonstring (privilegetrees));}}}} (jsonHasil pengembalian
[{"kode": "web.permission", "createid": "sys", "createTime": 1473232840000, "functionName": "Manajemen Izin", "Tersembunyi": 0, "id": 1, "leafnode": "ParentId": 0, "Hak istimewa": [{{{{{{{{{{{{{{{{", "Sys", "CreateTime": 1473232872000, "FunctionName": "Manajemen Pengguna", "Tersembunyi": 0, "Id": 2, "Leafnode": 0, "ParentID": 1, "Privilegelist": [{"Code": "Web.PerMission.user-Mgmt.add": "createM," creatim, "createMissim.User-mgmt.add": ":": "" createM, "creatmissim.Suser-MGMT.ADD": ":": "createM," creatmissim.User-user-mgmt.add ":": ":": ":" createMissiM. "createMissiM.PREORMIST.USER-MGMT." 1473232936000, "functionName": "pengguna baru", "tersembunyi": 0, "id": 3, "Leafnode": 1, "ParentId": 2, "Privilegelist": [], "Subsystemid": 1, "UpdateId": "Sys", "UpdateTime": 14732329, "UpdateId": "Sys", "UpdateTime": 14732329, "UpdateID": "SYS", "UpdateTime": 14732329129.inides ":" Sys "," UpdateTime ": 1473232929 VALIDID": "SYS", "UpdateTime": 1473232929 {1000 {1000 {14732), "Web.permission.user-mgmt.modify", "createid": "sys", "createTime": 1473232997000, "functionName": "memodifikasi pengguna", "tersembunyi": 0, "id": "leafnode": "ParentId": 2, "Privilegelist": "", "1," 1, "Parentid": 2, "Privilegelist": "LEAFNODE", "Parentid": "Privilegelist": "Privilegelist": "Privilegelist": "Privilegelist": " "sys","updateTime": 1473232997000,"validity": 1}],"subSystemId": 1,"updateId": "sys","updateTime": 1473232900000,"validity": 1}],"subSystemId": 1,"updateId": "sys","updateTime": 1473232877000, "validitas": 1}] Di atas adalah kode contoh untuk implementasi data struktur pohon bacaan mybatis yang diperkenalkan kepada Anda. Saya harap ini akan membantu Anda. Jika Anda memiliki pertanyaan, silakan tinggalkan saya pesan dan editor akan membalas Anda tepat waktu. Terima kasih banyak atas dukungan Anda ke situs web Wulin.com!