JavaWebプロジェクトの開発事例の粋14(ニュース発表システム)の10を学ぶ
11926 ワード
comを新規作成します.ppcms.voパッケージの後にNewsというvoクラスを再構築し、これはデータベースに基づいて構築されます.ここにはNewsクラスのみがリストされています.他の類似項目もあります.NewsClass、NewsKind、Newsuserなど.
次にデータベース構造を添付するsqlはmysqldump--opt-d ppcms-uroot-p>xxxである.sqlがエクスポートしました.
package com.ppcms.vo;
public class News {
public int newsId; // id
public int myOther; //
public int classId; // id
public int kindId; // id
public String headTitle; //
public String content; //
public String connect; //
public String author; //
public String editor; //
public String newsFrom; //
public String newsTime; //
public int hits; //
public int top; //
public int state; //
public int tag; //
public News(){
headTitle = null;
content = null;
connect = null;
author = null;
editor = null;
newsFrom = null;
newsTime = null;
}
public int getNewsId() {
return newsId;
}
public void setNewsId(int newsId) {
this.newsId = newsId;
}
public int getMyOther() {
return myOther;
}
public void setMyOther(int myOther) {
this.myOther = myOther;
}
public int getClassId() {
return classId;
}
public void setClassId(int classId) {
this.classId = classId;
}
public int getKindId() {
return kindId;
}
public void setKindId(int kindId) {
this.kindId = kindId;
}
public String getHeadTitle() {
return headTitle;
}
public void setHeadTitle(String headTitle) {
this.headTitle = headTitle;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getConnect() {
return connect;
}
public void setConnect(String connect) {
this.connect = connect;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getEditor() {
return editor;
}
public void setEditor(String editor) {
this.editor = editor;
}
public String getNewsFrom() {
return newsFrom;
}
public void setNewsFrom(String newsFrom) {
this.newsFrom = newsFrom;
}
public String getNewsTime() {
return newsTime;
}
public void setNewsTime(String newsTime) {
this.newsTime = newsTime;
}
public int getHits() {
return hits;
}
public void setHits(int hits) {
this.hits = hits;
}
public int getTop() {
return top;
}
public void setTop(int top) {
this.top = top;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
public int getTag() {
return tag;
}
public void setTag(int tag) {
this.tag = tag;
}
}
次にデータベース構造を添付するsqlはmysqldump--opt-d ppcms-uroot-p>xxxである.sqlがエクスポートしました.
-- MySQL dump 10.13 Distrib 5.5.28, for Win32 (x86)
--
-- Host: localhost Database: ttcmsv1
-- ------------------------------------------------------
-- Server version 5.5.28
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `news`
--
DROP TABLE IF EXISTS `news`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `news` (
`newsId` int(11) NOT NULL AUTO_INCREMENT,
`classId` int(11) NOT NULL DEFAULT '0',
`kindId` int(11) NOT NULL DEFAULT '0',
`myOther` int(11) NOT NULL DEFAULT '0',
`headTitle` varchar(255) NOT NULL DEFAULT '',
`content` text NOT NULL,
`connect` varchar(255) DEFAULT NULL,
`author` varchar(20) NOT NULL DEFAULT '',
`editor` varchar(20) DEFAULT NULL,
`newsFrom` varchar(40) DEFAULT NULL,
`top` int(11) DEFAULT NULL,
`newsTime` varchar(20) DEFAULT NULL,
`hits` int(11) DEFAULT '0',
`state` int(11) DEFAULT '0',
`tag` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`newsId`)
) ENGINE=MyISAM AUTO_INCREMENT=33 DEFAULT CHARSET=gb2312;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `newsadmin`
--
DROP TABLE IF EXISTS `newsadmin`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `newsadmin` (
`userName` varchar(20) NOT NULL DEFAULT '',
`passWd` varchar(20) NOT NULL DEFAULT '',
`purview` int(11) NOT NULL DEFAULT '0',
`lastLogin` datetime DEFAULT NULL,
`lastLoginIp` varchar(20) DEFAULT NULL,
PRIMARY KEY (`userName`)
) ENGINE=MyISAM DEFAULT CHARSET=gb2312;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `newsclass`
--
DROP TABLE IF EXISTS `newsclass`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `newsclass` (
`classId` int(11) NOT NULL DEFAULT '0',
`content` varchar(20) NOT NULL DEFAULT '',
PRIMARY KEY (`classId`)
) ENGINE=MyISAM DEFAULT CHARSET=gb2312;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `newscommon`
--
DROP TABLE IF EXISTS `newscommon`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `newscommon` (
`counter` int(11) NOT NULL DEFAULT '0',
`ip` varchar(20) NOT NULL DEFAULT ''
) ENGINE=MyISAM DEFAULT CHARSET=gb2312;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `newskind`
--
DROP TABLE IF EXISTS `newskind`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `newskind` (
`kindId` int(11) NOT NULL AUTO_INCREMENT,
`content` varchar(255) NOT NULL DEFAULT '',
`classId` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`kindId`)
) ENGINE=MyISAM AUTO_INCREMENT=20 DEFAULT CHARSET=gb2312;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `newspopedom`
--
DROP TABLE IF EXISTS `newspopedom`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `newspopedom` (
`gradeId` int(11) NOT NULL DEFAULT '0',
`grade` varchar(20) DEFAULT NULL,
PRIMARY KEY (`gradeId`)
) ENGINE=MyISAM DEFAULT CHARSET=gb2312;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `newsreply`
--
DROP TABLE IF EXISTS `newsreply`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `newsreply` (
`replyId` int(11) NOT NULL AUTO_INCREMENT,
`newsId` int(11) NOT NULL DEFAULT '0',
`user` varchar(20) DEFAULT NULL,
`content` varchar(100) DEFAULT NULL,
`replyTime` varchar(20) DEFAULT NULL,
PRIMARY KEY (`replyId`)
) ENGINE=MyISAM DEFAULT CHARSET=gb2312;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `newsusr`
--
DROP TABLE IF EXISTS `newsusr`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `newsusr` (
`userName` varchar(20) NOT NULL DEFAULT '',
`passWd` varchar(20) NOT NULL DEFAULT '',
`sex` int(11) DEFAULT NULL,
`question` varchar(255) DEFAULT NULL,
`answer` varchar(255) DEFAULT NULL,
`emailAddr` varchar(50) DEFAULT NULL,
`qq` varchar(10) DEFAULT NULL,
`http` varchar(30) DEFAULT NULL,
`purview` int(11) DEFAULT '1',
`regTime` varchar(20) DEFAULT NULL,
PRIMARY KEY (`userName`)
) ENGINE=MyISAM DEFAULT CHARSET=gb2312;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `noteadmin`
--
DROP TABLE IF EXISTS `noteadmin`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `noteadmin` (
`adminName` char(20) NOT NULL DEFAULT '',
`adminPasswd` char(20) NOT NULL DEFAULT '',
PRIMARY KEY (`adminName`)
) ENGINE=MyISAM DEFAULT CHARSET=gb2312;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `noteguest`
--
DROP TABLE IF EXISTS `noteguest`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `noteguest` (
`noteId` int(11) NOT NULL AUTO_INCREMENT,
`userName` varchar(20) NOT NULL DEFAULT '',
`sex` int(11) NOT NULL DEFAULT '0',
`email` varchar(50) DEFAULT NULL,
`qq` varchar(9) DEFAULT NULL,
`url` varchar(50) DEFAULT NULL,
`headTitle` text NOT NULL,
`content` text NOT NULL,
`image` text,
`noteTime` varchar(20) DEFAULT NULL,
PRIMARY KEY (`noteId`)
) ENGINE=MyISAM DEFAULT CHARSET=gb2312;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `notereply`
--
DROP TABLE IF EXISTS `notereply`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `notereply` (
`replyId` int(11) NOT NULL AUTO_INCREMENT,
`noteId` int(11) NOT NULL DEFAULT '0',
`content` text,
`replyTime` varchar(20) DEFAULT NULL,
PRIMARY KEY (`replyId`)
) ENGINE=MyISAM DEFAULT CHARSET=gb2312;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2013-06-08 17:23:24