package com.pj.tb_cooperative;

import com.pj.api.dto.CooperativeDto;
import com.pj.utils.sg.AjaxJson;
import com.pj.utils.so.SoMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * Controller: tb_cooperative -- 合作社
 * @author lbl
 */
@RestController
@RequestMapping("/app/TbCooperative/")
public class TbCooperativeAppController {

	/** 底层 Service 对象 */
	@Autowired
	TbCooperativeService tbCooperativeService;

	/** 查 - 根据id */
	@RequestMapping("getById")
	public AjaxJson getById(Long id){
		TbCooperative t = tbCooperativeService.getById(id);
		return AjaxJson.getSuccessData(t);
	}

	/** 查集合 - 根据条件（参数为空时代表忽略指定条件） */
	@RequestMapping("getList")
	public AjaxJson getList() {
		SoMap so = SoMap.getRequestSoMap();
		List<TbCooperative> list = tbCooperativeService.getList(so.startPage());
		return AjaxJson.getPageData(so.getDataCount(), list);
	}


	/*------            正常业务👆👆    rpc远程调用👇👇                         -----------*/

	/** 查 - 根据合作社Id */
	@RequestMapping("rpc/getCooperativeById")
	public CooperativeDto getCooperativeById(@RequestParam("id")Long cooperativeId) {
		CooperativeDto dto = tbCooperativeService.getCooperativeById(cooperativeId);
		return dto;
	}

	/** 合作社保存银行卡信息 */
	@RequestMapping("rpc/saveBankInfo")
	public boolean saveBankByCooperative(@RequestParam("id")Long id, @RequestParam("bankName")String bankName, @RequestParam("bankAccount")String bankAccount) {
		return tbCooperativeService.saveBankByCooperative(id, bankName, bankAccount);
	}

}
