Skip to content

Commit

Permalink
feat: add mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
wildeslam committed Jun 28, 2024
1 parent 2c26824 commit e6d5697
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 50 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.arextest.web.api.service.beans.auto;

import org.springframework.context.annotation.Configuration;

/**
* @author wildeslam.
* @create 2024/6/27 20:20
*/
@Configuration
public class SystemConfigAutoConfiguration {


}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
import com.arextest.web.model.mapper.FSFolderMapper;
import com.arextest.web.model.mapper.FSInterfaceMapper;
import com.arextest.web.model.mapper.FSNodeMapper;
import com.arextest.web.model.mapper.FSRequestMapper;
import com.arextest.web.model.mapper.FSTreeMapper;
import com.arextest.web.model.mapper.UserWorkspaceMapper;
import com.arextest.web.model.mapper.WorkspaceMapper;
Expand Down Expand Up @@ -882,16 +883,21 @@ public List<String> addItemsByAppAndInterface(FSAddItemsByAppAndInterfaceRequest
path.addAll(Arrays.asList(defaultPath));

// save interface
FSSaveInterfaceRequestType saveInterfaceRequest = buildSaveInterfaceRequest(request,
defaultPath[1]);
FSSaveInterfaceRequestType saveInterfaceRequest = FSRequestMapper.INSTANCE.buildSaveInterfaceRequest(
request);
saveInterfaceRequest.setId(defaultPath[1]);
saveInterface(saveInterfaceRequest, userName);

//save case
FSSaveCaseRequestType saveCaseRequest = buildSaveCaseRequest(request, defaultPath[2]);
FSSaveCaseRequestType saveCaseRequest = FSRequestMapper.INSTANCE.buildSaveCaseRequest(
request);
saveCaseRequest.setId(defaultPath[2]);
saveCase(saveCaseRequest, userName);

//pin case
FSPinMockRequestType pinMockRequest = buildPinMockRequest(request, defaultPath[2]);
FSPinMockRequestType pinMockRequest = FSRequestMapper.INSTANCE.buildPinMockRequest(request);
pinMockRequest.setInfoId(defaultPath[2]);
pinMockRequest.setNodeType(FSInfoItem.CASE);
pinMock(pinMockRequest);
}

Expand Down Expand Up @@ -1567,50 +1573,4 @@ public List<FSPathInfoDto> getAbsolutePathInfo(String infoId, Integer nodeType)
}
return path;
}

private FSSaveInterfaceRequestType buildSaveInterfaceRequest(
FSAddItemsByAppAndInterfaceRequestType in, String id) {
FSSaveInterfaceRequestType out = new FSSaveInterfaceRequestType();
out.setAddress(in.getAddress());
out.setBody(in.getBody());
out.setId(id);
out.setHeaders(in.getHeaders());
out.setLabelIds(in.getLabelIds());
out.setAuth(in.getAuth());
out.setDescription(in.getDescription());
out.setParams(in.getParams());
out.setWorkspaceId(in.getWorkspaceId());
out.setPreRequestScripts(in.getPreRequestScripts());
out.setTestAddress(in.getTestAddress());
out.setTestScripts(in.getTestScripts());
return out;
}

private FSSaveCaseRequestType buildSaveCaseRequest(FSAddItemsByAppAndInterfaceRequestType in,
String id) {
FSSaveCaseRequestType out = new FSSaveCaseRequestType();
out.setId(id);
out.setAddress(in.getAddress());
out.setBody(in.getBody());
out.setHeaders(in.getHeaders());
out.setLabelIds(in.getLabelIds());
out.setAuth(in.getAuth());
out.setDescription(in.getDescription());
out.setParams(in.getParams());
out.setWorkspaceId(in.getWorkspaceId());
out.setPreRequestScripts(in.getPreRequestScripts());
out.setTestAddress(in.getTestAddress());
out.setTestScripts(in.getTestScripts());
return out;
}

private FSPinMockRequestType buildPinMockRequest(FSAddItemsByAppAndInterfaceRequestType in,
String id) {
FSPinMockRequestType out = new FSPinMockRequestType();
out.setNodeType(FSInfoItem.CASE);
out.setRecordId(in.getNodeName());
out.setWorkspaceId(in.getWorkspaceId());
out.setInfoId(id);
return out;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.arextest.web.model.mapper;

import com.arextest.web.model.contract.contracts.filesystem.FSAddItemsByAppAndInterfaceRequestType;
import com.arextest.web.model.contract.contracts.filesystem.FSPinMockRequestType;
import com.arextest.web.model.contract.contracts.filesystem.FSSaveCaseRequestType;
import com.arextest.web.model.contract.contracts.filesystem.FSSaveInterfaceRequestType;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
* @author wildeslam.
* @create 2024/6/28 11:36
*/
@Mapper
public interface FSRequestMapper {

FSRequestMapper INSTANCE = Mappers.getMapper(FSRequestMapper.class);

FSSaveInterfaceRequestType buildSaveInterfaceRequest(
FSAddItemsByAppAndInterfaceRequestType request);

FSSaveCaseRequestType buildSaveCaseRequest(FSAddItemsByAppAndInterfaceRequestType request);

@Mapping(target = "recordId", source = "nodeName")
FSPinMockRequestType buildPinMockRequest(FSAddItemsByAppAndInterfaceRequestType request);

}

0 comments on commit e6d5697

Please sign in to comment.