feat(REQ-2106): Banner相关接口实现完成
This commit is contained in:
parent
621a7e48c4
commit
96b0128ef4
@ -52,7 +52,7 @@ public interface ApplicationVersionApi {
|
||||
* @return void
|
||||
*/
|
||||
@GetMapping("/api/applicationVersion/delete")
|
||||
ApiResult<Void> deleteById(@RequestParam("id") Long id);
|
||||
ApiResult<Void> deleteById(@RequestParam("id") Long id, @RequestParam("personId") Long personId);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
|
||||
@ -67,4 +67,14 @@ public class CreateApplicationVersionReq {
|
||||
* 更新后是否弹窗提醒,0不提醒,1提醒,默认0
|
||||
*/
|
||||
private int remind;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private Long updateBy;
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
package cn.axzo.nanopart.api.request;
|
||||
|
||||
import cn.axzo.nanopart.api.enums.RecodeTypeEnum;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author chenwenjian
|
||||
* @version 1.0
|
||||
* @date 2024/4/7 13:38
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CreateBannerOperationLogReq {
|
||||
|
||||
|
||||
/**
|
||||
* 类型:banner,material
|
||||
*/
|
||||
private RecodeTypeEnum recodeType;
|
||||
|
||||
/**
|
||||
* 记录id
|
||||
*/
|
||||
private Long recodeId;
|
||||
|
||||
/**
|
||||
* 操作类型,新增,编辑,删除
|
||||
*/
|
||||
private String operationType;
|
||||
|
||||
/**
|
||||
* 新数据
|
||||
*/
|
||||
private JSONObject newData;
|
||||
|
||||
/**
|
||||
* 旧数据
|
||||
*/
|
||||
private JSONObject oldData;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
}
|
||||
@ -22,7 +22,6 @@ import java.time.LocalDateTime;
|
||||
@AllArgsConstructor
|
||||
public class PageBannerOperationLogReq {
|
||||
|
||||
|
||||
/**
|
||||
* 类型:banner,material
|
||||
*/
|
||||
|
||||
@ -56,4 +56,9 @@ public class UpdateApplicationVersionReq {
|
||||
* 更新后是否弹窗提醒,0不提醒,1提醒,默认0
|
||||
*/
|
||||
private int remind;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private Long updateBy;
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ public class ApplicationVersionController implements ApplicationVersionApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<Void> deleteById(Long id) {
|
||||
public ApiResult<Void> deleteById(Long id, Long personId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,13 @@
|
||||
package cn.axzo.nanopart.server.service;
|
||||
|
||||
import cn.axzo.nanopart.api.request.CreateBannerOperationLogReq;
|
||||
|
||||
/**
|
||||
* @author chenwenjian
|
||||
* @version 1.0
|
||||
* @date 2024/4/5 18:06
|
||||
*/
|
||||
public interface BannerOperationLogService {
|
||||
|
||||
Long create(CreateBannerOperationLogReq req);
|
||||
}
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package cn.axzo.nanopart.server.service.impl;
|
||||
|
||||
import cn.axzo.nanopart.api.request.CreateBannerOperationLogReq;
|
||||
import cn.axzo.nanopart.server.dao.BannerOperationLogDao;
|
||||
import cn.axzo.nanopart.server.domain.BannerOperationLog;
|
||||
import cn.axzo.nanopart.server.service.BannerOperationLogService;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -17,4 +19,10 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class BannerOperationLogServiceImpl extends ServiceImpl<BannerOperationLogDao, BannerOperationLog> implements BannerOperationLogService {
|
||||
@Override
|
||||
public Long create(CreateBannerOperationLogReq req) {
|
||||
BannerOperationLog bannerOperationLog = BeanUtil.copyProperties(req, BannerOperationLog.class);
|
||||
this.save(bannerOperationLog);
|
||||
return bannerOperationLog.getId();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package cn.axzo.nanopart.server.service.impl;
|
||||
|
||||
import cn.axzo.framework.domain.ServiceException;
|
||||
import cn.axzo.nanopart.api.enums.RecodeTypeEnum;
|
||||
import cn.axzo.nanopart.api.request.CreateBannerOperationLogReq;
|
||||
import cn.axzo.nanopart.api.request.CreateBannerReq;
|
||||
import cn.axzo.nanopart.api.request.DetailBannerReq;
|
||||
import cn.axzo.nanopart.api.request.PageBannerReq;
|
||||
@ -13,6 +15,7 @@ import cn.axzo.nanopart.server.service.BannerOperationLogService;
|
||||
import cn.axzo.nanopart.server.service.BannerService;
|
||||
import cn.axzo.pokonyan.dao.converter.PageConverter;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -21,6 +24,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@ -58,13 +62,32 @@ public class BannerServiceImpl extends ServiceImpl<BannerDao, Banner> implements
|
||||
*
|
||||
* @param req {@link UpdateBannerReq}
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void update(UpdateBannerReq req) {
|
||||
// 校验占位图宽高比例
|
||||
req.getAspectRatio().checkAspectRatio();
|
||||
|
||||
Banner oldBanner = this.selectById(req.getId());
|
||||
if (Objects.isNull(oldBanner)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LambdaUpdateChainWrapper<Banner> updateLambdaQueryChain = buildUpdateLambdaQueryChain(req);
|
||||
update(updateLambdaQueryChain);
|
||||
|
||||
Banner newBanner = this.selectById(req.getId());
|
||||
|
||||
// 记录操作日志
|
||||
CreateBannerOperationLogReq updateLogReq = new CreateBannerOperationLogReq()
|
||||
.setRecodeType(RecodeTypeEnum.BANNER)
|
||||
.setRecodeId(req.getId())
|
||||
.setOperationType("update")
|
||||
.setOldData((JSONObject) JSONObject.toJSON(oldBanner))
|
||||
.setNewData((JSONObject) JSONObject.toJSON(newBanner))
|
||||
.setCreateBy(req.getUpdateBy())
|
||||
.setUpdateBy(req.getUpdateBy());
|
||||
bannerOperationLogService.create(updateLogReq);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -88,6 +111,7 @@ public class BannerServiceImpl extends ServiceImpl<BannerDao, Banner> implements
|
||||
* @param req {@link CreateBannerReq}
|
||||
* @return bannerId
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public Long create(CreateBannerReq req) {
|
||||
// 对站点code进行校重
|
||||
@ -101,6 +125,14 @@ public class BannerServiceImpl extends ServiceImpl<BannerDao, Banner> implements
|
||||
this.save(banner);
|
||||
|
||||
// 记录日志
|
||||
CreateBannerOperationLogReq createLogReq = new CreateBannerOperationLogReq()
|
||||
.setRecodeType(RecodeTypeEnum.BANNER)
|
||||
.setRecodeId(banner.getId())
|
||||
.setOperationType("create")
|
||||
.setNewData((JSONObject) JSONObject.toJSON(banner))
|
||||
.setCreateBy(req.getCreateBy())
|
||||
.setUpdateBy(req.getUpdateBy());
|
||||
bannerOperationLogService.create(createLogReq);
|
||||
return banner.getId();
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user