|
|
@@ -0,0 +1,61 @@ |
|
|
|
package com.hz.pm.api.sys.manage; |
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.hz.pm.api.common.model.constant.BizConst; |
|
|
|
import com.hz.pm.api.sys.model.dto.StagingDTO; |
|
|
|
import com.hz.pm.api.sys.model.entity.Staging; |
|
|
|
import com.hz.pm.api.sys.model.enumeration.StagingType; |
|
|
|
import com.hz.pm.api.sys.service.IStagingService; |
|
|
|
import com.hz.pm.api.user.util.LoginUserUtil; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
|
|
|
|
/** |
|
|
|
* <p> |
|
|
|
* StagingManage |
|
|
|
* </p> |
|
|
|
* |
|
|
|
* @author WendyYang |
|
|
|
* @since 14:21 2024/3/25 |
|
|
|
*/ |
|
|
|
@Component |
|
|
|
@AllArgsConstructor |
|
|
|
public class StagingManage { |
|
|
|
|
|
|
|
private final IStagingService stagingService; |
|
|
|
|
|
|
|
public void save(StagingDTO staging) { |
|
|
|
Staging entity = new Staging(); |
|
|
|
entity.setType(staging.getType().name()); |
|
|
|
entity.setContent(staging.getContent()); |
|
|
|
entity.setBizId(staging.getBizId()); |
|
|
|
entity.setCreateBy(LoginUserUtil.getUserId()); |
|
|
|
entity.setCreateOn(LocalDateTime.now()); |
|
|
|
stagingService.save(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public StagingDTO detail(StagingType type, String bizId) { |
|
|
|
Wrapper<Staging> query = Wrappers.lambdaQuery(Staging.class) |
|
|
|
.eq(Staging::getType, type) |
|
|
|
.eq(Staging::getCreateBy, LoginUserUtil.getUserId()) |
|
|
|
.eq(StrUtil.isNotBlank(bizId), Staging::getBizId, bizId) |
|
|
|
.orderByDesc(Staging::getCreateOn, Staging::getId) |
|
|
|
.last(BizConst.LIMIT_1); |
|
|
|
Staging staging = stagingService.getOne(query); |
|
|
|
if (staging == null) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
StagingDTO detail = new StagingDTO(); |
|
|
|
detail.setId(staging.getId()); |
|
|
|
detail.setContent(staging.getType()); |
|
|
|
detail.setType(StagingType.valueOf(staging.getType())); |
|
|
|
detail.setBizId(staging.getBizId()); |
|
|
|
return detail; |
|
|
|
} |
|
|
|
|
|
|
|
} |