package com.jeeplus.sys.feign;

import com.alibaba.fastjson.JSON;
import com.jeeplus.sys.domain.Post;
import com.jeeplus.sys.service.PostService;
import com.jeeplus.sys.service.dto.PostDTO;
import com.jeeplus.sys.service.mapstruct.PostWrapper;
import com.jeeplus.sys.utils.TenantUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PostApiImpl implements IPostApi {

    @Autowired
    PostService postService;


    @Override
    public PostDTO getPostDTOByName(String name) {
        return postService.getPostDTOByName(name);
        // return PostWrapper.INSTANCE.toDTO ( postService.lambdaQuery ( ).eq ( Post::getTenantId, TenantUtils.getTenantId ( ) ).eq ( Post::getName, name ).one ( ) );
    }

    @Override
    public String getPostDTOByNameJSON(String name) {
        return JSON.toJSONString(postService.getPostDTOByName(name));

    }
}
