电力项目十五--数据字典

数据字典的作用:

1.贯穿系统的所有数据项,开发过程中,动态的维护系统数据项:

2.保证数据的录入安全,业务表使用数据字典的时候,存放的是数据项的编号,而不是数据项的值。

3.方便系统的统计。

1.数据库的设计:

#数据字典

create table Elec_SystemDDL(

  seqID INT NOT NULL primary key, #主键ID(自增长)

  keyword VARCHAR(20)  NULL, #数据类型

  ddlCode INT NULL, #数据项的code

  ddlName VARCHAR(50) NULL #数据项的value

);

创建Elec_SystemDDL.java文件

package com.itheima.elec.bean;

import java.io.Serializable;

@SuppressWarnings("serial")
public class ElecSytemDDL implements Serializable{

    private Integer seqID;
    private String keyword;
    private Integer ddlCode;
    private String ddlName;

    public Integer getSeqID() {
        return seqID;
    }
    public void setSeqID(Integer seqID) {
        this.seqID = seqID;
    }
    public String getKeyword() {
        return keyword;
    }
    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }
    public Integer getDdlCode() {
        return ddlCode;
    }
    public void setDdlCode(Integer ddlCode) {
        this.ddlCode = ddlCode;
    }
    public String getDdlName() {
        return ddlName;
    }
    public void setDdlName(String ddlName) {
        this.ddlName = ddlName;
    }

}

创建对应的hbm.xml文件 ElecSystemDDL.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <hibernate-mapping>
        <class name="com.itheima.elec.bean.ElecSystemDDL" table="Elec_SystemDDL">
            <id name="seqID" type="integer" column="seqID">
                <generator class="increment"></generator>
            </id>
            <property  name="keyword" type="string" column="keyword"></property>
            <property name="ddlCode" type="integer" column="ddlCode"></property>
            <property name="ddlName" type="string" column="ddlName"></property>

        </class>

    </hibernate-mapping>
    

然后在hibernate.cfg.xml文件中添加文件

    <mapping resource="com/itheima/elec/bean/ElecSystemDDL.hbm.xml"/>

IElecSystemDDL.java

package com.itheima.elec.dao;

import com.itheima.elec.bean.ElecSystemDDL;

public interface IElecSystemDDLDao extends ICommonDao<ElecSystemDDL> {
    public static final String SERVICE_NAME = "com.itheima.elec.dao.impl.ElecSystemDDLDaoImpl";

}

ElecSystemDDLDaoImpl.java

package com.itheima.elec.dao.impl;
import org.springframework.stereotype.Repository;

import com.itheima.elec.bean.ElecSystemDDL;
import com.itheima.elec.dao.IElecSystemDDLDao;

/**
 * @Repository
 * 相当于在spring中定义:<bean id="elecTextDaoImpl" class="com. **.ElecTextDaoImpl">
 */
@Repository(IElecSystemDDLDao.SERVICE_NAME)
public class ElecSystemDDLDaoImpl extends CommonDaoImpl<ElecSystemDDL> implements IElecSystemDDLDao{

}

IElecSystemDDLService.java

package com.itheima.elec.service;

import java.util.List;

import com.itheima.elec.bean.ElecSystemDDL;

public interface IElecSystemDDLService {

    public static final String SERVICE_NAME="com.itheima.elec.service.impl.ElecSystemDDLServiceImpl";
}

ElecSystemDDLServiceImpl.java

package com.itheima.elec.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.itheima.elec.dao.IElecSystemDDLDao;
import com.itheima.elec.service.IElecSystemDDLService;
//事务控制:spring的声明事务处理,在service层添加@Transactional
@Service(IElecSystemDDLService.SERVICE_NAME)
@Transactional(readOnly=true)
public class ElecSystemDDLServiceImpl implements IElecSystemDDLService {

    /*数据字典Dao*/
    @Resource(name=IElecSystemDDLDao.SERVICE_NAME)
    IElecSystemDDLDao elecSystemDDLDao;

}

ElecSystemDDLAction.java

package com.itheima.elec.web.action;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.itheima.elec.bean.ElecSystemDDL;
import com.itheima.elec.service.IElecSystemDDLService;
import com.itheima.elec.service.IElecTextService;

@SuppressWarnings("serial")
@Controller("elecSystemDDLAction")
@Scope(value="prototype")
public class ElecSystemDDLAction extends BaseAction<ElecSystemDDL>{

    ElecSystemDDL elecSystemDDL = this.getModel();

    //注入Service
    @Resource(name=IElecSystemDDLService.SERVICE_NAME)
    IElecSystemDDLService elecSystemDDLService;

/**
 * 数据字典的首页显示
 * 跳转到:/system/dictionIndex.jsp页面
 */
public String home(){
    return "home";
}

}

struts.xml

<action name="elecSystemDDLAction_*" class="elecSystemDDLAction" method="{1}">
                <result name="home">/WEB-INF/page/system/dictionaryIndex.jsp</result>
                <result name="save" type="redirectAction">
                    <param name="actionName">elecCommonMsgAction_home.do</param>
                </result>
                <result name="actingView">/WEB-INF/page/system/actingView.jsp</result>
        </action>

写完了dao,service,action,然后配置struts.xml

然后修改script/menuDate.js中的配置

{
            mid:‘aq‘,
            pid:‘am‘,
            name:‘数据字典维护‘,
            icon:‘../images/MenuIcon/shujuzidianguanli.gif‘,
            target:‘mainFrame‘,
            /*url:‘../system/dictionaryIndex.jsp‘,*/
            url:‘../system/elecSystemDDLAction_home.do‘,
            isParent:false
        }

启动,页面显示:

时间: 2024-08-25 17:02:55

电力项目十五--数据字典的相关文章

电力项目十八--DOM对象的ajax

Ajax操作的核心对象:xmlreq = new XMLHttpRequest(); 第一步:在dictionaryIndex.jsp中添加: <script type="text/javascript" src="${pageContext.request.contextPath }/script/pub.js"></script> 第二步:调用js的代码:实现: Pub.submitActionWithForm: * 参数一:表单Form

电力项目十二--运行监控中添加进度条

应用场景: 1.文件上传.下载(IO流); 2.数据的导入导出: 3.大批量数据的增删改查: 4.远程数据的访问. 添加函数loading(); <%@ page language="java" pageEncoding="UTF-8"%> <%@taglib uri="/struts-tags" prefix="s" %> <!-- 添加标签,然后做栈顶获取数据 --> <html&

十五周 项目1 工资数据的输入

/* 输入员工工资1000-10000之间,并按从大到小输出*/ #include <iostream> using namespace std; int main( ) { double salarys[500]; int n=0; double t; while(cin>>salarys[n]) { n++; //从cin流读取数据 } //将n名职工的工资排序后输出 for(int i=0; i<n; i++) for(int j=0; j<n-1; j++) {

[项目构建 十五]babasport 项目总结及源码分享.

终于把这个项目自己手动的敲了一遍且总结了其中的知识点, 现在来做一个整体性的总结. 总目录: [项目构建 一]babasport 项目环境搭建. [项目构建 二]babasport SSM 三大框架整合 [项目构建 三]babasport Dubbo的使用及浅析. [项目构建 四]babasport 分页的使用及解析. [项目构建 五]babasport ajax图片上传及FastDFS入门案例. [项目构建 六]babasport Mybatis逆向工程构建项目实例. [项目构建 六]baba

【.NET Core项目实战-统一认证平台】第十五章 网关篇-使用二级缓存提升性能

原文:[.NET Core项目实战-统一认证平台]第十五章 网关篇-使用二级缓存提升性能 [.NET Core项目实战-统一认证平台]开篇及目录索引 一.背景 首先说声抱歉,可能是因为假期综合症(其实就是因为懒哈)的原因,已经很长时间没更新博客了,现在也调整的差不多了,准备还是以每周1-2篇的进度来更新博客,并完成本项目所有功能. 言归正传,本重构项目是在我根据实际需求重构,由于还未完全写完,所以也没进行压测,在2月份时,张善友老师给我留言说经过压测发现我重构的Ocelot网关功能性能较差,其中

手把手教你做关键词匹配项目(搜索引擎)---- 第十五天

第十五天 小帅帅很乐意做简单的事情,复杂的事情他搞不懂怎么做,但是听了于老大的讲解,他觉得好多事情怎么这么简单. 他随手把一些代码写了出来,然后去找于老大,去请教以后怎么做...... <?php class OldAgeCharListHandle extends CharListHandle{ public function exec(){ $this->charlist->addCore("老年"); $this->charlist->addBlac

学习进度条(十五周)

本周主要是对于团队开发项目的修改完善.   第十五周 所花时间(包括上课) 上课2小时,课后10小时 代码量(行) 200+ 博客量 2 了解到的知识点 服务器连接GET方法

第十五篇 Integration Services:SSIS参数

本篇文章是Integration Services系列的第十五篇,详细内容请参考原文. 简介在前一篇,我们使用SSDT-BI将第一个SSIS项目My_First_SSIS_Project升级/转换到SSIS 2012.在这一篇,我们将探讨SSIS变量的姊妹:SSIS参数.我们将展示参数配置,通过包参数管理动态属性值,以及在SSIS包执行期间参数是如何配置和使用的.首先在SSDT-BI打开转换过的My_First_SSIS_Project,如图15.1所示:图15.1My_First_SSIS_P

【大话QT之十五】ctkPluginFrameWork插件系统Windows下编译

使用ctkPluginFramework作为插件系统框架的确有着众多开发上的优势.最近收到一些站内信,大家都想使用ctkPluginFramework但是不知道如何编译,这篇教程就来讲一讲ctkPluginFramework插件系统在Windows下的编译过程. 准备条件: 1. 安装Git,我们通过它来下载CTK的源码. 2. 安装CMake,我们用它来生成vs下的sln解决方案文件. 相关站点: 1. CTK的官网:http://www.commontk.org/index.php/Main