fix
This commit is contained in:
parent
4871c0eee2
commit
004c2d900b
@ -1,10 +1,10 @@
|
||||
package com.example.demo.controller;
|
||||
|
||||
import com.example.demo.entity.News;
|
||||
import com.example.demo.entity.User;
|
||||
import com.example.demo.service.NewsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -21,4 +21,9 @@ public class NewsController {
|
||||
public List<News> getAllNews() {
|
||||
return newsService.getAllNews();
|
||||
}
|
||||
|
||||
@PostMapping("/insertNews")
|
||||
public Boolean insertNews(@RequestBody List<News> newsList) {
|
||||
return newsService.saveBatch(newsList);
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,6 +29,9 @@ public class News {
|
||||
@TableField(value = "EXT")
|
||||
private String ext;
|
||||
|
||||
@TableField(value = "BATCH_ID")
|
||||
private String batch_id;
|
||||
|
||||
public News() {
|
||||
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@ package com.example.demo.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.example.demo.entity.User;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
|
||||
public interface UserMapper extends BaseMapper<User> {
|
||||
}
|
||||
|
||||
@ -6,7 +6,9 @@ import com.example.demo.mapper.NewsMapper;
|
||||
import com.example.demo.service.NewsService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> implements NewsService {
|
||||
@ -19,4 +21,13 @@ public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> implements Ne
|
||||
public News getNewsById(Integer id) {
|
||||
return getById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveBatch(Collection<News> newsList) {
|
||||
String batchId = UUID.randomUUID().toString();
|
||||
for (News news : newsList) {
|
||||
news.setBatch_id(batchId);
|
||||
}
|
||||
return super.saveBatch(newsList);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,29 +1,19 @@
|
||||
# ????????????????
|
||||
modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory,com.p6spy.engine.outage.P6OutageFactory
|
||||
|
||||
# ???????
|
||||
logMessageFormat=com.baomidou.mybatisplus.extension.p6spy.P6SpyLogger
|
||||
|
||||
# ????????
|
||||
appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger
|
||||
|
||||
# ??JDBC????
|
||||
deregisterdrivers=true
|
||||
|
||||
# ????
|
||||
useprefix=true
|
||||
|
||||
# ???????
|
||||
excludecategories=info,debug,result,commit,resultset
|
||||
|
||||
# ????
|
||||
dateformat=yyyy-MM-dd HH:mm:ss
|
||||
|
||||
# ??????
|
||||
# driverlist=org.h2.Driver
|
||||
|
||||
# ???SQL??
|
||||
outagedetection=true
|
||||
|
||||
# ?SQL??????????
|
||||
outagedetectioninterval=2
|
||||
@ -1,21 +0,0 @@
|
||||
package com.example.demo;
|
||||
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class DatabaseTestRunner implements CommandLineRunner {
|
||||
|
||||
private final JdbcTemplate jdbcTemplate;
|
||||
|
||||
public DatabaseTestRunner(JdbcTemplate jdbcTemplate) {
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(String...args) throws Exception{
|
||||
jdbcTemplate.execute("SELECT 1");
|
||||
System.out.println("database connection is scuccessful");
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user