Data dictionary and its use

1 data dictionary

1.1 What is a data dictionary

Configure the following configuration items of the same type into the data dictionary table of the system, which is convenient for system maintenance. The super administrator uniformly performs data dictionary maintenance in the background. If the user needs to add and change configuration items, only need to modify the data dictionary table. Just record, no need to modify the code.

 

1.2 Data Dictionary Requirements

Configuration items of the same type:

Create a record in the system data dictionary type   data dictionary type table record data type (such as user status)

Create a table to record the data dictionary details : (for example, the user status is normal suspension) 

Data Dictionary Schedule

 

The flexible configuration items above are called " common configuration items "

Fix the configuration items above ( each configuration has a code at the top ): " business code "

 

1.3 Data dictionary table structure

Dictionary type table DICTTYPE:

record data dictionary type

 

Dictionary list DICTINFO:

record data dictionary details

   

 

The dictionary indicates how to store common configuration items and business codes in the table.

 

Common configuration item storage:

Common configuration item names are stored in the info field of the DICTINFO table

The type id corresponding to the common configuration item is stored in the DICTINFO table TYPECODE

Query common configuration top:

 

Business code storage:

The name corresponding to the business code is stored in the info field of the DICTINFO table

The type id corresponding to the business code is stored in the DICTINFO table TYPECODE

The business code is stored in the DICTINFO table DICTCODE ( is the difference from the common configuration top )


Business code query:

 

 

1.4 Data dictionary usage

 

1. Display the business code or common configuration in the drop-down box on the page

For example, on the system user query page, the query condition is the user type, and the user type cannot be hard-coded on the jsp. All configuration items of the user type need to be retrieved in the action method and dynamically traversed on the jsp page.

 

2. When querying the business table , the name corresponding to the business code needs to be correlated and queried

When querying the business table, according to the business code, the name corresponding to the code is correlated and queried.

Specify business code and type id when associating query dictionary details


3. When querying the business table, you need to associate and query the name corresponding to the common configuration item

Specify the primary key of the detailed table when associating query dictionary details

 


1.5 Summary

Common configuration items: Simple classification of business data. These classifications are more flexible according to user requirements. These configuration items are used as common configuration items to configure the data dictionary table.

 

Business code: a fixed code that is necessary for the system to run and is defined during system design. These codes may need to be hard-coded in the program code.

1.6 Application of data dictionary in the system

 

1.6.1 User type drop-down box on user query page

 

User type: belongs to business code

Get all the details under the user type:

Query from the data dictionary list, query according to typecode


Action:

Modify the user query page method, call systemConfigService to query user type information, and pass the user type list information to the page.

   // User query page

   @RequestMapping("/queryuser")

   public String queryuser(Modelmodel)throwsException {

      / / Take the data required by the page out of the incoming page

      List<Dictinfo>groupList =systemConfigService.findDictinfoByType("s01");

     

      model.addAttribute("groupList",groupList);

      return"/base/user/queryuser";

   }

 

页面:

将用户类型下拉框值,改成遍历groupList列表。

<TDclass="left">用户类型:</TD>

                <td><selectname="sysuserCustom.groupid">

                      <option value="">请选择</option>

                      <!-- <option value="1">卫生局</option>

                      <optionvalue="2">卫生院</option>

                      <optionvalue="3">卫生室</option>

                      <optionvalue="4">供货商</option>

                      <optionvalue="0">系统管理员</option> -->

                      <c:forEach items='${groupList}'var="dictinfo">

                      <option value="${dictinfo.dictcode}">${dictinfo.info}</option>

                      </c:forEach>                  

                </select>

                </TD>

1.6.2          用户查询列表中用户类型列

 

Dao:

修改用户查询列表mapper,添加一列需要关联用户类型的代码查询代码对应的名称。

 

页面:

修改datagrid的列定义,

{

      field : 'groupname',//对应json中的key

      title : '用户类型',

      width : 120,

      /* formatter : function(value, row,index) {//通过此方法格式化显示内容,value表示从json中取出该单元格的值,row表示这一行的数据,是一个对象,index:行的序号

         if(value =='1'){

            return "卫生局";

         }else if(value =='2'){

            return "卫生院";

         }else if(value =='3'){

            return "卫生室";

         }else if(value =='4'){

            return "供货商";

         }else if(value =='0'){

            return "系统管理员";

         }

      } */

   }

普通配置项下拉框

查询出普通配置项列表,

页面中下拉框遍历list(option的value是${dictinfo.id})

 

<c:forEachitems="${list}"var="dictinfo">

                      <option value="${dictinfo.id }">${dictinfo.info}</option>

</c:forEach>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326368394&siteId=291194637