【发布时间】:2020-08-08 05:22:01
【问题描述】:
{ “代码”:1000, “消息”:“成功”, “时间戳”:1596860735157, “数据”: [ { “身份证”:1, “内容名称”:空, “创建时间”:0, “内容路径”:空 }, { “身份证”:2, “内容名称”:空, “创建时间”:0, “内容路径”:空 }, { “身份证”:3, “内容名称”:空, “创建时间”:0, “内容路径”:空 } ] }
在 t_content_library=> id:bigint,content_name:varchar(450),content_path:varchar(500),created_time:bigint。
mysql> select * from t_content_library;
+----+----------------------------------------------------+----------------------------------------------------------------------------------+---------------+
| id | content_name | content_path | created_time |
+----+----------------------------------------------------+----------------------------------------------------------------------------------+---------------+
| 1 | pexels-jack-redgate-3014019.jpg | C:\Users\DELL\Desktop\content\pexels-jack-redgate-3014019.jpg | 1596783953545 |
| 2 | pexels-thiago-matos-2335275.jpg | C:\Users\DELL\Desktop\content\pexels-thiago-matos-2335275.jpg | 1596784207089 |
| 3 | louis-hansel-shotsoflouis-2gwghEzGp4g-unsplash.jpg | C:\Users\DELL\Desktop\content\louis-hansel-shotsoflouis-2gwghEzGp4g-unsplash.jpg | 1596784491699 |
| 4 | jessica-delp-p1P_e86R2DI-unsplash.jpg | C:\Users\DELL\Desktop\content\jessica-delp-p1P_e86R2DI-unsplash.jpg | 1596784579313 |
| 5 | patrick-untersee-OrT5-yC95j0-unsplash.jpg | C:\Users\DELL\Desktop\content\patrick-untersee-OrT5-yC95j0-unsplash.jpg | 1596784602268 |
| 6 | jun-zhao-XWQ15ixxRjE-unsplash.jpg | C:\Users\DELL\Desktop\content\jun-zhao-XWQ15ixxRjE-unsplash.jpg | 1596784616456 |
| 7 | jo-jo-mPM-x0zPhok-unsplash.jpg | C:\Users\DELL\Desktop\content\jo-jo-mPM-x0zPhok-unsplash.jpg | 1596784632238 |
| 8 | melnychuk-nataliya-8J6uuvsdj-4-unsplash.jpg | C:\Users\DELL\Desktop\content\melnychuk-nataliya-8J6uuvsdj-4-unsplash.jpg | 1596784644961 |
| 9 | nathan-anderson-UhagOo7IOyc-unsplash.jpg | C:\Users\DELL\Desktop\content\nathan-anderson-UhagOo7IOyc-unsplash.jpg | 1596784877626 |
| 10 | gayathri-sri-ptbKY_b1ROc-unsplash.jpg | C:\Users\DELL\Desktop\content\gayathri-sri-ptbKY_b1ROc-unsplash.jpg | 1596784887985 |
| 11 | Depositphotos_95439918_xl-2015_1920x1920.jpg | C:\Users\DELL\Desktop\content\Depositphotos_95439918_xl-2015_1920x1920.jpg | 1596907309367 |
+----+----------------------------------------------------+----------------------------------------------------------------------------------+---------------+
-
型号
@Data @AllArgsConstructor @NoArgsConstructor @Builder @ToString public class ContentLibrary { int id; String contentName; long createdTime; String contentPath; } -
控制器
@RequestMapping(path = "content/library/") @RestController public class ContentLibraryController { @Autowired ContentLibraryService contentLibraryService; @PostMapping("") public Response readLibrary() { List<ContentLibrary> contentLibraries = contentLibraryService.readContentLibrary(); return ResponseBuilder.buildSuccessResponse(contentLibraries); } } -
服务
@Service public class ContentLibraryService { @Autowired ContentLibraryMapper contentLibraryMapper; ContentLibrary content = new ContentLibrary(); public List<ContentLibrary> readContentLibrary() { return contentLibraryMapper.readAllLibraryContent(); } } -
映射器
@Repository @Mapper public interface ContentLibraryMapper { @Select("SELECT * FROM t_content_library") List<ContentLibrary> readAllLibraryContent(); }
【问题讨论】:
标签: spring rest gradle mybatis pojo