WeMomentsController.java
2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package com.linkwechat.web.controller.wecom;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.wecom.constants.SynchRecordConstants;
import com.linkwechat.wecom.domain.WeMoments;
import com.linkwechat.wecom.service.IWeMomentsService;
import com.linkwechat.wecom.service.IWeSynchRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 朋友圈相关
*/
@RestController
@RequestMapping("/wecom/moments")
public class WeMomentsController extends BaseController {
@Autowired
IWeMomentsService iWeMomentsService;
@Autowired
IWeSynchRecordService iWeSynchRecordService;
/**
* 获取朋友圈列表
* @param weMoments
* @return
*/
@GetMapping("/list")
public TableDataInfo list(WeMoments weMoments) {
startPage();
List<WeMoments> moments = iWeMomentsService.findMoments(weMoments);
TableDataInfo dataTable = getDataTable(moments);
dataTable.setLastSyncTime(
iWeSynchRecordService.findUpdateLatestTime( weMoments.getType().equals(new Integer(0))?
SynchRecordConstants.SYNCH_CUSTOMER_ENTERPRISE_MOMENTS:SynchRecordConstants.SYNCH_CUSTOMER_PERSON_MOMENTS)
);//最近同步时间
return dataTable;
}
/**
* 获取朋友圈详情
* @param momentId
* @return
*/
@GetMapping("/findMomentsDetail/{momentId}")
public AjaxResult findMomentsDetail(@PathVariable String momentId){
return AjaxResult.success(
iWeMomentsService.findMomentsDetail(momentId)
);
}
/**
* 新增或者编辑朋友圈
* @return
*/
@PostMapping("/addOrUpdate")
public AjaxResult addOrUpdate(@RequestBody WeMoments weMoments){
iWeMomentsService.addOrUpdateMoments(weMoments);
return AjaxResult.success();
}
/**
* 朋友圈同步
* @param filterType 0:企业朋友圈;1:个人朋友圈
* @return
*/
@GetMapping("/synchMoments")
public AjaxResult synchMoments(@RequestParam(defaultValue = "0") Integer filterType){
if(filterType.equals(new Integer(0))){
iWeMomentsService.synchEnterpriseMoments(filterType);
}else if(filterType.equals(new Integer(1))){
iWeMomentsService.synchPersonMoments(filterType);
}
return AjaxResult.success(WeConstans.SYNCH_TIP);
}
}