{
“代码”:1000,
“message”:“成功”,
“时间戳记”:1596860735157,
“数据”:[
{
“id”:1
“contentName”:null,
“createdTime”:0,
“contentPath”:null
},
{
“id”:2
“contentName”:null,
“createdTime”:0,
“contentPath”:null
},
{
“id”:3,
“contentName”:null,
“createdTime”:0,
“contentPath”:null
}
]
}
在这里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();
}
最佳答案
您需要启用将下划线映射到驼峰大小写的MyBatis函数。
如果您使用的是Spring Boot,请将以下内容添加到application.properties
:
mybatis.configuration.map-underscore-to-camel-case=true