Compare commits
	
		
			No commits in common. "master" and "detached" have entirely different histories.
		
	
	
		
	
		
| @ -42,11 +42,3 @@ dependencies { | |||||||
| tasks.named('test') { | tasks.named('test') { | ||||||
| 	useJUnitPlatform() | 	useJUnitPlatform() | ||||||
| } | } | ||||||
| 
 |  | ||||||
| tasks.withType(JavaCompile) { |  | ||||||
| 	options.encoding = 'UTF-8' |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| tasks.withType(Test) { |  | ||||||
| 	systemProperty 'file.encoding', 'UTF-8' |  | ||||||
| } |  | ||||||
| @ -1,26 +0,0 @@ | |||||||
| package com.example.demo.config; |  | ||||||
| 
 |  | ||||||
| import com.baomidou.mybatisplus.annotation.DbType; |  | ||||||
| import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer; |  | ||||||
| import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; |  | ||||||
| import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; |  | ||||||
| import org.mybatis.spring.annotation.MapperScan; |  | ||||||
| import org.springframework.context.annotation.Bean; |  | ||||||
| import org.springframework.context.annotation.Configuration; |  | ||||||
| 
 |  | ||||||
| @Configuration |  | ||||||
| @MapperScan(basePackages = {"com.example.**.mapper"}) |  | ||||||
| public class MybatisPlusConfig { |  | ||||||
| 
 |  | ||||||
|     @Bean |  | ||||||
|     public MybatisPlusInterceptor mybatisPlusInterceptor() { |  | ||||||
|         MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); |  | ||||||
|         interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); |  | ||||||
|         return interceptor; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     @Bean |  | ||||||
|     public ConfigurationCustomizer configurationCustomizer() { |  | ||||||
|         return configuration -> configuration.setUseGeneratedShortKey(false); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -1,7 +1,7 @@ | |||||||
| package com.example.demo.controller; | package com.example.demo.controller; | ||||||
| 
 | 
 | ||||||
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |  | ||||||
| import com.example.demo.entity.News; | import com.example.demo.entity.News; | ||||||
|  | import com.example.demo.entity.User; | ||||||
| import com.example.demo.service.NewsService; | import com.example.demo.service.NewsService; | ||||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||||
| @ -9,7 +9,6 @@ import org.springframework.web.bind.annotation.*; | |||||||
| import java.util.List; | import java.util.List; | ||||||
| 
 | 
 | ||||||
| @RestController | @RestController | ||||||
| @RequestMapping("/news") |  | ||||||
| public class NewsController { | public class NewsController { | ||||||
|     private final NewsService newsService; |     private final NewsService newsService; | ||||||
| 
 | 
 | ||||||
| @ -18,11 +17,9 @@ public class NewsController { | |||||||
|         this.newsService = newsService; |         this.newsService = newsService; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @GetMapping("/list") |     @GetMapping("/news") | ||||||
|     public Page<News> getAllNews(@RequestParam(defaultValue = "1") int page, |     public List<News> getAllNews() { | ||||||
|                                  @RequestParam(defaultValue = "10") int size) { |         return newsService.getAllNews(); | ||||||
|         Page<News> newsPage = new Page<>(page, size); |  | ||||||
|         return newsService.getAllNews(newsPage); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @PostMapping("/insertNews") |     @PostMapping("/insertNews") | ||||||
|  | |||||||
| @ -17,20 +17,20 @@ public class News { | |||||||
|     @TableField(value = "EXCERPT") |     @TableField(value = "EXCERPT") | ||||||
|     private String excerpt; |     private String excerpt; | ||||||
| 
 | 
 | ||||||
|     @TableField(value = "CREATE_TIME", fill = FieldFill.INSERT) |     @TableField(value = "CREATE_TIME", fill = FieldFill.UPDATE) | ||||||
|     private Timestamp createTime; |     private Timestamp create_time; | ||||||
| 
 | 
 | ||||||
|     @TableField(value = "UPDATE_TIME", fill = FieldFill.UPDATE) |     @TableField(value = "UPDATE_TIME", fill = FieldFill.INSERT) | ||||||
|     private Timestamp updateTime; |     private Timestamp update_time; | ||||||
| 
 | 
 | ||||||
|     @TableField(value = "IS_DELETE") |     @TableField(value = "IS_DELETE") | ||||||
|     private Boolean isDelete; |     private Boolean is_delete; | ||||||
| 
 | 
 | ||||||
|     @TableField(value = "EXT") |     @TableField(value = "EXT") | ||||||
|     private String ext; |     private String ext; | ||||||
| 
 | 
 | ||||||
|     @TableField(value = "BATCH_ID") |     @TableField(value = "BATCH_ID") | ||||||
|     private String batchId; |     private String batch_id; | ||||||
| 
 | 
 | ||||||
|     public News() { |     public News() { | ||||||
| 
 | 
 | ||||||
| @ -40,4 +40,14 @@ public class News { | |||||||
|         this.title = title; |         this.title = title; | ||||||
|         this.excerpt = excerpt; |         this.excerpt = excerpt; | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     public News(int id, String title, String excerpt, Timestamp create_time, Timestamp update_time, Boolean is_delete, String ext) { | ||||||
|  |         this.id = id; | ||||||
|  |         this.title = title; | ||||||
|  |         this.excerpt = excerpt; | ||||||
|  |         this.create_time = create_time; | ||||||
|  |         this.update_time = update_time; | ||||||
|  |         this.is_delete = is_delete; | ||||||
|  |         this.ext = ext; | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -2,8 +2,6 @@ package com.example.demo.mapper; | |||||||
| 
 | 
 | ||||||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||||||
| import com.example.demo.entity.News; | import com.example.demo.entity.News; | ||||||
| import org.apache.ibatis.annotations.Mapper; |  | ||||||
| 
 | 
 | ||||||
| @Mapper |  | ||||||
| public interface NewsMapper extends BaseMapper<News> { | public interface NewsMapper extends BaseMapper<News> { | ||||||
| } | } | ||||||
|  | |||||||
| @ -2,8 +2,6 @@ package com.example.demo.mapper; | |||||||
| 
 | 
 | ||||||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||||||
| import com.example.demo.entity.User; | import com.example.demo.entity.User; | ||||||
| import org.apache.ibatis.annotations.Mapper; |  | ||||||
| 
 | 
 | ||||||
| @Mapper |  | ||||||
| public interface UserMapper extends BaseMapper<User> { | public interface UserMapper extends BaseMapper<User> { | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,9 +1,10 @@ | |||||||
| package com.example.demo.service; | package com.example.demo.service; | ||||||
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |  | ||||||
| import com.baomidou.mybatisplus.extension.service.IService; | import com.baomidou.mybatisplus.extension.service.IService; | ||||||
| import com.example.demo.entity.News; | import com.example.demo.entity.News; | ||||||
| 
 | 
 | ||||||
|  | import java.util.List; | ||||||
|  | 
 | ||||||
| public interface NewsService extends IService<News> { | public interface NewsService extends IService<News> { | ||||||
|     Page<News> getAllNews(Page<News> page); |     List<News> getAllNews(); | ||||||
|     News getNewsById(Integer id); |     News getNewsById(Integer id); | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,6 +1,5 @@ | |||||||
| package com.example.demo.service.impl; | package com.example.demo.service.impl; | ||||||
| 
 | 
 | ||||||
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |  | ||||||
| import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ||||||
| import com.example.demo.entity.News; | import com.example.demo.entity.News; | ||||||
| import com.example.demo.mapper.NewsMapper; | import com.example.demo.mapper.NewsMapper; | ||||||
| @ -13,15 +12,9 @@ import java.util.UUID; | |||||||
| 
 | 
 | ||||||
| @Service | @Service | ||||||
| public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> implements NewsService { | public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> implements NewsService { | ||||||
|     private final NewsMapper newsMapper; |  | ||||||
| 
 |  | ||||||
|     public NewsServiceImpl(NewsMapper newsMapper) { |  | ||||||
|         this.newsMapper = newsMapper; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     @Override |     @Override | ||||||
|     public Page<News> getAllNews(Page<News> page) { |     public List<News> getAllNews() { | ||||||
|         return newsMapper.selectPage(page, null); |         return list(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
| @ -33,7 +26,7 @@ public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> implements Ne | |||||||
|     public boolean saveBatch(Collection<News> newsList) { |     public boolean saveBatch(Collection<News> newsList) { | ||||||
|         String batchId = UUID.randomUUID().toString(); |         String batchId = UUID.randomUUID().toString(); | ||||||
|         for (News news : newsList) { |         for (News news : newsList) { | ||||||
|             news.setBatchId(batchId); |             news.setBatch_id(batchId); | ||||||
|         } |         } | ||||||
|         return super.saveBatch(newsList); |         return super.saveBatch(newsList); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -3,10 +3,7 @@ spring.datasource.url=jdbc:p6spy:mysql://47.106.93.245:9003/service | |||||||
| spring.datasource.username=root | spring.datasource.username=root | ||||||
| spring.datasource.password=qingyu23. | spring.datasource.password=qingyu23. | ||||||
| spring.datasource.driver-class-name = com.p6spy.engine.spy.P6SpyDriver | spring.datasource.driver-class-name = com.p6spy.engine.spy.P6SpyDriver | ||||||
| mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl | #spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver | ||||||
| mybatis-plus.global-config.db-config.id-type=auto |  | ||||||
| logging.level.com.baomidou.mybatisplus=DEBUG |  | ||||||
| logging.level.org.apache.ibatis=DEBUG |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user