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