当前位置:网站首页>68: Chapter 6: Develop article services: 1: Content sorting; article table introduction; creating [article] article services;
68: Chapter 6: Develop article services: 1: Content sorting; article table introduction; creating [article] article services;
2022-08-10 22:40:00 【small dry forest】
说明:
(1)本篇博客内容:Development articles:1:内容梳理;article表介绍;创建【article】文章服务;
目录
四:【article】文章服务,创建测试用的HelloController,看看项目是否OK;
一:【文章服务】部分,内容梳理;
(1)In the center of the front desk of the writer,The user can be published;
● 发表文章的时候,Use a rich text editor;
(2)The user in the content management,Can view all the articles published in the;
(3)After the user published an article,Is the need to review;Audit is divided into automatic and manual audit;
● 自动审核:We will use the ali text detectionAPI来做;
● 人工审核:For some ambiguous article,Use ali automatic audit is not enough light;那么,The administrators will system in the background,进行人工审核;
(4)At the front desk system home page,Will display all users、Approved list of articles;
二:article文章表;
(1)content字段:
● The user is in rich text editor to write the article;The contents of the rich text editor,Not only language, etc,还会有一些HTML代码;
● 我们这儿,At present the article content,保存在了MariaDB数据库中,这其实是不好的;Later we will improve;
(2)article_type字段:
● If the article type is1(图文),Then said the article is on the cover of the need to have a;article_coverField holds the address of the cover;
(3)is_appoint字段:
● 定时发布文章,We will use timing task to do;
(4)article_status字段:
● Only in the published article should withdraw and delete,Reflect a tendency of:"审核中"、"End of the machine on,等待人工审核"这两种状态下,Is a state of also in the process;As long as it is in the process of the state,Says it is working by other business processing;所以,For is in the state of the article,We should not to delete it;
(5)read_counts字段:
● Data for the concurrency value will be higher,We later useredis来优化;(comment_counts数据,我们也会使用redis来优化)
(6)mongo_file_id字段:
● 后面,我们使用MongoDB来优化的时候,Use this field;
三:创建【article】文章服务;
1.pom.xml;
在【article】服务中,引入【api】接口工程的依赖;
<?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"> <parent> <artifactId>imooc-news-dev</artifactId> <groupId>com.imooc</groupId> <version>1.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>imooc-news-dev-service-article</artifactId> <dependencies> <!--在article这个微服务中,引入api接口工程的依赖; 即【article】这个微服务,需要依赖于【api】--> <dependency> <groupId>com.imooc</groupId> <artifactId>imooc-news-dev-service-api</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> </project>
2.application.yml配置文件;
(1)application.yml:
############################################################ # # article文章微服务 # web访问端口号 约定:8001 # ############################################################ server: # port: 8001 tomcat: uri-encoding: UTF-8 max-swallow-size: -1 # tomcat默认大小2M,超过2M的文件不会被捕获,需要调整此处大小为100MB或者-1即可 ############################################################ # # 配置项目信息 # ############################################################ spring: profiles: active: dev # yml中“配置文件”的环境配置,dev表示开发环境,test表示测试环境,prod表示生产环境; application: name: service-article jackson: date-format: yyyy-MM-dd HH:mm:ss time-zone: GMT+8 datasource: # 数据源的相关配置 type: com.zaxxer.hikari.HikariDataSource # 数据源类型:HikariCP driver-class-name: com.mysql.jdbc.Driver # mysql驱动 url: jdbc:mysql://localhost:3308/imooc-news-dev?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true username: root password: ********** hikari: connection-timeout: 30000 # 等待连接池分配连接的最大时长(毫秒),超过这个时长还没可用的连接则发生SQLException, 默认:30秒 minimum-idle: 5 # 最小连接数 maximum-pool-size: 20 # 最大连接数 auto-commit: true # 自动提交(此属性控制从池返回的连接的默认自动提交行为) idle-timeout: 600000 # 连接超时的最大时长(毫秒),超时则被释放(retired),默认:10分钟 pool-name: DateSourceHikariCP # 连接池名字 max-lifetime: 1800000 # 连接的生命时长(毫秒),超时而且没被使用则被释放(retired),默认:30分钟 1800000ms connection-test-query: SELECT 1 #配置MongoDB data: mongodb: uri: mongodb://root:[email protected]***.***:27017 #MongoDBThe deployment of servicesip地址、端口号; database: imooc-news #我们需要在MongoDB中,创建imooc-news这个database; ############################################################ # # mybatis 配置 # ############################################################ mybatis: type-aliases-package: com.imooc.pojo # 所有POJO类所在包路径 mapper-locations: classpath:mapper/*.xml # mapper映射文件 ############################################################ # # mybatis mapper 配置 # ############################################################ # 通用 Mapper 配置 mapper: mappers: com.imooc.my.mapper.MyMapper not-empty: false # 在进行数据库操作的的时候,判断表达式 username != null, 是否追加 username != '' identity: MYSQL # 方言,使用的是MySQL # 分页插件配置 pagehelper: helperDialect: mysql supportMethodsArguments: true
说明:
(1)The article service port,We agreed to8001;
(2)application-dev.yml:
server: port: 8001 spring: redis: database: 0 host: 192.168.***.*** port: 6380 password: ***** # 设置域名,在java代码中获取,这里是资源配置 # 这儿的website和domain-name可以瞎写,只要能做到见名知意就行; website: domain-name: imoocnews.com # dev 开发环境开启mybatis日志 mybatis: configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
(3)application-prod.yml:
server: port: 8001 spring: redis: database: 0 host: 192.168.***.*** port: 6380 password: ***** # 设置域名,在java代码中获取,这里是资源配置 # 这儿的website和domain-name可以瞎写,只要能做到见名知意就行; website: domain-name: imoocnews.com
3.logback-spring.xml日志配置文件;
<?xml version="1.0" encoding="UTF-8"?> <configuration> <!-- 指定日志文件的存储地址,使用绝对路径 --> <!-- <property name="LOG_HOME" value="/workspaces/logs/imooc-news-dev/service-admin"/>--> <property name="LOG_HOME" value="e:/logs/imoocNewsLog/server-article"/> <!-- Console 输出设置 --> <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符--> <pattern>%white(%d{mm:ss.SSS}) %green([%thread]) %cyan(%-5level) %yellow(%logger{36}) %magenta(-) %black(%msg%n)</pattern> <charset>utf8</charset> </encoder> </appender> <!-- 按照每天生成日志文件 --> <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!-- 日志文件输出的文件名 --> <fileNamePattern>${LOG_HOME}/service-article.%d{yyyy-MM-dd}.log</fileNamePattern> </rollingPolicy> <encoder> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> </encoder> </appender> <!--<logger name="org.apache.ibatis.cache.decorators.LoggingCache" level="DEBUG" additivity="false">--> <!--<appender-ref ref="CONSOLE"/>--> <!--</logger>--> <root level="info"><!--因为debug的日志信息,太多了,所以我么把输出的日志级别设置为了info--> <appender-ref ref="FILE"/> <appender-ref ref="CONSOLE"/> </root> </configuration>
4.Application主启动类;
package com.imooc.article; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan; import tk.mybatis.spring.annotation.MapperScan; //@SpringBootApplication(exclude = MongoAutoConfiguration.class) @SpringBootApplication @MapperScan(basePackages = "com.imooc.article.mapper") @ComponentScan(basePackages = {"com.imooc","org.n3r.idworker"}) public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
说明:
(1)In order to make project startup is not a problem,To create the bestmapper包;
四:【article】文章服务,创建测试用的HelloController,看看项目是否OK;
(1)install一下整个项目;(2)只启动【article】文章服务;(3)记得使用SwitchHost开启虚拟域名;(4)访问hello测试接口;
边栏推荐
- C # Hex file transfer skills necessary article 】 【 bin file code implementation
- 【Maui正式版】创建可跨平台的Maui程序,以及有关依赖注入、MVVM双向绑定的实现和演示
- Extended Chinese Remainder Theorem
- 一篇文章教你Pytest快速入门和基础讲解,一定要看
- 合并k个已排序的链表
- 链表中的节点每k个一组翻转
- Research on multi-element N-k fault model of power system based on AC power flow (implemented by Matlab code) [Power System Fault]
- BM7 链表中环的入口结点
- 关于 DataFrame: 处理时间
- 阿里云新增三大高性能计算解决方案,助力生命科学行业快速发展
猜你喜欢
GMT,UTC,CST,DST,RTC,NTP,SNTP,NITZ: 嵌入式的时间
一篇文章教你Pytest快速入门和基础讲解,一定要看
学会开会|成为有连接感组织的重要技能
Exploration and practice of the "zero trust" protection and data security governance system of the ransomware virus of Meichuang Technology
电力系统潮流计算(牛顿-拉夫逊法、高斯-赛德尔法、快速解耦法)(Matlab代码实现)
什么是Jmeter?Jmeter使用的原理步骤是什么?
BM13 determines whether a linked list is a palindrome
Research on multi-element N-k fault model of power system based on AC power flow (implemented by Matlab code) [Power System Fault]
LeetCode每日两题02:反转字符串中的单词 (均1200道)
Likou 221 questions, the largest square
随机推荐
JVM classic fifty questions, now the interview is stable
MySQL Advanced Commands
[Maui official version] Create a cross-platform Maui program, as well as the implementation and demonstration of dependency injection and MVVM two-way binding
3598. 二叉树遍历(华中科技大学考研机试题)
BM7 list entry in central
交换机和生成树知识点
JVM经典五十问,这下面试稳了
shell脚本循环语句for、while语句
String类的常用方法
翻译科技论文,俄译中怎样效果好
The Thread State,
使用 Cloudreve 搭建私有云盘
unusual understanding
服务——DHCP原理与配置
黑猫带你学Makefile第12篇:常见Makefile问题汇总
[SQL brush questions] Day3----Special exercises for common functions that SQL must know
异常的了解
Power system power flow calculation (Newton-Raphson method, Gauss-Seidel method, fast decoupling method) (Matlab code implementation)
元宇宙社交应用,靠什么吸引用户「为爱发电」?
An article to teach you a quick start and basic explanation of Pytest, be sure to read