package org.springblade.application.feign;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor;
import org.springblade.application.pojo.entity.ApplicationInfoEntity;
import org.springblade.application.service.IApplicationService;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@AllArgsConstructor
public class ApplicationClientImpl implements ApplicationClient {

	private IApplicationService applicationService;

	@Override
	@PostMapping(API_PREFIX + "/page")
	public R page(@RequestParam Map<String, Object> params, Query query) {
		IPage<ApplicationInfoEntity> pages = applicationService.getPage(Condition.getPage(query), params);
		return R.data(pages);
	}

	@Override
	@PostMapping(API_PREFIX + "/detail")
	public R detail(ApplicationInfoEntity applicationInfoEntity) {
		ApplicationInfoEntity detail = applicationService.getOne(Condition.getQueryWrapper(applicationInfoEntity));
		return R.data(detail);
	}
}
