CREATE TABLE' sys_dict ' (' ID ')INT(Ten) not NULLAuto_increment COMMENT'primary Key ID', ' Dict_type 'VARCHAR( -) not NULL DEFAULT "'COMMENT'Dictionary type', ' Dict_key 'INT(Ten) not NULL DEFAULT '0'COMMENT'Dictionary key', ' Dict_value 'VARCHAR( -) not NULL DEFAULT "'COMMENT'Dictionary value', ' sort 'INT(Ten) not NULL DEFAULT '0'COMMENT'Dictionary sort Values', ' Add_uid 'INT(Ten) not NULL DEFAULT '0'COMMENT'Add People', ' Update_uid 'INT(Ten) not NULL DEFAULT '0'COMMENT'Update Person', ' Add_time 'TIMESTAMP not NULL DEFAULT Current_timestampCOMMENT'creation Time', ' Update_time 'TIMESTAMP not NULL DEFAULT Current_timestampCOMMENT'Update Time', ' Del_flag 'TINYINT(4) not NULL DEFAULT '0'COMMENT'Delete Tag', ' remark 'VARCHAR( -) not NULL DEFAULT "'COMMENT'Notes', PRIMARY KEY(' id ')) ENGINE=INNODB auto_increment=1 DEFAULTCHARSET=UTF8 COMMENT='Data dictionary table';
Data Dictionary Tool class
Public classDictutils {Private StaticSysdictmapper sysdictmapper = Springcontextutils.getbeanbyclass (sysdictmapper.class); Public Staticsysdictpo getdict (String dicttype, Integer dictkey) {sysdictpo Sysdictpo=NewSysdictpo (); Sysdictpo.setdicttype (Dicttype); Sysdictpo.setdictkey (Dictkey); returnSysdictmapper.selectbytypeandkey (SYSDICTPO); } Public Staticstring Getdictvalue (String dicttype, Integer dictkey) {sysdictpo query=getdict (Dicttype, Dictkey); if(Query! =NULL) { returnQuery.getdictvalue (); } return NULL; }}
One magical thing about a data dictionary is to make a switch
String value = dictutils.getdictvalue ("switch", 0switch = boolean.valueof (value); if (switch) { //... } Else { //.....}
and Dict_value we can modify through the interface, only need to modify the value of the database without the need to change the code
How to create a data dictionary table