package com.yeshi.makemoney.app.controller.client.api;
|
|
import com.google.gson.*;
|
import com.yeshi.makemoney.app.entity.msg.AppPageNotifyMsg;
|
import com.yeshi.makemoney.app.entity.msg.UserMsg;
|
import com.yeshi.makemoney.app.entity.team.TeamInviteRelation;
|
import com.yeshi.makemoney.app.entity.team.UserSpreadImg;
|
import com.yeshi.makemoney.app.entity.user.UserInfo;
|
import com.yeshi.makemoney.app.exception.team.SpreadImgException;
|
import com.yeshi.makemoney.app.exception.team.TeamInviteRelationException;
|
import com.yeshi.makemoney.app.exception.team.UserSpreadImgException;
|
import com.yeshi.makemoney.app.exception.user.UserInfoException;
|
import com.yeshi.makemoney.app.service.inter.goldcorn.GoldCornGetRecordService;
|
import com.yeshi.makemoney.app.service.inter.msg.AppPageNotifyMsgService;
|
import com.yeshi.makemoney.app.service.inter.msg.UserMsgService;
|
import com.yeshi.makemoney.app.service.inter.team.TeamInviteRelationService;
|
import com.yeshi.makemoney.app.service.inter.team.UserSpreadImgService;
|
import com.yeshi.makemoney.app.service.inter.user.UserExtraInfoService;
|
import com.yeshi.makemoney.app.service.inter.user.UserInfoService;
|
import com.yeshi.makemoney.app.service.query.msg.UserMsgQuery;
|
import com.yeshi.makemoney.app.utils.Constant;
|
import com.yeshi.makemoney.app.utils.annotation.UserLogin;
|
import com.yeshi.makemoney.app.vo.AcceptData;
|
import com.yeshi.makemoney.app.vo.msg.AppPageNotifyMsgVO;
|
import com.yeshi.makemoney.app.vo.msg.UserMsgVO;
|
import com.yeshi.makemoney.app.vo.team.TeamInfoVO;
|
import com.yeshi.makemoney.app.vo.team.TeamMemberListVO;
|
import com.yeshi.makemoney.app.vo.user.UserInfoVO;
|
import net.sf.json.JSONObject;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.yeshi.utils.BigDecimalUtil;
|
import org.yeshi.utils.JsonUtil;
|
import org.yeshi.utils.ThreadUtil;
|
import org.yeshi.utils.TimeUtil;
|
|
import javax.annotation.Resource;
|
import java.lang.reflect.Type;
|
import java.math.BigDecimal;
|
import java.util.*;
|
import java.util.stream.Collectors;
|
|
/**
|
* @author hxh
|
* @title: TeamController
|
* @description: 团队接口
|
* @date 2021/11/16 17:37
|
*/
|
@Controller
|
@RequestMapping("api/v1/msg")
|
public class MsgController {
|
|
@Resource
|
private AppPageNotifyMsgService appPageNotifyMsgService;
|
|
@Resource
|
private UserMsgService userMsgService;
|
|
|
/**
|
* @return java.lang.String
|
* @author hxh
|
* @description 获取应用内通知信息
|
* @date 10:50 2022/4/24
|
* @param: acceptData
|
* @param: type
|
**/
|
@ResponseBody
|
@RequestMapping("getNotifyMsg")
|
public String getNotifyMsg(AcceptData acceptData, String type) {
|
AppPageNotifyMsg.AppPageNotifyMsgType msgType = AppPageNotifyMsg.AppPageNotifyMsgType.valueOf(type);
|
if (msgType == null) {
|
return JsonUtil.loadFalseResult("类型错误");
|
}
|
AppPageNotifyMsg msg = appPageNotifyMsgService.selectByType(acceptData.getSystem(), msgType, new Date());
|
if (msg == null) {
|
return JsonUtil.loadFalseResult("暂无通知消息");
|
}
|
return JsonUtil.loadTrueResult(AppPageNotifyMsgVO.create(msg));
|
}
|
|
|
@UserLogin(uid = "#uid")
|
@ResponseBody
|
@RequestMapping("getUserMsg")
|
public String getUserMsg(AcceptData acceptData, Long uid, int page) {
|
UserMsgQuery query = new UserMsgQuery();
|
query.setUid(uid);
|
|
List<UserMsg> msgList = userMsgService.list(query, page, Constant.PAGE_SIZE);
|
long count = userMsgService.count(query);
|
|
|
Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
|
@Override
|
public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) {
|
return value == null ? new JsonPrimitive("") : new JsonPrimitive(TimeUtil.getGernalTime(value.getTime(), "yyyy.MM.dd HH:mm"));
|
}
|
}).create();
|
|
List<UserMsgVO> voList = new ArrayList<>();
|
if (msgList != null) {
|
voList = msgList.stream().map(item -> {
|
return UserMsgVO.create(item);
|
}).collect(Collectors.toList());
|
|
}
|
|
JSONObject data = new JSONObject();
|
data.put("list", gson.toJson(voList));
|
data.put("count", count);
|
ThreadUtil.run(new Runnable() {
|
@Override
|
public void run() {
|
userMsgService.readAllMsg(uid);
|
}
|
});
|
return JsonUtil.loadTrueResult(data);
|
}
|
|
|
}
|