简单的controller方法和action方法

不同系统的controller方法和对应的action方法都不一样,但是基本知识调用路径和接口的定义方法有区别,方法中的编写是一样的,post和get定义,接口参数的定义,路径的编写和注解的使用
1.
Controller
Post
@RestController
@RequestMapping("/store")
public class StoreController extends BaseController {
@Autowired
private StoreService service;
@RequestMapping(value = "https://www.it610.com/getStoreByCode",method ={RequestMethod.POST})
public BaseResponseVo getStoreByCode(@RequestBody String code){
List list=service.getStoreByCode(code);
returnBaseResponseVo.success(list);
}
}
Get
@RequestMapping(value = "https://www.it610.com/getContractType/{carSymbol}",method = {RequestMethod.GET})
【简单的controller方法和action方法】public BaseResponseVo getContractType(@PathVariable String carSymbol){
RentPlanQo rentPlanQo = new RentPlanQo();
rentPlanQo.setCarSymbol(carSymbol);
Map map = stockService.getContractType(rentPlanQo);
if(map==null||map.get("contractType")==null||"".equals(map.get("contractType"))){
throw new BaseException("111", "未查询到信息!");
}
map.remove("billingCompany");
map.remove("rate");
return BaseResponseVo.success(map);
}
2.这个是使用的rpc,接口路径直接定义
/**
* 查询所有可用的银行基础信息
* @return
*/
@RSAnnotation(value = "https://www.it610.com/article/hshcmdm.bank.queryBankAllValid",remark="银行基础信息")
public List queryBankAllValid() {
List bankList= bankMapper.queryBankAllValid();
List resultBank=new ArrayList<>();
for (BankModel bm:bankList){
BankDTO dto=new BankDTO();
dto.setCode(bm.getCode());
dto.setName(bm.getName());
dto.setAbbreviation(bm.getAbbreviation());
resultBank.add(dto);
}
return resultBank;
}
@RSAnnotation(value = "https://www.it610.com/article/hshcdispatch.dispatchOrder.purCancel", remark = "采购取消")
public Res purCancel(String orderNo, String userId) {
logger.info("远程服务--采购取消,客户订单号为:"+orderNo);
return dispatchOrderService.purCancel(orderNo, userId);
}
@Service
public class TestRS extends AbstractRS{
//远程服务地址
@RSAnnotation("hshcstore.test.test")
public Object test(Object o1){
System.out.println(o1);
return TimeUtil.getNowTimeAllStr()+"=>"+o1;
}
public static void main(String[] args) {
//Object obj= RemoteClientUtil.getClient("http://localhost:9000")
//.exe("hshcstore.test.test","wodeceshi"); 测试一下
Object obj= RemoteClientUtil.exe("hshcstore.test.test","wodeceshi");
System.out.println(obj);
}

}

3.自定义注解,无框架
自定义注解中的邮箱和type设定了权限和不可为空状态,配置中定义

@aPermission(name ={ "业务管理", "调度管理", "查询" }) @aDev(code = "sun", email = "sun@huash.com", name = "sun") @aAuth(type = aAuthType.LOGIN) public Reply getDispatchPage(){ Map map = _getParameters(); Page page = service.getDispatchPage(map); return new ReplyAjaxPage(page); }

    推荐阅读