中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

電商網(wǎng)站多少錢重慶seo

電商網(wǎng)站多少錢,重慶seo,seo外鏈友情鏈接,重新做系統(tǒng)后怎么沒有wordpress為了實現(xiàn)一個基于Spring和Spring MVC的漢服文化宣傳網(wǎng)站,我們需要創(chuàng)建一個簡單的Web應用程序來展示漢服文化和相關(guān)信息。這個系統(tǒng)將包括以下幾個部分: 數(shù)據(jù)庫表設計:定義文章、用戶和評論的相關(guān)表。實體類:表示數(shù)據(jù)庫中的數(shù)據(jù)。DAO層接口及MyBatis映射文件:用于與數(shù)據(jù)庫交…

![在這里插入圖片描述](https://i-blog.csdnimg.cn/direct/0022679f5cad49eaa699a854e1ff9044.png

為了實現(xiàn)一個基于Spring和Spring MVC的漢服文化宣傳網(wǎng)站,我們需要創(chuàng)建一個簡單的Web應用程序來展示漢服文化和相關(guān)信息。這個系統(tǒng)將包括以下幾個部分:

  1. 數(shù)據(jù)庫表設計:定義文章、用戶和評論的相關(guān)表。
  2. 實體類:表示數(shù)據(jù)庫中的數(shù)據(jù)。
  3. DAO層接口及MyBatis映射文件:用于與數(shù)據(jù)庫交互。
  4. Service層接口及其實現(xiàn)類:業(yè)務邏輯處理。
  5. Controller層:處理HTTP請求。
  6. 前端頁面:展示信息并允許用戶操作。

1. 數(shù)據(jù)庫表設計

假設我們有一個名為hanfu_culture的數(shù)據(jù)庫,其中包含以下表:

  • articles
  • users
  • comments
CREATE TABLE articles (id INT AUTO_INCREMENT PRIMARY KEY,title VARCHAR(255) NOT NULL,content TEXT NOT NULL,author_id INT NOT NULL,created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,FOREIGN KEY (author_id) REFERENCES users(id)
);CREATE TABLE users (id INT AUTO_INCREMENT PRIMARY KEY,username VARCHAR(100) NOT NULL UNIQUE,email VARCHAR(100) NOT NULL UNIQUE,password VARCHAR(255) NOT NULL
);CREATE TABLE comments (id INT AUTO_INCREMENT PRIMARY KEY,article_id INT NOT NULL,user_id INT NOT NULL,comment_text TEXT NOT NULL,created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,FOREIGN KEY (article_id) REFERENCES articles(id),FOREIGN KEY (user_id) REFERENCES users(id)
);

2. 實體類

創(chuàng)建Java實體類來表示這些表的數(shù)據(jù)。

Article.java

import java.sql.Timestamp;public class Article {private Integer id;private String title;private String content;private Integer authorId;private Timestamp createdAt;// Getters and Setters
}

User.java

public class User {private Integer id;private String username;private String email;private String password;// Getters and Setters
}

Comment.java

import java.sql.Timestamp;public class Comment {private Integer id;private Integer articleId;private Integer userId;private String commentText;private Timestamp createdAt;// Getters and Setters
}

3. DAO層接口及MyBatis映射文件

定義DAO層接口以及對應的XML映射文件。

ArticleDao.java

import java.util.List;public interface ArticleDao {List<Article> getAllArticles();Article getArticleById(int id);void addArticle(Article article);
}

ArticleMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.dao.ArticleDao"><select id="getAllArticles" resultType="com.example.model.Article">SELECT * FROM articles ORDER BY created_at DESC</select><select id="getArticleById" parameterType="int" resultType="com.example.model.Article">SELECT * FROM articles WHERE id = #{id}</select><insert id="addArticle" parameterType="com.example.model.Article">INSERT INTO articles (title, content, author_id, created_at)VALUES (#{title}, #{content}, #{authorId}, NOW())</insert>
</mapper>

UserDao.java

import java.util.List;public interface UserDao {List<User> getAllUsers();User getUserById(int id);User getUserByUsername(String username);void addUser(User user);
}

UserMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.dao.UserDao"><select id="getAllUsers" resultType="com.example.model.User">SELECT * FROM users</select><select id="getUserById" parameterType="int" resultType="com.example.model.User">SELECT * FROM users WHERE id = #{id}</select><select id="getUserByUsername" parameterType="String" resultType="com.example.model.User">SELECT * FROM users WHERE username = #{username}</select><insert id="addUser" parameterType="com.example.model.User">INSERT INTO users (username, email, password)VALUES (#{username}, #{email}, #{password})</insert>
</mapper>

CommentDao.java

import java.util.List;public interface CommentDao {List<Comment> getCommentsByArticleId(int articleId);void addComment(Comment comment);
}

CommentMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.dao.CommentDao"><select id="getCommentsByArticleId" parameterType="int" resultType="com.example.model.Comment">SELECT * FROM comments WHERE article_id = #{articleId} ORDER BY created_at ASC</select><insert id="addComment" parameterType="com.example.model.Comment">INSERT INTO comments (article_id, user_id, comment_text, created_at)VALUES (#{articleId}, #{userId}, #{commentText}, NOW())</insert>
</mapper>

4. Service層接口及其實現(xiàn)類

定義Service層接口及其實現(xiàn)類。

ArticleService.java

import java.util.List;public interface ArticleService {List<Article> getAllArticles();Article getArticleById(int id);void addArticle(Article article);
}

ArticleServiceImpl.java

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.List;@Service
public class ArticleServiceImpl implements ArticleService {@Autowiredprivate ArticleDao articleDao;@Overridepublic List<Article> getAllArticles() {return articleDao.getAllArticles();}@Overridepublic Article getArticleById(int id) {return articleDao.getArticleById(id);}@Overridepublic void addArticle(Article article) {articleDao.addArticle(article);}
}

UserService.java

import java.util.List;public interface UserService {List<User> getAllUsers();User getUse
http://www.risenshineclean.com/news/1833.html

相關(guān)文章:

  • 青島外貿(mào)建設網(wǎng)站制作搜索排名提升
  • 吉安市城鄉(xiāng)規(guī)劃建設局網(wǎng)站網(wǎng)絡營銷與策劃
  • 即將上市的手機優(yōu)優(yōu)群排名優(yōu)化軟件
  • 萍鄉(xiāng)做網(wǎng)站的公司廣州新聞熱點事件
  • 多媒體展廳公司seo學習論壇
  • j建設銀行信用卡網(wǎng)站開發(fā)一個平臺需要多少錢
  • 做蔬果批發(fā)有專門的網(wǎng)站么seo是什么意思怎么解決
  • 宜昌市建設工程質(zhì)量監(jiān)督站網(wǎng)站百度提交網(wǎng)址
  • 做招聘的網(wǎng)站seo技術(shù)快速網(wǎng)站排名
  • 視頻網(wǎng)站做視頻節(jié)目賺錢嗎搜狗搜圖
  • 網(wǎng)站簡單設計電子技術(shù)培訓機構(gòu)
  • 天津?qū)I(yè)網(wǎng)站制作設計營銷廣告網(wǎng)站
  • 小型網(wǎng)站建設源碼石家莊新聞頭條新聞最新今天
  • justhost wordpress企業(yè)網(wǎng)站優(yōu)化公司
  • 山東網(wǎng)站建設公司優(yōu)化網(wǎng)站關(guān)鍵詞優(yōu)化
  • 購物網(wǎng)站開發(fā)的描述seo點擊優(yōu)化
  • 網(wǎng)站自定義鏈接怎么做的seo網(wǎng)站推廣主要目的不包括
  • 免費做婚禮邀請函的網(wǎng)站教育培訓機構(gòu)網(wǎng)站
  • 網(wǎng)站是先備案 還是先做網(wǎng)站網(wǎng)站策劃書模板范文
  • 外貿(mào)平臺有哪些分別對應哪個市場隨州seo
  • 網(wǎng)站建設 外包南寧百度快速排名優(yōu)化
  • 南通市網(wǎng)站建設我的完廣州網(wǎng)絡營銷推廣
  • 做銀行設計有好的網(wǎng)站參考嗎網(wǎng)站搭建需要多少錢
  • 溫州多語言網(wǎng)站建設網(wǎng)站發(fā)帖推廣平臺
  • 網(wǎng)頁瀏覽設置在哪里打開網(wǎng)頁優(yōu)化
  • 做網(wǎng)站比較好的環(huán)球網(wǎng)疫情最新
  • 2015做哪個網(wǎng)站能致富沈陽專業(yè)seo關(guān)鍵詞優(yōu)化
  • 建設公司企業(yè)網(wǎng)站個人網(wǎng)頁怎么制作
  • WordPress網(wǎng)頁加載時間seo網(wǎng)站優(yōu)化快速排名軟件
  • 備案名 網(wǎng)站名互聯(lián)網(wǎng)營銷師教材