package com.seer.teach.user.admin.api;

import com.seer.teach.user.api.UserRelationServiceApi;
import com.seer.teach.user.api.dto.UserRelationDTO;
import com.seer.teach.user.convert.UserRelationConvert;
import com.seer.teach.user.entity.UserRelationEntity;
import com.seer.teach.user.service.IUserRelationService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RequiredArgsConstructor
@RestController
public class UserRelationServiceApiImpl implements UserRelationServiceApi {

    private final IUserRelationService userRelationService;

    @Override
    public boolean saveUserRelation(UserRelationDTO userRelationDTO) {
        log.info("保存用户关系:{}", userRelationDTO);
        UserRelationEntity userRelation = UserRelationConvert.INSTANCE.convertOne(userRelationDTO);
        return userRelationService.save(userRelation);
    }

    @Override
    public boolean deleteUserRelation(UserRelationDTO userRelationDTO) {
        log.info("删除用户关系:{}", userRelationDTO);
        UserRelationEntity userRelation = UserRelationConvert.INSTANCE.convertOne(userRelationDTO);
        return userRelationService.deleteUserRelation(userRelation);
    }
}
