Commit 6dd9c5e2 authored by alex yao's avatar alex yao

feat:新增审核单接口

parent 24428bc6
package cn.com.poc.approval.aggregate;
import cn.com.poc.approval.constants.ApprovalEnum;
import cn.com.poc.approval.dto.BizApprovalDto;
import cn.com.yict.framemax.data.model.PagingInfo;
import java.util.List;
/**
* @author alex.yao
* @date 2025/6/27
*/
public interface ApprovalService {
/**
* 提交审批单
*
* @param approvalType 审核类型
* @param approvalContent 审批单内容
* @param userId 用户ID
* @return 审批单状态
*/
String submit(ApprovalEnum.ApprovalTypeEnum approvalType, String approvalContent, Long userId);
/**
* 更新审批状态
*
* @param approvalId 审批单ID
* @param approvalStatus 审批状态
* @param approvalProfessionalId 审批人ID
* @return 审批单状态
*/
String updateStatus(Long approvalId, ApprovalEnum.ApprovalStatusEnum approvalStatus, Long approvalProfessionalId);
/**
* 删除审批单
*
* @param approvalId 审批单ID
* @param userId 用户ID
*/
void delete(Long approvalId, Long userId);
/**
* 获取审批单详情
*
* @param approvalId 审批单ID
* @return 审批单详情
*/
BizApprovalDto getDetail(Long approvalId);
/**
* 获取审批单列表
*
* @param userId 用户ID
* @param approvalType 审批类型
* @param approvalStatus 审批状态
* @param pagingInfo 分页信息
* @return 审批单列表
*/
List<BizApprovalDto> getList(Long userId, ApprovalEnum.ApprovalTypeEnum approvalType, ApprovalEnum.ApprovalStatusEnum approvalStatus, PagingInfo pagingInfo) throws Exception;
}
package cn.com.poc.approval.aggregate.impl;
import cn.com.poc.approval.aggregate.ApprovalService;
import cn.com.poc.approval.constants.ApprovalEnum;
import cn.com.poc.approval.convert.BizApprovalConvert;
import cn.com.poc.approval.dto.BizApprovalDto;
import cn.com.poc.approval.entity.BizApprovalEntity;
import cn.com.poc.approval.service.BizApprovalService;
import cn.com.poc.common.constant.CommonConstant;
import cn.com.poc.common.utils.StringUtils;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.data.model.PagingInfo;
import cn.com.yict.framemax.frame.service.FmxParamConfigService;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author alex.yao
* @date 2025/6/27
*/
@Service
public class ApprovalServiceImpl implements ApprovalService {
private final Logger logger = LoggerFactory.getLogger(ApprovalService.class);
private final String PARAM_CODE = "approval.user_id";
@Resource
private BizApprovalService bizApprovalService;
@Resource
private FmxParamConfigService fmxParamConfigService;
@Override
public String submit(ApprovalEnum.ApprovalTypeEnum approvalType, String approvalContent, Long userId) {
String paramValue = fmxParamConfigService.getParam(PARAM_CODE);
if (paramValue == null || StringUtils.isBlank(paramValue)) {
throw new BusinessException("审批人未配置");
}
Long approvalProfessionalId = Long.valueOf(paramValue);
BizApprovalEntity bizApprovalEntity = new BizApprovalEntity();
bizApprovalEntity.setSubmitter(userId);
bizApprovalEntity.setApprovalType(approvalType.getCode());
bizApprovalEntity.setApprovalStatus(ApprovalEnum.ApprovalStatusEnum.APPROVALING.getCode());
bizApprovalEntity.setApprovalProfessional(approvalProfessionalId);
bizApprovalEntity.setApprovalContent(approvalContent);
try {
bizApprovalService.save(bizApprovalEntity);
} catch (Exception e) {
logger.error("Submit Approval Error", e);
throw new BusinessException("提交审批单失败");
}
return ApprovalEnum.ApprovalStatusEnum.APPROVALING.getCode();
}
@Override
public String updateStatus(Long approvalId, ApprovalEnum.ApprovalStatusEnum approvalStatus, Long approvalProfessionalId) {
try {
BizApprovalEntity bizApprovalEntity = bizApprovalService.get(approvalId);
if (bizApprovalEntity == null) {
throw new BusinessException("审批单不存在");
}
bizApprovalEntity.setApprovalStatus(approvalStatus.getCode());
bizApprovalEntity.setApprovalProfessional(approvalProfessionalId);
bizApprovalService.update(bizApprovalEntity);
return approvalStatus.getCode();
} catch (Exception e) {
logger.error("Update Approval Status Error", e);
throw new BusinessException("更新审批单状态失败");
}
}
@Override
public void delete(Long approvalId, Long userId) {
try {
BizApprovalEntity bizApprovalEntity = bizApprovalService.get(approvalId);
if (bizApprovalEntity == null) {
throw new BusinessException("审批单不存在");
}
bizApprovalService.deletedById(approvalId);
} catch (Exception e) {
logger.error("Delete Approval Error", e);
throw new BusinessException("审批单删除失败");
}
}
@Override
public BizApprovalDto getDetail(Long approvalId) {
try {
BizApprovalEntity bizApprovalEntity = bizApprovalService.get(approvalId);
if (bizApprovalEntity == null) {
throw new BusinessException("审批单不存在");
}
return BizApprovalConvert.entityToDto(bizApprovalEntity);
} catch (Exception e) {
logger.error("Delete Approval Error", e);
throw new BusinessException("审批单删除失败");
}
}
@Override
public List<BizApprovalDto> getList(Long userId, ApprovalEnum.ApprovalTypeEnum approvalType, ApprovalEnum.ApprovalStatusEnum approvalStatus, PagingInfo pagingInfo) throws Exception {
BizApprovalEntity bizApprovalEntity = new BizApprovalEntity();
if (approvalStatus != null) {
bizApprovalEntity.setApprovalStatus(approvalStatus.getCode());
}
if (approvalType != null) {
bizApprovalEntity.setApprovalType(approvalType.getCode());
}
bizApprovalEntity.setSubmitter(userId);
bizApprovalEntity.setIsDeleted(CommonConstant.IsDeleted.N);
List<BizApprovalEntity> entities = bizApprovalService.findByExample(bizApprovalEntity, pagingInfo);
if (CollectionUtils.isNotEmpty(entities)) {
return entities.stream().map(BizApprovalConvert::entityToDto).collect(Collectors.toList());
}
return Collections.emptyList();
}
}
package cn.com.poc.approval.constants;
/**
* 审批相关常量枚举类
*
* @author alex.yao
* @date 2025/6/27
*/
public class ApprovalEnum {
/**
* 审批状态枚举类
*/
public enum ApprovalStatusEnum {
/**
* 审批中
*/
APPROVALING("APPROVALING", "审批中"),
/**
* 审批通过
*/
APPROVED("APPROVED", "审批通过"),
/**
* 审批拒绝
*/
REJECTED("REJECTED", "审批拒绝");
private final String code;
private final String desc;
ApprovalStatusEnum(String code, String desc) {
this.code = code;
this.desc = desc;
}
public String getCode() {
return code;
}
public String getDesc() {
return desc;
}
public static ApprovalStatusEnum getEnumByCode(String code) {
for (ApprovalStatusEnum approvalStatusEnum : ApprovalStatusEnum.values()) {
if (approvalStatusEnum.getCode().equals(code)) {
return approvalStatusEnum;
}
}
return null;
}
}
/**
* 审批类型枚举类
*/
public enum ApprovalTypeEnum {
/**
* 差旅审批单
*/
TRAVEL_BUSINESS("TRAVEL_BUSINESS", "差旅审批单"),
;
private final String code;
private final String desc;
ApprovalTypeEnum(String code, String desc) {
this.code = code;
this.desc = desc;
}
public String getCode() {
return code;
}
public String getDesc() {
return desc;
}
public static ApprovalTypeEnum getEnumByCode(String code) {
for (ApprovalTypeEnum approvalTypeEnum : ApprovalTypeEnum.values()) {
if (approvalTypeEnum.getCode().equals(code)) {
return approvalTypeEnum;
}
}
return null;
}
}
}
package cn.com.poc.approval.convert;
import cn.com.poc.approval.model.BizApprovalModel;
import cn.com.poc.approval.entity.BizApprovalEntity;
import cn.com.poc.approval.dto.BizApprovalDto;
public class BizApprovalConvert {
public static BizApprovalEntity modelToEntity(BizApprovalModel model) {
BizApprovalEntity entity = new BizApprovalEntity();
entity.setId(model.getId());
entity.setSubmitter(model.getSubmitter());
entity.setApprovalType(model.getApprovalType());
entity.setApprovalStatus(model.getApprovalStatus());
entity.setApprovalProfessional(model.getApprovalProfessional());
entity.setApprovalContent(model.getApprovalContent());
entity.setIsDeleted(model.getIsDeleted());
entity.setCreator(model.getCreator());
entity.setCreatedTime(model.getCreatedTime());
entity.setModifier(model.getModifier());
entity.setModifiedTime(model.getModifiedTime());
entity.setSysVersion(model.getSysVersion());
return entity;
}
public static BizApprovalModel entityToModel(BizApprovalEntity entity) {
BizApprovalModel model = new BizApprovalModel();
model.setId(entity.getId());
model.setSubmitter(entity.getSubmitter());
model.setApprovalType(entity.getApprovalType());
model.setApprovalStatus(entity.getApprovalStatus());
model.setApprovalProfessional(entity.getApprovalProfessional());
model.setApprovalContent(entity.getApprovalContent());
model.setIsDeleted(entity.getIsDeleted());
model.setCreator(entity.getCreator());
model.setCreatedTime(entity.getCreatedTime());
model.setModifier(entity.getModifier());
model.setModifiedTime(entity.getModifiedTime());
model.setSysVersion(entity.getSysVersion());
return model;
}
public static BizApprovalDto entityToDto(BizApprovalEntity entity) {
BizApprovalDto dto = new BizApprovalDto();
dto.setId(entity.getId());
dto.setSubmitter(entity.getSubmitter());
dto.setApprovalType(entity.getApprovalType());
dto.setApprovalStatus(entity.getApprovalStatus());
dto.setApprovalProfessional(entity.getApprovalProfessional());
dto.setApprovalContent(entity.getApprovalContent());
dto.setCreatedTime(entity.getCreatedTime());
dto.setModifiedTime(entity.getModifiedTime());
return dto;
}
public static BizApprovalEntity dtoToEntity(BizApprovalDto dto) {
BizApprovalEntity entity = new BizApprovalEntity();
entity.setId(dto.getId());
entity.setSubmitter(dto.getSubmitter());
entity.setApprovalType(dto.getApprovalType());
entity.setApprovalStatus(dto.getApprovalStatus());
entity.setApprovalProfessional(dto.getApprovalProfessional());
entity.setApprovalContent(dto.getApprovalContent());
entity.setCreatedTime(dto.getCreatedTime());
entity.setModifiedTime(dto.getModifiedTime());
return entity;
}
}
\ No newline at end of file
package cn.com.poc.approval.dto;
public class BizApprovalDto {
/** id
*
*/
private java.lang.Long id;
public java.lang.Long getId(){
return this.id;
}
public void setId(java.lang.Long id){
this.id = id;
}
/** submitter
*提交人ID
*/
private java.lang.Long submitter;
public java.lang.Long getSubmitter(){
return this.submitter;
}
public void setSubmitter(java.lang.Long submitter){
this.submitter = submitter;
}
/** approval_type
*审批类型
*/
private java.lang.String approvalType;
public java.lang.String getApprovalType(){
return this.approvalType;
}
public void setApprovalType(java.lang.String approvalType){
this.approvalType = approvalType;
}
/** approval_status
*审批状态
*/
private java.lang.String approvalStatus;
public java.lang.String getApprovalStatus(){
return this.approvalStatus;
}
public void setApprovalStatus(java.lang.String approvalStatus){
this.approvalStatus = approvalStatus;
}
/** approval_professional
*审批人ID
*/
private java.lang.Long approvalProfessional;
public java.lang.Long getApprovalProfessional(){
return this.approvalProfessional;
}
public void setApprovalProfessional(java.lang.Long approvalProfessional){
this.approvalProfessional = approvalProfessional;
}
/** approval_content
*审核单信息
*/
private java.lang.String approvalContent;
public java.lang.String getApprovalContent(){
return this.approvalContent;
}
public void setApprovalContent(java.lang.String approvalContent){
this.approvalContent = approvalContent;
}
/** CREATED_TIME
*创建时间
*/
private java.util.Date createdTime;
public java.util.Date getCreatedTime(){
return this.createdTime;
}
public void setCreatedTime(java.util.Date createdTime){
this.createdTime = createdTime;
}
/** MODIFIED_TIME
*修改时间
*/
private java.util.Date modifiedTime;
public java.util.Date getModifiedTime(){
return this.modifiedTime;
}
public void setModifiedTime(java.util.Date modifiedTime){
this.modifiedTime = modifiedTime;
}
}
\ No newline at end of file
package cn.com.poc.approval.entity;
public class BizApprovalEntity {
private static final long serialVersionUID = 1L;
/** id
*
*/
private java.lang.Long id;
public java.lang.Long getId(){
return this.id;
}
public void setId(java.lang.Long id){
this.id = id;
}
/** submitter
*提交人ID
*/
private java.lang.Long submitter;
public java.lang.Long getSubmitter(){
return this.submitter;
}
public void setSubmitter(java.lang.Long submitter){
this.submitter = submitter;
}
/** approval_type
*审批类型
*/
private java.lang.String approvalType;
public java.lang.String getApprovalType(){
return this.approvalType;
}
public void setApprovalType(java.lang.String approvalType){
this.approvalType = approvalType;
}
/** approval_status
*审批状态
*/
private java.lang.String approvalStatus;
public java.lang.String getApprovalStatus(){
return this.approvalStatus;
}
public void setApprovalStatus(java.lang.String approvalStatus){
this.approvalStatus = approvalStatus;
}
/** approval_professional
*审批人ID
*/
private java.lang.Long approvalProfessional;
public java.lang.Long getApprovalProfessional(){
return this.approvalProfessional;
}
public void setApprovalProfessional(java.lang.Long approvalProfessional){
this.approvalProfessional = approvalProfessional;
}
/** approval_content
*审核单信息
*/
private java.lang.String approvalContent;
public java.lang.String getApprovalContent(){
return this.approvalContent;
}
public void setApprovalContent(java.lang.String approvalContent){
this.approvalContent = approvalContent;
}
/** is_deleted
*是否删除 1、Y 是 2、N 否
*/
private java.lang.String isDeleted;
public java.lang.String getIsDeleted(){
return this.isDeleted;
}
public void setIsDeleted(java.lang.String isDeleted){
this.isDeleted = isDeleted;
}
/** CREATOR
*创建人
*/
private java.lang.String creator;
public java.lang.String getCreator(){
return this.creator;
}
public void setCreator(java.lang.String creator){
this.creator = creator;
}
/** CREATED_TIME
*创建时间
*/
private java.util.Date createdTime;
public java.util.Date getCreatedTime(){
return this.createdTime;
}
public void setCreatedTime(java.util.Date createdTime){
this.createdTime = createdTime;
}
/** MODIFIER
*修改人
*/
private java.lang.String modifier;
public java.lang.String getModifier(){
return this.modifier;
}
public void setModifier(java.lang.String modifier){
this.modifier = modifier;
}
/** MODIFIED_TIME
*修改时间
*/
private java.util.Date modifiedTime;
public java.util.Date getModifiedTime(){
return this.modifiedTime;
}
public void setModifiedTime(java.util.Date modifiedTime){
this.modifiedTime = modifiedTime;
}
/** SYS_VERSION
*乐观锁,版本号
*/
private java.lang.Integer sysVersion;
public java.lang.Integer getSysVersion(){
return this.sysVersion;
}
public void setSysVersion(java.lang.Integer sysVersion){
this.sysVersion = sysVersion;
}
}
\ No newline at end of file
package cn.com.poc.approval.model;
import java.io.Serializable;
import cn.com.yict.framemax.data.model.BaseModelClass;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Id;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.Version;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
/**
* Model class for biz_approval
* 审批单
*/
@Entity
@Table(name = "biz_approval")
@DynamicInsert
@DynamicUpdate
public class BizApprovalModel extends BaseModelClass implements Serializable {
private static final long serialVersionUID = 1L;
/** id
*
*/
private java.lang.Long id;
@Column(name = "id",length = 19)
@Id @GeneratedValue(strategy = GenerationType.AUTO)
public java.lang.Long getId(){
return this.id;
}
public void setId(java.lang.Long id){
this.id = id;
super.addValidField("id");
}
/** submitter
*提交人ID
*/
private java.lang.Long submitter;
@Column(name = "submitter",length = 19)
public java.lang.Long getSubmitter(){
return this.submitter;
}
public void setSubmitter(java.lang.Long submitter){
this.submitter = submitter;
super.addValidField("submitter");
}
/** approval_type
*审批类型
*/
private java.lang.String approvalType;
@Column(name = "approval_type",length = 100)
public java.lang.String getApprovalType(){
return this.approvalType;
}
public void setApprovalType(java.lang.String approvalType){
this.approvalType = approvalType;
super.addValidField("approvalType");
}
/** approval_status
*审批状态
*/
private java.lang.String approvalStatus;
@Column(name = "approval_status",length = 100)
public java.lang.String getApprovalStatus(){
return this.approvalStatus;
}
public void setApprovalStatus(java.lang.String approvalStatus){
this.approvalStatus = approvalStatus;
super.addValidField("approvalStatus");
}
/** approval_professional
*审批人ID
*/
private java.lang.Long approvalProfessional;
@Column(name = "approval_professional",length = 19)
public java.lang.Long getApprovalProfessional(){
return this.approvalProfessional;
}
public void setApprovalProfessional(java.lang.Long approvalProfessional){
this.approvalProfessional = approvalProfessional;
super.addValidField("approvalProfessional");
}
/** approval_content
*审核单信息
*/
private java.lang.String approvalContent;
@Column(name = "approval_content",length = 1073741824)
public java.lang.String getApprovalContent(){
return this.approvalContent;
}
public void setApprovalContent(java.lang.String approvalContent){
this.approvalContent = approvalContent;
super.addValidField("approvalContent");
}
/** is_deleted
*是否删除 1、Y 是 2、N 否
*/
private java.lang.String isDeleted;
@Column(name = "is_deleted",length = 1)
public java.lang.String getIsDeleted(){
return this.isDeleted;
}
public void setIsDeleted(java.lang.String isDeleted){
this.isDeleted = isDeleted;
super.addValidField("isDeleted");
}
/** CREATOR
*创建人
*/
private java.lang.String creator;
@Column(name = "CREATOR",length = 225)
public java.lang.String getCreator(){
return this.creator;
}
public void setCreator(java.lang.String creator){
this.creator = creator;
super.addValidField("creator");
}
/** CREATED_TIME
*创建时间
*/
private java.util.Date createdTime;
@Column(name = "CREATED_TIME",length = 19)
public java.util.Date getCreatedTime(){
return this.createdTime;
}
public void setCreatedTime(java.util.Date createdTime){
this.createdTime = createdTime;
super.addValidField("createdTime");
}
/** MODIFIER
*修改人
*/
private java.lang.String modifier;
@Column(name = "MODIFIER",length = 225)
public java.lang.String getModifier(){
return this.modifier;
}
public void setModifier(java.lang.String modifier){
this.modifier = modifier;
super.addValidField("modifier");
}
/** MODIFIED_TIME
*修改时间
*/
private java.util.Date modifiedTime;
@Column(name = "MODIFIED_TIME",length = 19)
public java.util.Date getModifiedTime(){
return this.modifiedTime;
}
public void setModifiedTime(java.util.Date modifiedTime){
this.modifiedTime = modifiedTime;
super.addValidField("modifiedTime");
}
/** SYS_VERSION
*乐观锁,版本号
*/
private java.lang.Integer sysVersion;
@Column(name = "SYS_VERSION",length = 10)
@Version
public java.lang.Integer getSysVersion(){
return this.sysVersion;
}
public void setSysVersion(java.lang.Integer sysVersion){
this.sysVersion = sysVersion;
super.addValidField("sysVersion");
}
}
\ No newline at end of file
package cn.com.poc.approval.repository;
import cn.com.yict.framemax.data.repository.Repository;
import cn.com.poc.approval.model.BizApprovalModel;
public interface BizApprovalRepository extends Repository<BizApprovalModel,java.lang.Long> {
}
\ No newline at end of file
package cn.com.poc.approval.rest;
import cn.com.poc.approval.dto.BizApprovalDto;
import cn.com.yict.framemax.core.rest.BaseRest;
import cn.com.yict.framemax.data.model.PagingInfo;
import cn.com.yict.framemax.web.permission.Access;
import cn.com.yict.framemax.web.permission.Permission;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* 审批服务接口
*
* @author alex.yao
* @date 2025/6/27
*/
@Permission(Access.Safety)
public interface ApprovalRest extends BaseRest {
/**
* 提交审批单
*/
String submit(@RequestBody BizApprovalDto dto);
/**
* 更新审批状态
*/
String updateStatus(@RequestBody BizApprovalDto dto);
/**
* 删除审批单
*/
void delete(@RequestParam Long approvalId);
/**
* 获取审批单详情
*/
BizApprovalDto getDetail(@RequestParam Long approvalId);
/**
* 获取审批单列表
*/
List<BizApprovalDto> getList(@RequestBody BizApprovalDto dto, PagingInfo pagingInfo);
}
package cn.com.poc.approval.rest.impl;
import cn.com.poc.approval.aggregate.ApprovalService;
import cn.com.poc.approval.constants.ApprovalEnum;
import cn.com.poc.approval.dto.BizApprovalDto;
import cn.com.poc.approval.rest.ApprovalRest;
import cn.com.poc.common.utils.Assert;
import cn.com.poc.common.utils.BlContext;
import cn.com.poc.common.utils.StringUtils;
import cn.com.poc.support.security.oauth.entity.UserBaseEntity;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.data.model.PagingInfo;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
* @author alex.yao
* @date 2025/6/27
*/
@Component
public class ApprovalRestImpl implements ApprovalRest {
@Resource
private ApprovalService approvalService;
@Override
public String submit(BizApprovalDto dto) {
Assert.notNull(dto, "approvalDto can not be null");
Assert.notNull(dto.getApprovalType(), "approvalType can not be null");
Assert.notNull(dto.getApprovalContent(), "approvalContent can not be null");
ApprovalEnum.ApprovalTypeEnum approvalType = ApprovalEnum.ApprovalTypeEnum.getEnumByCode(dto.getApprovalType());
if (approvalType == null) {
throw new BusinessException("approvalType is not valid");
}
UserBaseEntity userBaseEntity = BlContext.getCurrentUserNotException();
if (userBaseEntity == null) {
throw new BusinessException("用户未登录");
}
return approvalService.submit(approvalType, dto.getApprovalContent(), userBaseEntity.getUserId());
}
@Override
public String updateStatus(BizApprovalDto dto) {
Assert.notNull(dto, "approvalDto can not be null");
Assert.notNull(dto.getApprovalStatus(), "approval status can not be null");
Assert.notNull(dto.getId(), "id can not be null");
ApprovalEnum.ApprovalStatusEnum approvalStatusEnum = ApprovalEnum.ApprovalStatusEnum.getEnumByCode(dto.getApprovalStatus());
if (approvalStatusEnum == null) {
throw new BusinessException("approval status is not valid");
}
UserBaseEntity userBaseEntity = BlContext.getCurrentUserNotException();
if (userBaseEntity == null) {
throw new BusinessException("用户未登录");
}
return approvalService.updateStatus(dto.getId(), approvalStatusEnum, userBaseEntity.getUserId());
}
@Override
public void delete(Long approvalId) {
Assert.notNull(approvalId, "approvalId can not be null");
UserBaseEntity userBaseEntity = BlContext.getCurrentUserNotException();
if (userBaseEntity == null) {
throw new BusinessException("用户未登录");
}
approvalService.delete(approvalId, userBaseEntity.getUserId());
}
@Override
public BizApprovalDto getDetail(Long approvalId) {
Assert.notNull(approvalId, "approvalId can not be null");
return approvalService.getDetail(approvalId);
}
@Override
public List<BizApprovalDto> getList(BizApprovalDto dto, PagingInfo pagingInfo) {
Assert.notNull(dto, "approvalDto can not be null");
UserBaseEntity userBaseEntity = BlContext.getCurrentUserNotException();
if (userBaseEntity == null) {
throw new BusinessException("用户未登录");
}
ApprovalEnum.ApprovalTypeEnum approvalTypeEnum = null;
ApprovalEnum.ApprovalStatusEnum approvalStatusEnum = null;
if (StringUtils.isNotBlank(dto.getApprovalType())) {
approvalTypeEnum = ApprovalEnum.ApprovalTypeEnum.getEnumByCode(dto.getApprovalType());
}
if (StringUtils.isNotBlank(dto.getApprovalStatus())) {
approvalStatusEnum = ApprovalEnum.ApprovalStatusEnum.getEnumByCode(dto.getApprovalStatus());
}
return approvalService.getList(userBaseEntity.getUserId(), approvalTypeEnum, approvalStatusEnum, pagingInfo);
}
}
package cn.com.poc.approval.service;
import cn.com.yict.framemax.core.service.BaseService;
import cn.com.poc.approval.entity.BizApprovalEntity;
import cn.com.yict.framemax.data.model.PagingInfo;
import java.util.Collection;
import java.util.List;
public interface BizApprovalService extends BaseService {
BizApprovalEntity get(java.lang.Long id) throws Exception;
List<BizApprovalEntity> findByExample(BizApprovalEntity example,PagingInfo pagingInfo) throws Exception;
BizApprovalEntity save(BizApprovalEntity entity) throws Exception;
BizApprovalEntity update(BizApprovalEntity entity) throws Exception;
void deletedById(java.lang.Long id) throws Exception;
}
\ No newline at end of file
package cn.com.poc.approval.service.impl;
import cn.com.yict.framemax.core.service.impl.BaseServiceImpl;
import cn.com.poc.approval.service.BizApprovalService;
import cn.com.poc.approval.model.BizApprovalModel;
import cn.com.poc.approval.entity.BizApprovalEntity;
import cn.com.poc.approval.convert.BizApprovalConvert;
import cn.com.poc.approval.repository.BizApprovalRepository;
import cn.com.yict.framemax.data.model.PagingInfo;
import org.springframework.stereotype.Service;
import org.apache.commons.collections4.CollectionUtils;
import java.util.ArrayList;
import java.util.stream.Collectors;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.util.Assert;
@Service
public class BizApprovalServiceImpl extends BaseServiceImpl
implements BizApprovalService {
@Resource
private BizApprovalRepository repository;
public BizApprovalEntity get(java.lang.Long id) throws Exception {
Assert.notNull(id);
BizApprovalModel model = this.repository.get(id);
if (model == null) {
return null;
}
if ("Y".equals(model.getIsDeleted())) {
return null;
}
return BizApprovalConvert.modelToEntity(model);
}
public List<BizApprovalEntity> findByExample(BizApprovalEntity example, PagingInfo pagingInfo) throws Exception {
List<BizApprovalEntity> result = new ArrayList<BizApprovalEntity>();
BizApprovalModel model = new BizApprovalModel();
if (example != null) {
model = BizApprovalConvert.entityToModel(example);
}
model.setIsDeleted("N");
List<BizApprovalModel> models = this.repository.findByExample(model, "id desc", pagingInfo);
if (CollectionUtils.isNotEmpty(models)) {
result = models.stream().map(BizApprovalConvert::modelToEntity).collect(Collectors.toList());
}
return result;
}
public BizApprovalEntity save(BizApprovalEntity entity) throws Exception {
Assert.notNull(entity);
entity.setId(null);
entity.setIsDeleted("N");
BizApprovalModel model = BizApprovalConvert.entityToModel(entity);
BizApprovalModel saveModel = this.repository.save(model);
return BizApprovalConvert.modelToEntity(saveModel);
}
public BizApprovalEntity update(BizApprovalEntity entity) throws Exception {
Assert.notNull(entity);
Assert.notNull(entity.getId(), "update pk can not be null");
BizApprovalModel model = this.repository.get(entity.getId());
if (entity.getSubmitter() != null) {
model.setSubmitter(entity.getSubmitter());
}
if (entity.getApprovalType() != null) {
model.setApprovalType(entity.getApprovalType());
}
if (entity.getApprovalStatus() != null) {
model.setApprovalStatus(entity.getApprovalStatus());
}
if (entity.getApprovalProfessional() != null) {
model.setApprovalProfessional(entity.getApprovalProfessional());
}
if (entity.getIsDeleted() != null) {
model.setIsDeleted(entity.getIsDeleted());
}
if (entity.getCreator() != null) {
model.setCreator(entity.getCreator());
}
if (entity.getCreatedTime() != null) {
model.setCreatedTime(entity.getCreatedTime());
}
if (entity.getModifier() != null) {
model.setModifier(entity.getModifier());
}
if (entity.getModifiedTime() != null) {
model.setModifiedTime(entity.getModifiedTime());
}
if (entity.getSysVersion() != null) {
model.setSysVersion(entity.getSysVersion());
}
BizApprovalModel saveModel = this.repository.save(model);
return BizApprovalConvert.modelToEntity(saveModel);
}
public void deletedById(java.lang.Long id) throws Exception {
Assert.notNull(id);
BizApprovalModel model = this.repository.get(id);
if (model != null) {
if ("N".equals(model.getIsDeleted())) {
model.setIsDeleted("Y");
this.repository.save(model);
}
}
}
}
\ No newline at end of file
......@@ -25,10 +25,9 @@ import java.util.*;
public class AiDialoguesKnowledgeRestImpl implements AiDialoguesKnowledgeRest {
List<String> organization = new ArrayList<String>() {{
add("组织1");
add("组织2");
add("组织3");
add("组织4");
add("集团");
add("企业");
add("个人");
}};
@Resource
......@@ -45,7 +44,6 @@ public class AiDialoguesKnowledgeRestImpl implements AiDialoguesKnowledgeRest {
KnowledgeInfosQueryCondition condition = new KnowledgeInfosQueryCondition();
condition.setMemberId(userBaseEntity.getUserId().toString());
// condition.setQuery();
condition.setTrainStatus(KnowledgeConstant.TrainStatus.COMPLETE);
condition.setKnowledgeType(KnowledgeConstant.KnowledgeType.BASE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment