patch: “新增轮播图接口”加一个作者的字段。而且还是可以填可以不填的
All checks were successful
JslGroup/JslDeveloper/JSL_OrganizeInternalOA/pipeline/head This commit looks good

This commit is contained in:
筱锋xiao_lfeng 2024-02-03 22:01:30 +08:00
parent 53cd59a138
commit b2a268ff29
Signed by: XiaoLFeng
GPG Key ID: F693AA12AABBFA87
3 changed files with 19 additions and 3 deletions

View File

@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager"> <component name="ProjectRunConfigurationManager">
<configuration default="false" name="oa [spring-boot:run]" type="MavenRunConfiguration" factoryName="Maven" nameIsGenerated="true"> <configuration default="false" name="oa [clean,spring-boot:run]" type="MavenRunConfiguration" factoryName="Maven" nameIsGenerated="true">
<MavenSettings> <MavenSettings>
<option name="myGeneralSettings" /> <option name="myGeneralSettings" />
<option name="myRunnerSettings" /> <option name="myRunnerSettings" />
@ -11,6 +11,7 @@
</option> </option>
<option name="goals"> <option name="goals">
<list> <list>
<option value="clean" />
<option value="spring-boot:run" /> <option value="spring-boot:run" />
</list> </list>
</option> </option>

View File

@ -17,6 +17,7 @@ import lombok.Data;
public class CarouselVO { public class CarouselVO {
private Integer id; private Integer id;
private Integer displayOrder; private Integer displayOrder;
private String author;
private String image; private String image;
private String title; private String title;
private String description; private String description;

View File

@ -49,6 +49,13 @@ public class InfoServiceImpl implements InfoService {
UserDO userDO = userDAO.getUserById(userId); UserDO userDO = userDAO.getUserById(userId);
// 获取轮播图信息 // 获取轮播图信息
CarouselDO carouselDO = infoDAO.getCarousel(); CarouselDO carouselDO = infoDAO.getCarousel();
// 检查轮播图是否手动设置作者
String author;
if (carouselVO.getAuthor() != null && !carouselVO.getAuthor().isEmpty()) {
author = carouselVO.getAuthor();
} else {
author = userDO.getUsername();
}
// 添加轮播图 // 添加轮播图
CarouselDO.DataDO carousel = new CarouselDO.DataDO(); CarouselDO.DataDO carousel = new CarouselDO.DataDO();
carousel.setDisplayOrder(carouselVO.getDisplayOrder()) carousel.setDisplayOrder(carouselVO.getDisplayOrder())
@ -56,7 +63,7 @@ public class InfoServiceImpl implements InfoService {
.setDescription(carouselVO.getDescription()) .setDescription(carouselVO.getDescription())
.setTitle(carouselVO.getTitle()) .setTitle(carouselVO.getTitle())
.setIsActive(carouselVO.getIsActive()) .setIsActive(carouselVO.getIsActive())
.setAuthor(userDO.getUsername()) .setAuthor(author)
.setCreatedAt(new Timestamp(System.currentTimeMillis()).toString()); .setCreatedAt(new Timestamp(System.currentTimeMillis()).toString());
carouselDO.getData().add(carousel); carouselDO.getData().add(carousel);
// 保存轮播图 // 保存轮播图
@ -80,13 +87,20 @@ public class InfoServiceImpl implements InfoService {
if (carouselVO.getId() > carouselDO.getData().size()) { if (carouselVO.getId() > carouselDO.getData().size()) {
return ResultUtil.error(ErrorCode.ID_NOT_EXIST); return ResultUtil.error(ErrorCode.ID_NOT_EXIST);
} }
// 检查轮播图是否手动设置作者
String author;
if (carouselVO.getAuthor() != null) {
author = carouselVO.getAuthor();
} else {
author = userDO.getUsername();
}
CarouselDO.DataDO carousel = carouselDO.getData().get(carouselVO.getId() - 1); CarouselDO.DataDO carousel = carouselDO.getData().get(carouselVO.getId() - 1);
carousel.setDisplayOrder(carouselVO.getDisplayOrder()) carousel.setDisplayOrder(carouselVO.getDisplayOrder())
.setImage(carouselVO.getImage()) .setImage(carouselVO.getImage())
.setDescription(carouselVO.getDescription()) .setDescription(carouselVO.getDescription())
.setTitle(carouselVO.getTitle()) .setTitle(carouselVO.getTitle())
.setIsActive(carouselVO.getIsActive()) .setIsActive(carouselVO.getIsActive())
.setAuthor(userDO.getUsername()) .setAuthor(author)
.setUpdatedAt(new Timestamp(System.currentTimeMillis()).toString()); .setUpdatedAt(new Timestamp(System.currentTimeMillis()).toString());
// 保存轮播图 // 保存轮播图
if (infoDAO.setCarousel(carouselDO)) { if (infoDAO.setCarousel(carouselDO)) {