UserAttentionAction.java
2.64 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
package com.cjs.site.action.user.interact;
import java.util.Iterator;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.cjs.site.dao.entrust.OtcCodeDao;
import com.cjs.site.dao.user.interact.UserAttentionDao;
import com.cjs.site.model.entrust.OtcCodeInfo;
import com.cjs.site.model.user.UserAttentionInfo;
import com.cjs.site.model.user.account.UserInfo;
import com.cjs.site.util.web.ActionUtil;
/**
* 用户自选行情
*
* @author tongyufu
*
*/
@Controller
public class UserAttentionAction {
@Autowired
private UserAttentionDao userAttentionDao;
@Autowired
private OtcCodeDao otcCodeDao;
@RequestMapping("/entrust/all")
public String entrustAll(Model model) {
return "entrust/entrustAll.jsp";
}
@RequestMapping("/user/attention")
public String view() {
return "entrust/entrustAttention.jsp";
}
/**用户关注列表*/
@ResponseBody
@RequestMapping("/entrust/userAttentions")
public String userAttentions() {
UserInfo user = ActionUtil.getUser();
if (user == null) {
return "";
}
List<UserAttentionInfo> attentions = userAttentionDao.queryByUserId(user.getUserId());
StringBuilder build = new StringBuilder();
for (Iterator<UserAttentionInfo> it = attentions.iterator(); it.hasNext();) {
build.append(it.next().getOtcCode());
if (it.hasNext()) {
build.append(",");
}
}
return build.toString();
}
/**关注*/
@ResponseBody
@RequestMapping("/user/attention/save")
public String save(String otcCode) {
OtcCodeInfo otcCodeInfo = otcCodeDao.queryByOtcCode(otcCode);
UserAttentionInfo attention = new UserAttentionInfo();
if (otcCodeInfo == null) {
return "藏品[" + otcCode + "]不存在";
}
attention.setUserId(ActionUtil.getUser().getUserId());
attention.setOtcCode(otcCode);
userAttentionDao.save(attention);
return "您已成功关注 <a style='color:#d1131d'>" + otcCode + "(" + otcCodeInfo.getOtcName()
+ ")</a>";
}
/**取消关注*/
@ResponseBody
@RequestMapping("/user/attention/delete")
public String delete(String otcCode) {
String userId = ActionUtil.getUser().getUserId();
userAttentionDao.delete(userId, otcCode);
return "取消关注藏品成功";
}
}