java3个实现类的一些问题

原创
2020/12/09 00:22
阅读数 466

接口类

package com.fc.test.service.impl;

/**
 * @ClassName
 * @Description 请描述类的业务用途
 * @Author fuce
 * @Date 2020/12/9 10:42
 * @Version 1.0
 **/
public interface PayNotifyCallbakHandler {

    /**
     * 验签逻辑
     * @param params 回调报文
     * @return
     */
    Boolean verifyNotify(String params);
}

 

抽象类

package com.fc.test.service.impl;

/**
 * @ClassName
 * @Description 请描述类的业务用途
 * @Author fuce
 * @Date 2020/12/9 10:42
 * @Version 1.0
 **/
public abstract class AbstractPayNotifyCallbakHandler  implements  PayNotifyCallbakHandler{
    public void play(String str) {
        verifyNotify(str);
    }
}

3个实现类

package com.fc.test.service.impl;

import org.springframework.stereotype.Service;

/**
 * @ClassName
 * @Description 请描述类的业务用途
 * @Author fuce
 * @Date 2020/12/9 10:44
 * @Version 1.0
 **/
@Service("AliCallback")
public class Ali extends AbstractPayNotifyCallbakHandler{

    @Override
    public Boolean verifyNotify(String params) {
        System.out.println("Ali实现类"+params);
        return true;
    }

}
package com.fc.test.service.impl;

import org.springframework.stereotype.Service;

/**
 * @ClassName
 * @Description 请描述类的业务用途
 * @Author fuce
 * @Date 2020/12/9 10:44
 * @Version 1.0
 **/
@Service("BaiduCallback")
public class Baidu extends AbstractPayNotifyCallbakHandler{

    @Override
    public Boolean verifyNotify(String params) {
        System.out.println("Baidu实现类"+params);
        return true;
    }

}
package com.fc.test.service.impl;

import org.springframework.stereotype.Service;

/**
 * @ClassName
 * @Description 请描述类的业务用途
 * @Author fuce
 * @Date 2020/12/9 10:44
 * @Version 1.0
 **/
@Service("TaobaoCallback")
public class Taobao extends AbstractPayNotifyCallbakHandler{

    @Override
    public Boolean verifyNotify(String params) {
        System.out.println("Taobao实现类"+params);
        return true;
    }

}

 

controller

package com.fc.test.controller.admin;

import com.fc.test.service.impl.PayNotifyCallbakHandler;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.fc.test.common.domain.AjaxResult;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import javax.annotation.Resource;

/**
 * 该接口为了前后端分离or手机端服务不用登录的接口  访问地址:localhot:8080/ApiController/test
 * 如何还需要其他 接口不登陆就能访问:ShiroFilterMapFactory.java里面配置开放自己的controller
 * @ClassName: ApiController
 * @author fuce
 * @date 2020-04-15 22:59
 */
@Api(value = "接口API")
@Controller
@RequestMapping("/ApiController")
public class ApiController {

	@Resource
	private PayNotifyCallbakHandler AliCallback;
	@Resource
	private PayNotifyCallbakHandler BaiduCallback;

	@Resource
	private PayNotifyCallbakHandler TaobaoCallback;
	
	//@Log(title = "${TsysTables.tableComment}集合查询", action = "111")
	@ApiOperation(value = "测试方法", notes = "测试方法")
	@GetMapping("/test")
	@ResponseBody
	public AjaxResult test() {
		AliCallback.verifyNotify("ssss");
		BaiduCallback.verifyNotify("ssss");
		TaobaoCallback.verifyNotify("ssss");
		return AjaxResult.success();
	}
}

运行效果:

 

 

展开阅读全文
打赏
0
1 收藏
分享
加载中
更多评论
打赏
0 评论
1 收藏
0
分享
返回顶部
顶部