Commit fdc1f109 authored by jiaorz's avatar jiaorz

修改管家核销订单列表

parent 29e7c46a
...@@ -16,6 +16,8 @@ public class ResultCode { ...@@ -16,6 +16,8 @@ public class ResultCode {
// 操作失败 // 操作失败
public static int FAILED_CODE = Integer.valueOf(SystemProperty.getResultConfig("FAILED_CODE")); public static int FAILED_CODE = Integer.valueOf(SystemProperty.getResultConfig("FAILED_CODE"));
//IM消息删除失败
public static int IM_DELETE_FAIL_CODE = Integer.valueOf(SystemProperty.getResultConfig("IM_DELETE_FAIL_CODE"));
// 车辆预定失败,请重试 // 车辆预定失败,请重试
public static int BOOKED_FAILED_CODE = Integer.valueOf(SystemProperty.getResultConfig("BOOKED_FAILED_CODE")); public static int BOOKED_FAILED_CODE = Integer.valueOf(SystemProperty.getResultConfig("BOOKED_FAILED_CODE"));
//预定时间不能为空 DATE_TIME_IS_NULL //预定时间不能为空 DATE_TIME_IS_NULL
......
...@@ -6,6 +6,8 @@ SUCCESS_CODE=200 ...@@ -6,6 +6,8 @@ SUCCESS_CODE=200
#操作失败 #操作失败
FAILED_CODE=1001 FAILED_CODE=1001
1001=操作失败 1001=操作失败
IM_DELETE_FAIL_CODE = 10011
10011 = 删除消息失败
#数据已存在 #数据已存在
EXIST_CODE=1002 EXIST_CODE=1002
1002=数据已存在 1002=数据已存在
......
...@@ -8,13 +8,16 @@ import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO; ...@@ -8,13 +8,16 @@ import com.github.wxiaoqi.security.admin.feign.dto.AppUserDTO;
import com.github.wxiaoqi.security.admin.vo.ImiVo; import com.github.wxiaoqi.security.admin.vo.ImiVo;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.mongodb.client.result.DeleteResult;
import com.xxfc.platform.im.dto.CommentVo; import com.xxfc.platform.im.dto.CommentVo;
import com.xxfc.platform.im.dto.PraiseVo; import com.xxfc.platform.im.dto.PraiseVo;
import com.xxfc.platform.im.model.Comment; import com.xxfc.platform.im.model.Comment;
import com.xxfc.platform.im.model.Msg; import com.xxfc.platform.im.model.Msg;
import com.xxfc.platform.im.model.Praise; import com.xxfc.platform.im.model.Praise;
import com.xxfc.platform.im.vo.MsgVo; import com.xxfc.platform.im.vo.MsgVo;
import com.xxfc.platform.universal.constant.ResCode;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.bson.types.ObjectId; import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
...@@ -25,9 +28,7 @@ import org.springframework.data.mongodb.core.query.Criteria; ...@@ -25,9 +28,7 @@ import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.*;
import java.util.Iterator;
import java.util.List;
@Service @Service
@Slf4j @Slf4j
...@@ -153,6 +154,31 @@ public class MsgBiz { ...@@ -153,6 +154,31 @@ public class MsgBiz {
} }
/**
* 删除消息
* @param ids id字符串,用逗号隔开
* @return
*/
public ObjectRestResponse deleteByList(String ids) {
if (StringUtils.isBlank(ids)) {
return ObjectRestResponse.paramIsEmpty();
}
Integer userId = 0;
AppUserDTO appUserDTO = userBiz.getUserInfo();
if(appUserDTO != null) {
userId = appUserDTO.getImUserid();
}
List<String> list = Arrays.asList(ids.split(","));
Set<String> set = new HashSet<>();
set.addAll(list);
Query query = new Query(Criteria.where("id").in(set));
query.addCriteria(Criteria.where("userId").is(userId));
DeleteResult deleteResult = mongoTemplate.remove(query, Msg.class, "s_msg");
if (deleteResult != null && deleteResult.getDeletedCount() == set.size()) {
return ObjectRestResponse.succ();
}
return ObjectRestResponse.createFailedResult(ResultCode.IM_DELETE_FAIL_CODE, ResultCode.getMsg(ResultCode.IM_DELETE_FAIL_CODE));
}
/** /**
......
...@@ -35,4 +35,9 @@ public class MsgController { ...@@ -35,4 +35,9 @@ public class MsgController {
public ObjectRestResponse getByUserId(Integer page, Integer limit, Integer type) { public ObjectRestResponse getByUserId(Integer page, Integer limit, Integer type) {
return msgBiz.getMsgListByUserId(page, limit, type); return msgBiz.getMsgListByUserId(page, limit, type);
} }
@GetMapping(value = "/delete")
public ObjectRestResponse deleteByIds(String ids) {
return msgBiz.deleteByList(ids);
}
} }
//package com.xxfc.platform.universal.fastservice.api;
//
//
//import com.alibaba.fastjson.JSONObject;
//import com.github.wxiaoqi.security.common.util.HTTPSUtils;
//import com.github.wxiaoqi.security.common.util.process.SystemConfig;
//import com.xxfc.platform.universal.fastservice.dto.EventNotifyRequestDto;
//import com.xxfc.platform.universal.fastservice.dto.RequestBodyDto;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Service;
//
//import java.util.HashMap;
//import java.util.Map;
//
//@Slf4j
//@Service
//public class FastServiceApi {
//
// public String getAccessToken(String code) {
// RequestBodyDto requestBodyDto = new RequestBodyDto(SystemConfig.HUAWEI_FAST_SERVICE_GRANT_TYPE_AUTH,
// SystemConfig.HUAWEI_FAST_SERVICE_CLIENT_ID,
// SystemConfig.HUAWEI_FAST_SERVICE_CLIENT_SECRET,
// code,
// SystemConfig.HUAWEI_FAST_SERVICE_REDIRECT_URI);
// String paramString = requestBodyDto.getParamMap();
// log.info("获取token参数列表: param = {}", paramString);
// Map<String, String> headers = new HashMap<>();
// headers.put("Content-Type", "application/x-www-form-urlencoded");
// try {
// String result = HTTPSUtils.post(SystemConfig.HUAWEI_FAST_SERVICE_GET_TOKEN, paramString, headers);
// log.info("获取token返回结果: result = {}", result);
// return result;
// } catch (Exception e) {
// log.info("获取token返回失败");
// e.printStackTrace();
// }
// return null;
// }
//
// public String refreshAccessToken(String refreshToken) {
// RequestBodyDto requestBodyDto = new RequestBodyDto(SystemConfig.HUAWEI_FAST_SERVICE_GRANT_TYPE_REFRESH_TOKEN,
// refreshToken,
// SystemConfig.HUAWEI_FAST_SERVICE_CLIENT_ID,
// SystemConfig.HUAWEI_FAST_SERVICE_CLIENT_SECRET
// );
// String paramString = requestBodyDto.getParamMap();
// Map<String, String> headers = new HashMap<>();
// headers.put("Content-Type", "application/x-www-form-urlencoded");
// try {
// String result = HTTPSUtils.post(SystemConfig.HUAWEI_FAST_SERVICE_GET_TOKEN, paramString, headers);
// log.info("刷新token返回结果: result = {}", result);
// return result;
// } catch (Exception e) {
// log.info("刷新token返回失败");
// e.printStackTrace();
// }
// return null;
// }
// public String getOpenId(String accessToken) {
// RequestBodyDto requestBodyDto = new RequestBodyDto(SystemConfig.HUAWEI_FAST_SERVICE_NSP_SVC,
// SystemConfig.HUAWEI_FAST_SERVICE_OPEN_ID,
// accessToken
// );
// String paramString = requestBodyDto.getParamMap();
// log.info("获取openId参数列表: param = {}", paramString);
// Map<String, String> headers = new HashMap<>();
// headers.put("Content-Type", "application/x-www-form-urlencoded");
// try {
// String result = HTTPSUtils.post(SystemConfig.HUAWEI_FAST_SERVICE_GET_OPENID, paramString, headers);
// log.info("获取openId返回结果: result = {}", result);
// return result;
// } catch (Exception e) {
// log.info("获取openId返回失败");
// e.printStackTrace();
// }
// return null;
// }
//
// public String eventNotify(EventNotifyRequestDto eventNotifyRequestDto) {
// Map<String, String> headers = new HashMap<>();
// headers.put("x-appid", SystemConfig.HUAWEI_FAST_SERVICE_CLIENT_ID);
// headers.put("Authorization", eventNotifyRequestDto.getOAuthToken().getAccessToken());
// headers.put("Content-Type", "application/json");
// headers.put("Accept", "application/json");
// String paramString = JSONObject.toJSONString(eventNotifyRequestDto);
// log.info("事件通知参数列表: param = {}", paramString);
// try {
// String result = HTTPSUtils.post(SystemConfig.HUAWEI_FAST_SERVICE_EVENT_NOTIFY, paramString, headers);
// log.info("事件通知返回: result = {}", result);
// return result;
// } catch (Exception e) {
// log.info("事件通知返回失败");
// e.printStackTrace();
// }
// return null;
// }
//
// public static void main(String[] args) {
// FastServiceApi fastServiceApi = new FastServiceApi();
//
// }
//}
package com.xxfc.platform.universal.fastservice.dto;
import lombok.Data;
/**
* 快服务事件通知参数实体
*/
@Data
public class EventNotifyRequestDto {
private String requestTime; // String(17) M 请求报文的发送时间,格式:yyyyMMddHHmmssSSS(UTC)
private String requestId;// String M 事件唯一ID。在消息是否重传、以及撤销时作唯一识别标识。如果重传,则需要保证重传消息的requestId与原消息的requestId一致,服务端会对重复请求进行过滤处理。其他情况,则需要保证每次requestId不同。可以使用UUID作为requestId;Pattern: [a-zA-Z0-9\-]{1,64}。
private String openId; //String(512) M 华为分配的,第三方帐号与华为帐号的关联ID。
private String eventName; // String(100) M 事件名称,由开发者定义,在事件卡片规则中关联到某个卡片;需要保证事件名称在同一个appid下是唯一的。
private String parameters; //String(255) O 事件的参数,由开发者定义,华为快服务智慧平台透传给卡片页面。 Json格式,key不能以_、$和hag_开始,不要使用for, if, show, tid等保留字。
private String effectiveTime; //String(17) M 事件的生效时间,如酒店入住时间;UTC时区,精确到毫秒,格式:yyyyMMddHHmmssSSS。
private String expireTime; //String(17) M 事件的失效时间,超过该时间后,事件不再通知用户,UTC时区,精确到毫秒,格式:yyyyMMddHHmmssSSS。
private String abilityId; //String(128) O 通知的服务ID,开发者可以在华为快服务智慧平台的开发者控制台上获取。
private OAuthToken oAuthToken; //OAuthToken O 开发者在账号绑定完成后,如果快应用服务器需要对用户的快应用请求进行鉴权,则需要给用户分配AccessToken/RefreshToken信息;如果快应用服务器需要刷新保存在华为快服务智慧平台的用户AccessToken/RefreshToken,也通过该参数。
}
package com.xxfc.platform.universal.fastservice.dto;
import lombok.Data;
@Data
public class OAuthToken {
private String accessToken; //String(512) M 快应用服务器遵循OAuth2.0规范,分配的用户AccessToken。
private Long tokenExpire; // Long M 用户AccessToken的有效期,单位为秒,过期后,华为快服务智慧平台会使用refreshToken向快应用服务器重新申请。
private String refreshToken; // String(512) M 快应用服务器遵循OAuth2.0规范提供的,用于刷新AccessToken的标识。
private String tokenType = "bearer"; // String(64) O 传递Token的字段,默认为 bearer。
}
package com.xxfc.platform.universal.fastservice.dto;
import com.github.wxiaoqi.security.common.util.process.SystemConfig;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import java.net.URLEncoder;
@Data
public class RequestBodyDto {
private String grantType;
private String refreshToken;
private String clientId;
private String clientSecret;
private String code;
private String redirectUri;
private String nspSvc;
private String openId;
private String accessToken;
public RequestBodyDto(String grantType, String refreshToken, String clientId, String clientSecret, String code, String redirectUri, String nspSvc, String openId, String accessToken) {
this.grantType = grantType;
this.refreshToken = refreshToken;
this.clientId = clientId;
this.clientSecret = clientSecret;
this.code = code;
this.redirectUri = redirectUri;
this.nspSvc = nspSvc;
this.openId = openId;
this.accessToken = accessToken;
}
public RequestBodyDto(String grantType, String clientId, String clientSecret, String code, String redirectUri) {
this.grantType = grantType;
this.clientId = clientId;
this.clientSecret = clientSecret;
this.code = code;
this.redirectUri = redirectUri;
}
public RequestBodyDto(String grantType, String refreshToken, String clientId, String clientSecret) {
this.grantType = grantType;
this.refreshToken = refreshToken;
this.clientId = clientId;
this.clientSecret = clientSecret;
}
public RequestBodyDto(String nspSvc, String openId, String accessToken) {
this.nspSvc = nspSvc;
this.openId = openId;
this.accessToken = accessToken;
}
public String getParamMap(){
StringBuilder stringBuilder = new StringBuilder();
if(StringUtils.isNotBlank(this.grantType)) {
stringBuilder.append("granType = ");
stringBuilder.append( URLEncoder.encode(this.grantType));
stringBuilder.append("&");
}
if(StringUtils.isNotBlank(this.refreshToken)) {
stringBuilder.append("refresh_token = ");
stringBuilder.append( URLEncoder.encode(this.refreshToken));
stringBuilder.append("&");
}
if(StringUtils.isNotBlank(this.clientId)) {
stringBuilder.append("client_id = ");
stringBuilder.append( URLEncoder.encode(this.clientId));
stringBuilder.append("&");
}
if(StringUtils.isNotBlank(this.clientSecret)) {
stringBuilder.append("client_secret = ");
stringBuilder.append( URLEncoder.encode(this.clientSecret));
stringBuilder.append("&");
}
if(StringUtils.isNotBlank(this.code)) {
stringBuilder.append("code = ");
stringBuilder.append( URLEncoder.encode(this.code));
stringBuilder.append("&");
}
if(StringUtils.isNotBlank(this.redirectUri)) {
stringBuilder.append("redirect_uri = ");
stringBuilder.append( URLEncoder.encode(this.redirectUri));
stringBuilder.append("&");
}
if(StringUtils.isNotBlank(this.nspSvc)) {
stringBuilder.append("nsp_svc = ");
stringBuilder.append( URLEncoder.encode(this.nspSvc));
stringBuilder.append("&");
}
if(StringUtils.isNotBlank(this.openId)) {
stringBuilder.append("open_id = ");
stringBuilder.append( URLEncoder.encode(this.openId));
stringBuilder.append("&");
}
if(StringUtils.isNotBlank(this.accessToken)) {
stringBuilder.append("access_token = ");
stringBuilder.append( URLEncoder.encode(this.accessToken));
stringBuilder.append("&");
}
return stringBuilder.toString();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment