How to create a data dictionary table

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.