74 lines
2.9 KiB
Java
74 lines
2.9 KiB
Java
package com.api.aiyh_quanshi.service.Impl;
|
||
|
||
import aiyh.utils.zwl.common.ToolUtil;
|
||
import com.weaverboot.frame.ioc.anno.classAnno.WeaIocReplaceComponent;
|
||
import com.weaverboot.frame.ioc.anno.methodAnno.WeaReplaceAfter;
|
||
import com.weaverboot.frame.ioc.anno.methodAnno.WeaReplaceBefore;
|
||
import com.weaverboot.frame.ioc.handler.replace.weaReplaceParam.impl.WeaAfterReplaceParam;
|
||
import com.weaverboot.frame.ioc.handler.replace.weaReplaceParam.impl.WeaBeforeReplaceParam;
|
||
import weaver.aiyh_quanshi.RequestApi;
|
||
import weaver.aiyh_quanshi.entity.QsResponse;
|
||
import weaver.conn.RecordSet;
|
||
|
||
import java.util.Map;
|
||
|
||
/**
|
||
* 如不标注名称,则按类的全路径注入
|
||
*/
|
||
@WeaIocReplaceComponent("cancelMetingService")
|
||
public class CancelMetingServiceImpl {
|
||
ToolUtil toolUtil = new ToolUtil();
|
||
RequestApi requestApi = new RequestApi();
|
||
boolean flag = true;
|
||
|
||
/**
|
||
* 这是接口前置方法,这个方法会在接口执行前执行
|
||
* 前值方法必须用@WeaReplaceBefore,这里面有两个参数,第一个叫value,是你的api地址
|
||
* 第二个参数叫order,如果你有很多方法拦截的是一个api,那么这个就决定了执行顺序
|
||
* 前置方法的参数为WeaBeforeReplaceParam 这个类,里面有四个参数,request,response,请求参数的map,api的地址
|
||
*/
|
||
@WeaReplaceBefore(value = "/api/meeting/base/cancelMeeting", order = 1, description = "会议接口前拦截")
|
||
public void before(WeaBeforeReplaceParam weaBeforeReplaceParam) {
|
||
// 获取会议id
|
||
Map paramMap = weaBeforeReplaceParam.getParamMap();
|
||
String id = String.valueOf(paramMap.get("meetingid"));
|
||
// 通过会议id获取全时会议id
|
||
String query = "select * from meeting where id = ?";
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery(query, id);
|
||
rs.next();
|
||
String quanShiId = rs.getString("quan_shi_id");
|
||
String hrmId = rs.getString("contacter");
|
||
query = "select * from hrmresource where id = ?";
|
||
rs.executeQuery(query, hrmId);
|
||
rs.next();
|
||
String creatorEmail = rs.getString("email");
|
||
// 通过全时会议id对会议进行取消
|
||
QsResponse qsResponse = requestApi.cancelConference(quanShiId, creatorEmail);
|
||
if(!"0".equals(qsResponse.getStatus())){
|
||
// 取消失败
|
||
flag = false;
|
||
}
|
||
|
||
}
|
||
|
||
/**
|
||
* 这个是接口后置方法,大概的用法跟前置方法差不多,稍有差别
|
||
* 注解名称为WeaReplaceAfter
|
||
* 返回类型必须为String
|
||
* 参数叫WeaAfterReplaceParam,这个类前四个参数跟前置方法的那个相同,不同的是多了一个叫data的String,这个是那个接口执行完返回的报文
|
||
* 你可以对那个报文进行操作,然后在这个方法里return回去
|
||
*/
|
||
@WeaReplaceAfter(value = "/api/meeting/base/cancelMeeting", order = 1)
|
||
public String after(WeaAfterReplaceParam weaAfterReplaceParam) {
|
||
//这个就是接口执行完的报文
|
||
String data = weaAfterReplaceParam.getData();
|
||
if(!flag){
|
||
// 取消会议失败
|
||
}else{
|
||
|
||
}
|
||
|
||
return data;
|
||
}
|
||
} |