springboot aop+觀察者模式的應(yīng)用

1.前言

? ? ? ? ?在現(xiàn)有的業(yè)務(wù)邏輯上增加社裆,簡歷手動上傳和插件上傳的控制:

@Component

@Aspect

public class ResumeControAspectextends Observable {

private final static Loggerlogger = LoggerFactory.getLogger(ResumeControAspect.class);

//增加觀察者

? ? public ResumeControAspect(InResumeFlowObserver inResumeFlow, AlreadyEntryResumeObserver alreadyEntryResume, TalentResumeFlowObserver talentResumeFlow, ResumeOutObserver resumeOutObserver) {

this.addObserver(inResumeFlow);//流程中

? ? ? ? this.addObserver(alreadyEntryResume);//已入職處理

? ? ? ? this.addObserver(talentResumeFlow);//事業(yè)部人才庫

? ? ? ? this.addObserver(resumeOutObserver);

? ? }

private ResumeOutVoresumeOutVo;

? ? public void setResumeId(ResumeOutVo resumeOutVo) {

//增加入?yún)?

this.resumeOutVo = resumeOutVo;

//被觀察的東西發(fā)生改變,

? ? ? ? setChanged();

//喚醒觀察者

? ? ? ? notifyObservers(resumeOutVo);

? ? }

@Autowired

? ? private ResumeServiceresumeService;

? ? @Before("excuteService()")

public void doBeforeMethod(JoinPoint joinPoint) {

Object[] obj = joinPoint.getArgs();

? ? ? ? BaseResumeEntity baseResumeEntity =null;

? ? ? ? SysLoginUserDTO sysLoginUserDTO =null;

? ? ? ? ResumeAccessVo? resumeAccessVo =null;

? ? ? ? for (Object argItem : obj) {

if (argIteminstanceof BaseResumeEntity) {

baseResumeEntity = (BaseResumeEntity) argItem;

? ? ? ? ? ? }

if (argIteminstanceof ResumeAccessVo) {

resumeAccessVo = (ResumeAccessVo) argItem;

? ? ? ? ? ? }

if (argIteminstanceof SysLoginUserDTO) {

sysLoginUserDTO = (SysLoginUserDTO) argItem;

? ? ? ? ? ? }

}

if (sysLoginUserDTO.getBussDeptId()==null){

throw? new CustomException("登錄用戶事業(yè)部信息異常");

? ? ? ? }

/***********************************************簡歷上傳****************************************************************************/

? ? ? ? //判斷是不是在該事業(yè)部人才庫中 phone +buss_dept_id

? ? ? ? if (baseResumeEntity !=null && sysLoginUserDTO !=null) {

List bussIds =? sysLoginUserDTO.getAccessibleDeptIds();

? ? ? ? ? ? //根據(jù)部門ID和手機號判斷是否已存在

? ? ? ? ? ? List resumeOutVos =resumeService.selectIdByPhone(baseResumeEntity.getPhone(), bussIds);

? ? ? ? ? ? if (resumeOutVos!=null && resumeOutVos.size()>0){

List collect = resumeOutVos.stream().filter(t -> t.getState().equals(StateEnum.FLOW.getCode())).collect(Collectors.toList());

? ? ? ? ? ? ? ? if (collect.size()>0){

collect.get(0).setOperUserId(sysLoginUserDTO.getId());

? ? ? ? ? ? ? ? ? ? collect.get(0).setBaseResumeEntity(baseResumeEntity);

? ? ? ? ? ? ? ? ? ? for (Object argItem : obj) {

if (argIteminstanceof BaseResumeEntity) {

baseResumeEntity = (BaseResumeEntity) argItem;

? ? ? ? ? ? ? ? ? ? ? ? ? ? //在流程中的簡歷需要繼續(xù)往下走 其他的直接返回

? ? ? ? ? ? ? ? ? ? ? ? ? ? baseResumeEntity.setIsContinue(!StateEnum.FLOW.getCode().equals(collect.get(0).getState())?false:true);

? ? ? ? ? ? ? ? ? ? ? ? }

}

//喚醒觀察者

? ? ? ? ? ? ? ? ? ? setResumeId(collect.get(0));

? ? ? ? ? ? ? ? }else{

resumeOutVos.get(0).setOperUserId(sysLoginUserDTO.getId());

? ? ? ? ? ? ? ? ? ? resumeOutVos.get(0).setBaseResumeEntity(baseResumeEntity);

? ? ? ? ? ? ? ? ? ? for (Object argItem : obj) {

if (argIteminstanceof BaseResumeEntity) {

baseResumeEntity = (BaseResumeEntity) argItem;

? ? ? ? ? ? ? ? ? ? ? ? ? ? baseResumeEntity.setBussDeptId(sysLoginUserDTO.getBussDeptId());

? ? ? ? ? ? ? ? ? ? ? ? ? ? //在流程中的簡歷需要繼續(xù)往下走 其他的直接返回

? ? ? ? ? ? ? ? ? ? ? ? ? ? baseResumeEntity.setIsContinue(!StateEnum.FLOW.getCode().equals(resumeOutVos.get(0).getState())?false:true);

? ? ? ? ? ? ? ? ? ? ? ? }

}

//喚醒觀察者

? ? ? ? ? ? ? ? ? ? setResumeId(resumeOutVos.get(0));

? ? ? ? ? ? ? ? }

}

}

/***********************************************簡歷插件上傳****************************************************************************/

? ? ? ? if (resumeAccessVo!=null && sysLoginUserDTO !=null){

List bussId =? sysLoginUserDTO.getAccessibleDeptIds();

? ? ? ? ? ? //根據(jù)部門ID和手機號判斷是否已存在

? ? ? ? ? ? List resumeOutVos =resumeService.selectIdByPhone(resumeAccessVo.getPhone(), bussId);

? ? ? ? ? ? if (resumeOutVos!=null && resumeOutVos.size()>0){

List collect = resumeOutVos.stream().filter(t -> t.getState().equals(StateEnum.FLOW.getCode())).collect(Collectors.toList());

? ? ? ? ? ? ? ? if (collect.size()>0){

collect.get(0).setOperUserId(sysLoginUserDTO.getId());

? ? ? ? ? ? ? ? ? ? collect.get(0).setResumeAccessVo(resumeAccessVo);

? ? ? ? ? ? ? ? ? ? for (Object argItem : obj) {

if (argIteminstanceof ResumeAccessVo) {

resumeAccessVo = (ResumeAccessVo) argItem;

? ? ? ? ? ? ? ? ? ? ? ? ? ? //在流程中的簡歷需要繼續(xù)往下走 其他的直接返回

? ? ? ? ? ? ? ? ? ? ? ? ? ? resumeAccessVo.setIsContinue(!StateEnum.FLOW.getCode().equals(collect.get(0).getState())?false:true);

? ? ? ? ? ? ? ? ? ? ? ? }

}

setResumeId(collect.get(0));

? ? ? ? ? ? ? ? }else{

resumeOutVos.get(0).setOperUserId(sysLoginUserDTO.getId());

? ? ? ? ? ? ? ? ? ? resumeOutVos.get(0).setResumeAccessVo(resumeAccessVo);

? ? ? ? ? ? ? ? ? ? for (Object argItem : obj) {

if (argIteminstanceof ResumeAccessVo) {

resumeAccessVo = (ResumeAccessVo) argItem;

? ? ? ? ? ? ? ? ? ? ? ? ? ? resumeAccessVo.setBussDeptId(sysLoginUserDTO.getBussDeptId());

? ? ? ? ? ? ? ? ? ? ? ? ? ? //在流程中的簡歷需要繼續(xù)往下走 其他的直接返回

? ? ? ? ? ? ? ? ? ? ? ? ? ? resumeAccessVo.setIsContinue(!StateEnum.FLOW.getCode().equals(resumeOutVos.get(0).getState())?false:true);

? ? ? ? ? ? ? ? ? ? ? ? }

}

setResumeId(resumeOutVos.get(0));

? ? ? ? ? ? ? ? }

}

}

}

@Pointcut(value ="@annotation(ResumeContro)")

public void excuteService() {

}

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末向图,一起剝皮案震驚了整個濱河市泳秀,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌榄攀,老刑警劉巖嗜傅,帶你破解...
    沈念sama閱讀 223,126評論 6 520
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異檩赢,居然都是意外死亡吕嘀,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 95,421評論 3 400
  • 文/潘曉璐 我一進店門贞瞒,熙熙樓的掌柜王于貴愁眉苦臉地迎上來币他,“玉大人,你說我怎么就攤上這事彰阴。” “怎么了簇抵?”我有些...
    開封第一講書人閱讀 169,941評論 0 366
  • 文/不壞的土叔 我叫張陵碟摆,是天一觀的道長典蜕。 經(jīng)常有香客問我罗洗,道長,這世上最難降的妖魔是什么轩缤? 我笑而不...
    開封第一講書人閱讀 60,294評論 1 300
  • 正文 為了忘掉前任,我火速辦了婚禮壶愤,結(jié)果婚禮上馏鹤,老公的妹妹穿的比我還像新娘假瞬。我一直安慰自己,他們只是感情好脱茉,可當我...
    茶點故事閱讀 69,295評論 6 398
  • 文/花漫 我一把揭開白布琴许。 她就那樣靜靜地躺著,像睡著了一般榜田。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上净捅,一...
    開封第一講書人閱讀 52,874評論 1 314
  • 那天蛔六,我揣著相機與錄音废亭,去河邊找鬼。 笑死豆村,一個胖子當著我的面吹牛掌动,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播拟逮,決...
    沈念sama閱讀 41,285評論 3 424
  • 文/蒼蘭香墨 我猛地睜開眼适滓,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了罚屋?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 40,249評論 0 277
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎猛拴,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體愉昆,經(jīng)...
    沈念sama閱讀 46,760評論 1 321
  • 正文 獨居荒郊野嶺守林人離奇死亡跛溉,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,840評論 3 343
  • 正文 我和宋清朗相戀三年芳室,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片堪侯。...
    茶點故事閱讀 40,973評論 1 354
  • 序言:一個原本活蹦亂跳的男人離奇死亡诺苹,死狀恐怖雹拄,靈堂內(nèi)的尸體忽然破棺而出滓玖,到底是詐尸還是另有隱情质蕉,我是刑警寧澤,帶...
    沈念sama閱讀 36,631評論 5 351
  • 正文 年R本政府宣布禁悠,位于F島的核電站兑宇,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜站玄,卻給世界環(huán)境...
    茶點故事閱讀 42,315評論 3 336
  • 文/蒙蒙 一株旷、第九天 我趴在偏房一處隱蔽的房頂上張望尔邓。 院中可真熱鬧,春花似錦梯嗽、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,797評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至偿警,卻和暖如春唯笙,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背七嫌。 一陣腳步聲響...
    開封第一講書人閱讀 33,926評論 1 275
  • 我被黑心中介騙來泰國打工苞慢, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人绍赛。 一個月前我還...
    沈念sama閱讀 49,431評論 3 379
  • 正文 我出身青樓吗蚌,卻偏偏與公主長得像纯出,于是被迫代替她去往敵國和親敷燎。 傳聞我的和親對象是個殘疾皇子懈叹,可洞房花燭夜當晚...
    茶點故事閱讀 45,982評論 2 361

推薦閱讀更多精彩內(nèi)容