一个简单的web项目,网站文章管理(一)

mac2025-05-21  46

本人是自学Java的小菜鸟,前一段时间接了一个简单的项目,拿出来跟大家交流一下,也是我自己做个笔记回顾一下这次碰到的一些问题。自知还有很多问题没有发现,请大家多多指正,望大神轻喷。

主要的需求是:

一、实现对文章进行各种操作

所有文章分为三个状态:未审核(写手写作完成,提交管理员审核)、已审核未发布(管理员通过审核等待发布)、已发布(管理员确认文章无误,发布文章至网站前端展现);当文章为未审核状态时,管理员账号具有:审核、编辑、删除权限;写手账号只有:编辑和删除权限;当文章为已审核未发布状态时,只有管理员账号能查看,权限为:发布、编辑和删除;当文章为已发布状态时,只有管理员账号能查看,权限为:下架、删除;

二、登录用户权限分离

除现有管理员之外,增加文章写手账号,且每个写手登录自己账后后只能看到自己所写未通过审核的文章;管理员可以看到所有状态的文章(未审核、已审核未发布、已发布),同时要能统计已发布文章中各个写手的文章数量;

由于本项目为现有网站的附属项目,说明一下目前网站项目的情况:

一、 网站为php项目,本人完全不懂,所以部分功能只能通过一些笨办法解决,有一个问题到目前还未解决;

二、数据库的问题

现有储存文章数据的表为:article(不是真正表名),该表储存的文章会被直接展现至前端,所以为了实现审核、发布等功能,只能新增2张表article_1(已审核未发布)和article_2(未审核);现有user表中只有id、name、pwd字段,所以添加一个mark字段用来管理账户权限;在article表中增加字段"zuozhe"用于管理员账号查询和统计每个写手的文章数量,同时article_1和article_2表中也有此字段;

本项目中用到的技术有:

基本框架:springMVC+spring+mybatis(本次使用mybatis逆向工程生产bean、dao、mapper包下的类) 数据库:mysql5.6 前端框架:H-ui.admin3.0 服务器:tomcat8.0

下面是本项目的所有目录结构

然后是pom文件

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.xxxx</groupId> <artifactId>article</artifactId> <version>2.0-SNAPSHOT</version> <packaging>war</packaging> <name>article Maven Webapp</name> <!-- FIXME change it to the project's website --> <url>http://www.example.com</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.target>1.7</maven.compiler.target> </properties> <!-- 引入项目依赖的Jar包 --> <dependencies> <!-- springMVC和spring --> <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>4.3.7.RELEASE</version> </dependency> <!-- spring JDBC --> <!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>4.3.7.RELEASE</version> </dependency> <!-- spring-test --> <!-- https://mvnrepository.com/artifact/org.springframework/spring-test --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>4.3.7.RELEASE</version> <!-- <scope>test</scope> --> </dependency> <!-- spring aop --> <!-- https://mvnrepository.com/artifact/org.springframework/spring-aspects --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aspects</artifactId> <version>4.3.7.RELEASE</version> </dependency> <!-- mybatis --> <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.4.6</version> </dependency> <!-- mybatis整合spring适配包 --> <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.3.1</version> </dependency> <!-- mybatis逆向工程 --> <!-- https://mvnrepository.com/artifact/org.mybatis.generator/mybatis-generator-core --> <dependency> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-core</artifactId> <version>1.3.5</version> </dependency> <!-- 数据库连接池和驱动 --> <!-- https://mvnrepository.com/artifact/com.mchange/c3p0 --> <dependency> <groupId>com.mchange</groupId> <artifactId>c3p0</artifactId> <version>0.9.5.2</version> </dependency> <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.41</version> </dependency> <!-- jstl/servlet-api/junit --> <!-- https://mvnrepository.com/artifact/jstl/jstl --> <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.0.1</version> <scope>provided</scope> </dependency> <!-- https://mvnrepository.com/artifact/junit/junit --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <!-- <scope>test</scope> --> </dependency> <!-- 引入psgehelper分页插件 --> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> <version>5.0.0</version> </dependency> <!-- 返回数据转为json类型的支持 --> <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.8.8</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>5.0.7.RELEASE</version> </dependency> <dependency> <groupId>org.freemarker</groupId> <artifactId>freemarker</artifactId> <version>2.3.28</version> </dependency> <!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload --> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.3.1</version> </dependency> </dependencies> <build> <finalName>article</finalName> <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> <plugins> <plugin> <artifactId>maven-clean-plugin</artifactId> <version>3.1.0</version> </plugin> <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging --> <plugin> <artifactId>maven-resources-plugin</artifactId> <version>3.0.2</version> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> </plugin> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version> </plugin> <plugin> <artifactId>maven-war-plugin</artifactId> <version>3.2.2</version> </plugin> <plugin> <artifactId>maven-install-plugin</artifactId> <version>2.5.2</version> </plugin> <plugin> <artifactId>maven-deploy-plugin</artifactId> <version>2.8.2</version> </plugin> </plugins> </pluginManagement> </build> </project>

这次先写这么多,后续我慢慢更新,对了下面是最后的效果(涉及到版权的一些东西我做了马赛克处理请谅解)

登录页面:

管理员页面:

写手页面

最新回复(0)