dev
minuk926 3 years ago
parent 3b55c97e0f
commit 8cb4fe3573

@ -0,0 +1,26 @@
package com.xit.biz.cmm.resolver;
//import com.coxautodev.graphql.tools.GraphQLMutationResolver;
import com.xit.biz.cmm.dto.CmmUserDto;
import com.xit.biz.cmm.dto.struct.CmmUserMapstruct;
import com.xit.biz.cmm.entity.CmmUser;
import com.xit.biz.cmm.repository.ICmmUserRepository;
import graphql.kickstart.tools.GraphQLMutationResolver;
import lombok.RequiredArgsConstructor;
import org.mapstruct.factory.Mappers;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@Component
@RequiredArgsConstructor
@Transactional(rollbackFor = Exception.class)
public class CmmUserMutation implements GraphQLMutationResolver {
private final ICmmUserRepository cmmUserRepository;
private final CmmUserMapstruct cmmUserMapstruct = Mappers.getMapper(CmmUserMapstruct.class);
public CmmUser createUser(final CmmUserDto cmmUserDto){
CmmUser cmmUser = cmmUserRepository.save(cmmUserMapstruct.toEntity(cmmUserDto));
//return cmmUserMapstruct.toDto(cmmUser);
return cmmUser;
}
}

@ -0,0 +1,30 @@
package com.xit.biz.cmm.resolver;
//import com.coxautodev.graphql.tools.GraphQLQueryResolver;
import com.xit.biz.cmm.dto.CmmUserDto;
import com.xit.biz.cmm.dto.struct.CmmUserMapstruct;
import com.xit.biz.cmm.entity.CmmUser;
import com.xit.biz.cmm.repository.ICmmUserRepository;
import graphql.kickstart.tools.GraphQLQueryResolver;
import lombok.RequiredArgsConstructor;
import org.mapstruct.factory.Mappers;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.lang.annotation.Annotation;
@Component
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class CmmUserQuery implements GraphQLQueryResolver {
private final ICmmUserRepository cmmUserRepository;
private final CmmUserMapstruct cmmUserMapstruct = Mappers.getMapper(CmmUserMapstruct.class);
public CmmUser getUserByUserId(final String userId){
CmmUser cmmUser = cmmUserRepository.findByUserId(userId).orElse(null);
//return cmmUserMapstruct.toDto(cmmUser);
return cmmUser;
}
}
Loading…
Cancel
Save