package ${packageFeignName};
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.${businessName}.${ClassName}Pdu;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.feign.IFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * ${functionName} Feign接口
 * @author ${author}
 * @date ${datetime}
 */
@FeignClient(name = "${code}", path = "${path}", fallbackFactory = ${ClassName}FeignFallbackFactory.class)
public interface I${ClassName}Feign extends IFeign {


    /**
     * 查看${functionName}列表
     *
     * @param ${className}Pdu
     * @return
     */
    @PostMapping(value = "/${RequestMapping}/list")
    Rest<RespData<List<${ClassName}Pdu>>> list(@RequestBody ${ClassName}Pdu ${className}Pdu);


    /**
     * 查看${functionName}
     *
     * @param id
     * @return
     */
    @GetMapping(value = "/${RequestMapping}/info")
    Rest<${ClassName}Pdu> info(@RequestParam(value = "id") Long id);

    /**
     * 删除${functionName}
     *
     * @param ids
     * @return
     */
    @GetMapping(value = "/${RequestMapping}/delete")
    Rest<Void> delete(Long[] ids,@RequestHeader("Authorization") String authorization);


    /**
     * ${functionName}保存更新
     *
     * @param ${className}Pdu
     * @return
     */
    @PostMapping(value = "/${RequestMapping}/save")
    Rest<RespData<${ClassName}Pdu>> save(@RequestBody ${ClassName}Pdu ${className}Pdu,@RequestHeader("Authorization") String authorization);


}


@Slf4j
@Component
class ${ClassName}FeignFallbackFactory implements FallbackFactory<I${ClassName}Feign> {
    @Override
    public I${ClassName}Feign create(Throwable t) {
        return new I${ClassName}Feign() {
            @Override
            public Rest<RespData<List<${ClassName}Pdu>>> list(${ClassName}Pdu ${className}Pdu) {
               return Rest.fail("暂时无法获取${functionName}列表，请稍后再试!");
            }

            @Override
            public Rest<${ClassName}Pdu> info(Long id) {
               return Rest.fail("暂时无法获取${functionName}详细，请稍后再试!");
            }

            @Override
            public Rest<Void> delete(Long[] ids, String authorization) {
                return Rest.fail("暂时无法删除${functionName}，请稍后再试!");
            }

            @Override
            public Rest<RespData<${ClassName}Pdu>> save(${ClassName}Pdu ${className}Pdu, String authorization) {
                return Rest.fail("暂时无法保存${functionName}，请稍后再试!");
            }
        };
    }
}








