().eq("user_id", user.getUserId()));
50 | return num == 1 ? user : null;
51 | }
52 |
53 | @Override
54 | public int deleteById(Integer id) {
55 | return userMapper.deleteById(id);
56 | }
57 | }
58 |
59 |
--------------------------------------------------------------------------------
/back/src/main/java/com/haust/back/util/ReadFile.java:
--------------------------------------------------------------------------------
1 | package com.haust.back.util;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.IOException;
5 | import java.io.InputStream;
6 | import java.io.InputStreamReader;
7 | import java.util.ArrayList;
8 | import java.util.List;
9 |
10 | public class ReadFile {
11 | public List readTxtFile(String filePath, String encoding) throws IOException {
12 | List res = new ArrayList();
13 | InputStream is = null;
14 | InputStreamReader isr = null;
15 | is = this.getClass().getClassLoader().getResourceAsStream(filePath);
16 | isr = new InputStreamReader(is);
17 | BufferedReader bufferedReader = new BufferedReader(isr);
18 | String lineTxt = null;
19 | while ((lineTxt = bufferedReader.readLine()) != null) {
20 | res.add(lineTxt);
21 | }
22 | return res;
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/back/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=8080
2 |
3 | spring.mvc.pathmatch.matching-strategy=ant_path_matcher
4 |
5 | spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
6 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver
7 | spring.datasource.url=jdbc:mysql://localhost:3306/News?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC
8 | spring.datasource.username=root
9 | spring.datasource.password=010619HYy
10 | #mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
--------------------------------------------------------------------------------
/back/src/main/resources/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootLogger=error
2 | #log4j.rootLogger=info, stdout
3 | #log4j.appender.stdout=org.apache.log4j.ConsoleAppender
4 | #log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
5 | #log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %5p --- [%50t] %-80c(line:%5L) : %m%n
6 |
--------------------------------------------------------------------------------
/back/src/main/resources/static/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | SpringBoot后端服务已经启动
4 | SpringBoot backend service is running ......
5 |
6 |
--------------------------------------------------------------------------------
/back/src/test/java/com/haust/back/BackApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.haust.back;
2 |
3 | import java.sql.Timestamp;
4 | import java.util.Date;
5 | import java.util.List;
6 |
7 | import org.junit.jupiter.api.Test;
8 | import org.springframework.beans.factory.annotation.Autowired;
9 | import org.springframework.boot.test.context.SpringBootTest;
10 |
11 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
12 | import com.haust.back.entity.Comment;
13 | import com.haust.back.entity.Newstatus;
14 | import com.haust.back.entity.User;
15 | import com.haust.back.entity.Useroperationnew;
16 | import com.haust.back.mapper.*;
17 |
18 | @SpringBootTest
19 | class BackApplicationTests {
20 | @Autowired
21 | private UserMapper userMapper;
22 | @Autowired
23 | private NewMapper newMapper;
24 | @Autowired
25 | private UseroperationnewMapper useroperationnewMapper;
26 | @Autowired
27 | private CommentMapper commentMapper;
28 | @Autowired
29 | private NewstatusMapper newstatusMapper;
30 | @Test
31 | public void test() {
32 | List users = userMapper.selectList(null);
33 | users.forEach(System.out::println);
34 | }
35 | @Test
36 | public void GetHotNewsTest() {
37 | List hotsnews = useroperationnewMapper.getHotNews();
38 | hotsnews.forEach(System.out::println);
39 | }
40 | @Test
41 | public void GetCommentTest() {
42 | List comments = commentMapper.selectList(null);
43 | System.out.println(comments);
44 | }
45 | @Test
46 | public void InsertCommentTest() {
47 | Comment comment = new Comment();
48 | comment.setUserId(1);
49 | comment.setNewId(1);
50 | comment.setCCnt("测试评论");
51 | java.util.Date date = new Date();//获得当前时间
52 | Timestamp t = new Timestamp(date.getTime());//将时间转换成Timestamp类型,这样便可以存入到Mysql数据库中
53 | comment.setCDate(t);
54 | commentMapper.insert(comment);
55 | System.out.println(comment);
56 | }
57 | @Test
58 | public void CommentTest()
59 | {
60 | List comment=commentMapper.selectList(null);
61 | System.out.println(comment);
62 | }
63 | @Test
64 | public void GetStatusTest()
65 | {
66 | System.out.println(newstatusMapper.selectOne(new QueryWrapper().eq("new_id", 1)));
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/front/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | pnpm-debug.log*
8 | lerna-debug.log*
9 |
10 | node_modules
11 | dist
12 | dist-ssr
13 | *.local
14 |
15 | # Editor directories and files
16 | .vscode/*
17 | !.vscode/extensions.json
18 | .idea
19 | .DS_Store
20 | *.suo
21 | *.ntvs*
22 | *.njsproj
23 | *.sln
24 | *.sw?
25 |
--------------------------------------------------------------------------------
/front/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"]
3 | }
4 |
--------------------------------------------------------------------------------
/front/README.md:
--------------------------------------------------------------------------------
1 | # Vue 3 + Vite
2 |
3 | This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `
12 |