Commit 8430754d by giaogiao

AppKeyTest

parent ff324a3a
package io.geekidea.springbootplus;
import com.wecloud.im.tillo.netty.core.NettyStart;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
......@@ -8,8 +9,8 @@ import javax.annotation.Resource;
@Component
public class StartNettyService implements CommandLineRunner {
// @Value("${netty.port}")
// private int port;
@Value("${netty.port}")
private int port;
@Resource
private NettyStart nettyServer;
......@@ -17,8 +18,7 @@ public class StartNettyService implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
// nettyServer.run(port);
nettyServer.run(8899);
nettyServer.run(port);
}
}
package io.geekidea.springbootplus.test;
import com.wecloud.im.tillo.app_ws.utils.RSAGenerator;
import io.geekidea.springbootplus.SpringBootPlusApplication;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringBootPlusApplication.class)
public class AppKeyTest {
public static void main(String[] args) {
String appKey = RSAGenerator.getAppKey(); //定义变量接收
String appSecret = RSAGenerator.getAppSecret(appKey);
int i=1;
}
}
......@@ -28,4 +28,6 @@ import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringBootPlusApplication.class)
public class BaseTest {
}
package io.geekidea.springbootplus.test;
import com.wecloud.im.factory.PushFactory;
import com.wecloud.im.service.DonationRecordService;
import com.wecloud.im.vo.DonationRankAndTotal;
import me.chanjar.weixin.common.bean.WxOAuth2UserInfo;
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
import me.chanjar.weixin.mp.api.WxMpService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class SpiringPlusTest {
@Autowired
private PushFactory pushFactory;
@Autowired
private WxMpService wxMpService;
@Autowired
private DonationRecordService donationRecordService;
/**
* app推送:1.您有一条新消息(客服回复推送)
* 2.您的订单已报价(商家端报价完后推送)
* 3.您的订单已完成(商家端完成行程完后推送
*
* @throws Exception
*/
@Test
public void push() throws Exception {
pushFactory.getService(1).unicast("Ar4opHQcGn-UA1-fZ7O6PAeNSJs9rCEEI5XRvS_0rQke", "2", "您的订单已报价");
pushFactory.getService(1).unicast("Ar4opHQcGn-UA1-fZ7O6PAeNSJs9rCEEI5XRvS_0rQke", "3", "您的订单已完成");
}
@Test
public void wxGetOpenId() throws Exception {
String code = "071iQYGa1jwhCA06vtFa1OHuHE2iQYGq";
WxOAuth2AccessToken accessToken = wxMpService.getOAuth2Service().getAccessToken(code);
// 获取用户头像
WxOAuth2UserInfo userInfo = wxMpService.getOAuth2Service().getUserInfo(accessToken, null);
int ii = 1;
}
@Test
public void donationTest() throws Exception {
DonationRankAndTotal donationRankAndTotal = donationRecordService.getDonationRankAndTotal(1L);
int ii = 1;
};
}
package com.wecloud.im.config;
import io.geekidea.springbootplus.config.properties.WxMpProperties;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.List;
import java.util.stream.Collectors;
/**
* wechat mp configuration
*
* @author Binary Wang(https://github.com/binarywang)
*/
@Configuration
//@EnableConfigurationProperties(WxMpProperties.class)
public class WxMpConfiguration {
// private final LogHandler logHandler;
// private final NullHandler nullHandler;
// private final KfSessionHandler kfSessionHandler;
// private final StoreCheckNotifyHandler storeCheckNotifyHandler;
// private final LocationHandler locationHandler;
// private final MenuHandler menuHandler;
// private final MsgHandler msgHandler;
// private final UnsubscribeHandler unsubscribeHandler;
// private final SubscribeHandler subscribeHandler;
// private final ScanHandler scanHandler;
// private final WxMpProperties properties;
@Autowired
private WxMpProperties properties;
@Bean
public WxMpService wxMpService() {
// 代码里 getConfigs()处报错的同学,请注意仔细阅读项目说明,你的IDE需要引入lombok插件!!!!
final List<WxMpProperties.MpConfig> configs = this.properties.getConfigs();
if (configs == null) {
throw new RuntimeException("添加下相关配置,注意别配错了!");
}
WxMpService service = new WxMpServiceImpl();
service.setMultiConfigStorages(configs
.stream().map(a -> {
WxMpDefaultConfigImpl configStorage;
// if (this.properties.isUseRedis()) {
// final WxMpProperties.RedisConfig redisConfig = this.properties.getRedisConfig();
// JedisPool jedisPool = new JedisPool(redisConfig.getHost(), redisConfig.getPort());
// configStorage = new WxMpRedisConfigImpl(new JedisWxRedisOps(jedisPool), a.getAppId());
// } else {
configStorage = new WxMpDefaultConfigImpl();
// }
configStorage.setAppId(a.getAppId());
configStorage.setSecret(a.getSecret());
configStorage.setToken(a.getToken());
configStorage.setAesKey(a.getAesKey());
return configStorage;
}).collect(Collectors.toMap(WxMpDefaultConfigImpl::getAppId, a -> a, (o, n) -> o)));
return service;
}
// @Bean
// public WxMpMessageRouter messageRouter(WxMpService wxMpService) {
// final WxMpMessageRouter newRouter = new WxMpMessageRouter(wxMpService);
//
// // 记录所有事件的日志 (异步执行)
// newRouter.rule().handler(this.logHandler).next();
//
// // 接收客服会话管理事件
// newRouter.rule().async(false).msgType(EVENT).event(KF_CREATE_SESSION)
// .handler(this.kfSessionHandler).end();
// newRouter.rule().async(false).msgType(EVENT).event(KF_CLOSE_SESSION)
// .handler(this.kfSessionHandler).end();
// newRouter.rule().async(false).msgType(EVENT).event(KF_SWITCH_SESSION)
// .handler(this.kfSessionHandler).end();
//
// // 门店审核事件
// newRouter.rule().async(false).msgType(EVENT).event(POI_CHECK_NOTIFY).handler(this.storeCheckNotifyHandler).end();
//
// // 自定义菜单事件
// newRouter.rule().async(false).msgType(EVENT).event(EventType.CLICK).handler(this.menuHandler).end();
//
// // 点击菜单连接事件
// newRouter.rule().async(false).msgType(EVENT).event(EventType.VIEW).handler(this.nullHandler).end();
//
// // 关注事件
// newRouter.rule().async(false).msgType(EVENT).event(SUBSCRIBE).handler(this.subscribeHandler).end();
//
// // 取消关注事件
// newRouter.rule().async(false).msgType(EVENT).event(UNSUBSCRIBE).handler(this.unsubscribeHandler).end();
//
// // 上报地理位置事件
// newRouter.rule().async(false).msgType(EVENT).event(EventType.LOCATION).handler(this.locationHandler).end();
//
// // 接收地理位置消息
// newRouter.rule().async(false).msgType(XmlMsgType.LOCATION).handler(this.locationHandler).end();
//
// // 扫码事件
// newRouter.rule().async(false).msgType(EVENT).event(EventType.SCAN).handler(this.scanHandler).end();
//
// // 默认
// newRouter.rule().async(false).handler(this.msgHandler).end();
//
// return newRouter;
// }
}
package com.wecloud.im.config;
import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
import io.geekidea.springbootplus.config.properties.WxPayProperties;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author Binary Wang
*/
@Configuration
@ConditionalOnClass(WxPayService.class)
@EnableConfigurationProperties(WxPayProperties.class)
@AllArgsConstructor
public class WxPayConfiguration {
private WxPayProperties properties;
@Bean
@ConditionalOnMissingBean
public WxPayService wxService() {
WxPayConfig payConfig = new WxPayConfig();
payConfig.setAppId(StringUtils.trimToNull(this.properties.getAppId()));
payConfig.setMchId(StringUtils.trimToNull(this.properties.getMchId()));
payConfig.setMchKey(StringUtils.trimToNull(this.properties.getMchKey()));
payConfig.setSubAppId(StringUtils.trimToNull(this.properties.getSubAppId()));
payConfig.setSubMchId(StringUtils.trimToNull(this.properties.getSubMchId()));
payConfig.setKeyPath(StringUtils.trimToNull(this.properties.getKeyPath()));
// 可以指定是否使用沙箱环境
payConfig.setUseSandboxEnv(false);
WxPayService wxPayService = new WxPayServiceImpl();
wxPayService.setConfig(payConfig);
return wxPayService;
}
}
package com.wecloud.im.controller;
/**
* 替他人捐款记录表 控制器
*
* @author hewei
* @since 2021-02-25
*/
//@Slf4j
//@RestController
//@RequestMapping("/donationAgent")
//@Api(value = "替他人捐款记录表API", tags = {"替他人捐款记录表"})
//public class DonationAgentController extends BaseController {
//
// @Autowired
// private DonationAgentService donationAgentService;
//
// /**
// * 添加替他人捐款记录表
// */
// @PostMapping("/add")
// @OperationLog(name = "添加替他人捐款记录表", type = OperationLogType.ADD)
// @ApiOperation(value = "添加替他人捐款记录表")
// public ApiResult<Boolean> addDonationAgent(@Validated(Add.class) @RequestBody DonationAgent donationAgent) throws Exception {
// boolean flag = donationAgentService.saveDonationAgent(donationAgent);
// return ApiResult.result(flag);
// }
//
// /**
// * 修改替他人捐款记录表
// */
// @PostMapping("/update")
// @OperationLog(name = "修改替他人捐款记录表", type = OperationLogType.UPDATE)
// @ApiOperation(value = "修改替他人捐款记录表")
// public ApiResult<Boolean> updateDonationAgent(@Validated(Update.class) @RequestBody DonationAgent donationAgent)throws Exception{
// boolean flag= donationAgentService.updateDonationAgent(donationAgent);
// return ApiResult.result(flag);
// }
//
// /**
// * 删除替他人捐款记录表
// */
// @PostMapping("/delete/{id}")
// @OperationLog(name = "删除替他人捐款记录表", type = OperationLogType.DELETE)
// @ApiOperation(value = "删除替他人捐款记录表")
// public ApiResult<Boolean> deleteDonationAgent(@PathVariable("id") Long id)throws Exception{
// boolean flag= donationAgentService.deleteDonationAgent(id);
// return ApiResult.result(flag);
// }
//
// /**
// * 获取替他人捐款记录表详情
// */
// @GetMapping("/info/{id}")
// @OperationLog(name = "替他人捐款记录表详情", type = OperationLogType.INFO)
// @ApiOperation(value = "替他人捐款记录表详情")
// public ApiResult<DonationAgentQueryVo> getDonationAgent(@PathVariable("id") Long id)throws Exception{
// DonationAgentQueryVo donationAgentQueryVo = donationAgentService.getDonationAgentById(id);
// return ApiResult.ok(donationAgentQueryVo);
// }
//
// /**
// * 替他人捐款记录表分页列表
// */
// @PostMapping("/getPageList")
// @OperationLog(name = "替他人捐款记录表分页列表", type = OperationLogType.PAGE)
// @ApiOperation(value = "替他人捐款记录表分页列表")
// public ApiResult<Paging<DonationAgentQueryVo>>getDonationAgentPageList(@Validated @RequestBody DonationAgentPageParam donationAgentPageParam)throws Exception{
// Paging<DonationAgentQueryVo> paging = donationAgentService.getDonationAgentPageList(donationAgentPageParam);
// return ApiResult.ok(paging);
// }
//}
package com.wecloud.im.controller;
import com.wecloud.im.entity.VipPrice;
import com.wecloud.im.service.VipPriceService;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 会员价格表 控制器
*
* @author xxx
* @since 2021-03-11
*/
@Slf4j
@RestController
@RequestMapping("/vipPrice")
@Api(value = "会员价格表API", tags = {"会员价格表"})
public class VipPriceController extends BaseController {
@Autowired
private VipPriceService vipPriceService;
/**
* 会员价格表所有列表
*/
@PostMapping("/getAllList")
@OperationLog(name = "会员价格表所有列表", type = OperationLogType.PAGE)
@ApiOperation(value = "会员价格表所有列表")
public ApiResult<List<VipPrice>> getVipPricePageList() throws Exception {
return ApiResult.ok(vipPriceService.list());
}
// /**
// * 会员价格表分页列表
// */
// @PostMapping("/getPageList")
// @OperationLog(name = "会员价格表分页列表", type = OperationLogType.PAGE)
// @ApiOperation(value = "会员价格表分页列表")
// public ApiResult<Paging<VipPriceQueryVo>> getVipPricePageList(@Validated @RequestBody VipPricePageParam vipPricePageParam) throws Exception {
// Paging<VipPriceQueryVo> paging = vipPriceService.getVipPricePageList(vipPricePageParam);
// return ApiResult.ok(paging);
// }
// /**
// * 添加会员价格表
// */
// @PostMapping("/add")
// @OperationLog(name = "添加会员价格表", type = OperationLogType.ADD)
// @ApiOperation(value = "添加会员价格表")
// public ApiResult<Boolean> addVipPrice(@Validated(Add.class) @RequestBody VipPrice vipPrice) throws Exception {
// boolean flag = vipPriceService.saveVipPrice(vipPrice);
// return ApiResult.result(flag);
// }
//
// /**
// * 修改会员价格表
// */
// @PostMapping("/update")
// @OperationLog(name = "修改会员价格表", type = OperationLogType.UPDATE)
// @ApiOperation(value = "修改会员价格表")
// public ApiResult<Boolean> updateVipPrice(@Validated(Update.class) @RequestBody VipPrice vipPrice) throws Exception {
// boolean flag = vipPriceService.updateVipPrice(vipPrice);
// return ApiResult.result(flag);
// }
//
// /**
// * 删除会员价格表
// */
// @PostMapping("/delete/{id}")
// @OperationLog(name = "删除会员价格表", type = OperationLogType.DELETE)
// @ApiOperation(value = "删除会员价格表")
// public ApiResult<Boolean> deleteVipPrice(@PathVariable("id") Long id) throws Exception {
// boolean flag = vipPriceService.deleteVipPrice(id);
// return ApiResult.result(flag);
// }
//
// /**
// * 获取会员价格表详情
// */
// @GetMapping("/info/{id}")
// @OperationLog(name = "会员价格表详情", type = OperationLogType.INFO)
// @ApiOperation(value = "会员价格表详情")
// public ApiResult<VipPriceQueryVo> getVipPrice(@PathVariable("id") Long id) throws Exception {
// VipPriceQueryVo vipPriceQueryVo = vipPriceService.getVipPriceById(id);
// return ApiResult.ok(vipPriceQueryVo);
// }
}
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wecloud.im.convert;
import com.wecloud.im.entity.SysUser;
import io.geekidea.springbootplus.framework.shiro.vo.LoginUserVo;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
* 系统用户对象属性转换器
*
* @author geekidea
* @date 2019-10-05
**/
@Mapper
public interface UserConvert {
UserConvert INSTANCE = Mappers.getMapper(UserConvert.class);
/**
* 系统用户实体对象转换成登录用户VO对象
*
* @param sysUser
* @return
*/
LoginUserVo sysUserToLoginSysUserVo(SysUser sysUser);
}
package com.wecloud.im.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
* 替他人捐款记录表
*
* @author hewei
* @since 2021-02-25
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "DonationAgent对象")
public class DonationAgent extends BaseEntity {
private static final long serialVersionUID = 1L;
@NotNull(message = "id不能为空", groups = {Update.class})
@ApiModelProperty("主键")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@NotNull(message = "外键_捐款人_用户表id不能为空")
@ApiModelProperty("外键_捐款人_用户表id")
private Long fkUserId;
@NotNull(message = "外键_捐款表id不能为空")
@ApiModelProperty("外键_捐款表id")
private Long fkRecordId;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("修改时间")
private Date updateTime;
}
package com.wecloud.im.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;
/**
* 捐款记录
*
* @author hewei
* @since 2021-02-25
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "DonationRecord对象")
public class DonationRecord extends BaseEntity {
private static final long serialVersionUID = 1L;
@NotNull(message = "id不能为空", groups = {Update.class})
@ApiModelProperty("主键")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@NotNull(message = "外键_捐款人_用户表id不能为空")
@ApiModelProperty("外键_捐款人_用户表id")
private Long fkUserId;
@ApiModelProperty("捐款金额")
private BigDecimal money;
@ApiModelProperty("捐款用途;直接录入字符串: 助学助教,资助病残;慰问孤老,其他")
private String purpose;
@ApiModelProperty("捐款方式;1正常.2匿名,替他人捐款记录在donation_r agent表")
private Integer way;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("修改时间")
private Date updateTime;
@ApiModelProperty("是否为别人替我捐款")
private Integer isReplace;
@ApiModelProperty("微信商家订单id")
private String wxMerPayId;
@ApiModelProperty("支付状态,1已支付, 0未支付")
private Integer payStatus;
@ApiModelProperty("支付时间")
private Date payTime;
}
package com.wecloud.im.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.sql.Timestamp;
/**
* 优惠行程表
*
* @author xxx
* @since 2020-10-14
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "StrokeDiscount对象")
public class StrokeDiscount extends BaseEntity {
private static final long serialVersionUID = 1L;
@NotNull(message = "id不能为空", groups = {Update.class})
@ApiModelProperty("主键ID")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@NotNull(message = "出发城市id不能为空")
@ApiModelProperty("出发城市id")
private Long cityOutsetId;
@NotBlank(message = "出发城市名称不能为空")
@ApiModelProperty("出发城市名称")
private String cityOutsetName;
@NotNull(message = "到达城市id不能为空")
@ApiModelProperty("到达城市id")
private Long cityArriveId;
@NotBlank(message = "到达城市名称不能为空")
@ApiModelProperty("到达城市名称")
private String cityArriveName;
@NotNull(message = "座位数不能为空")
@ApiModelProperty("座位数")
private Integer seatNum;
@NotNull(message = "飞机型号ID不能为空")
@ApiModelProperty("飞机型号ID")
private Long plainTypeId;
@ApiModelProperty("飞机型号名称")
private String plainTypeName;
@NotNull(message = "出发时间不能为空")
@ApiModelProperty("出发时间")
private Timestamp outsetTime;
@ApiModelProperty("返程时间")
private Timestamp returnTime;
@NotNull(message = "状态,0-正常,1-完成,99-删除不能为空")
@ApiModelProperty("状态,0-正常,1-完成,99-删除")
private Integer status;
@NotNull(message = "创建时间不能为空")
@ApiModelProperty("创建时间")
private Timestamp createTime;
@ApiModelProperty("更新时间")
private Timestamp updateTime;
@ApiModelProperty("备注")
private String remarks;
@ApiModelProperty("价格")
private BigDecimal money;
@NotNull(message = "商家ID不能为空")
@ApiModelProperty("商家ID")
private Long mcId;
}
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wecloud.im.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.Version;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Null;
import java.util.Date;
/**
* <pre>
* 部门
* </pre>
*
* @author geekidea
* @since 2019-10-24
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "SysDepartment对象", description = "部门")
public class SysDepartment extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty("主键")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty("部门名称")
@NotBlank(message = "部门名称不能为空")
private String name;
@ApiModelProperty("父id")
private Long parentId;
@ApiModelProperty("状态,0:禁用,1:启用")
private Integer state;
@ApiModelProperty("排序")
private Integer sort;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty("版本")
@Null(message = "版本不用传")
@Version
private Integer version;
@ApiModelProperty("创建时间")
@Null(message = "创建时间不用传")
private Date createTime;
@ApiModelProperty("修改时间")
@Null(message = "修改时间不用传")
private Date updateTime;
}
package com.wecloud.im.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
* 系统通知表
*
* @author xxx
* @since 2020-11-06
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "SysNotice对象")
public class SysNotice extends BaseEntity {
private static final long serialVersionUID = 1L;
@NotNull(message = "id不能为空")
@ApiModelProperty("id")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty("主题")
private String theme;
@ApiModelProperty("内容")
private String content;
@ApiModelProperty("创建时间(时间戳)")
private Date createTime;
@ApiModelProperty("更新时间(时间戳)")
private Date updateTime;
@ApiModelProperty("状态,0-正常,1-禁用,99-删除")
private Integer status;
}
package com.wecloud.im.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
/**
* 系统通知已读 未读
*
* @author xxx
* @since 2020-11-06
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "SysNoticeRead对象")
public class SysNoticeRead extends BaseEntity {
private static final long serialVersionUID = 1L;
@NotNull(message = "不能为空")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@NotNull(message = "用户ID不能为空")
@ApiModelProperty("用户ID")
private Long userId;
@ApiModelProperty("0未读 1已读")
private Integer readStatus;
}
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wecloud.im.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.Version;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.util.Date;
/**
* <pre>
* 系统权限
* </pre>
*
* @author geekidea
* @since 2019-10-24
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "SysPermission对象", description = "系统权限")
public class SysPermission extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty("主键")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty("权限名称")
private String name;
@ApiModelProperty("父id")
private Long parentId;
@ApiModelProperty("路径")
private String url;
@ApiModelProperty("唯一编码")
@NotBlank(message = "唯一编码不能为空")
private String code;
@ApiModelProperty("图标")
private String icon;
@ApiModelProperty("类型,1:菜单,2:按钮")
@NotNull(message = "类型,1:菜单,2:按钮不能为空")
private Integer type;
@ApiModelProperty("层级,1:第一级,2:第二级,N:第N级")
@NotNull(message = "层级,1:第一级,2:第二级,N:第N级不能为空")
private Integer level;
@ApiModelProperty("状态,0:禁用,1:启用")
private Integer state;
@ApiModelProperty("排序")
private Integer sort;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty("版本")
@Null(message = "版本不用传")
@Version
private Integer version;
@ApiModelProperty("创建时间")
@Null(message = "创建时间不用传")
private Date createTime;
@ApiModelProperty("修改时间")
@Null(message = "修改时间不用传")
private Date updateTime;
}
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wecloud.im.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.Version;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.util.Date;
/**
* <pre>
* 系统角色
* </pre>
*
* @author geekidea
* @since 2019-10-24
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "SysRole对象", description = "系统角色")
public class SysRole extends BaseEntity {
private static final long serialVersionUID = -487738234353456553L;
@ApiModelProperty("主键")
@TableId(value = "id", type = IdType.AUTO)
@NotNull(groups = Update.class, message = "角色ID不能为空")
private Long id;
@ApiModelProperty("角色名称")
@NotBlank(message = "角色名称不能为空")
private String name;
@ApiModelProperty("角色唯一编码")
private String code;
@ApiModelProperty("角色类型")
private Integer type;
@ApiModelProperty("角色状态,0:禁用,1:启用")
private Integer state;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty("版本")
@Null(message = "版本不用传")
@Version
private Integer version;
@ApiModelProperty("创建时间")
@Null(message = "创建时间不用传")
private Date createTime;
@ApiModelProperty("修改时间")
@Null(message = "修改时间不用传")
private Date updateTime;
}
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wecloud.im.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.Version;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.util.Date;
/**
* <pre>
* 角色权限关系
* </pre>
*
* @author geekidea
* @since 2019-10-24
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "SysRolePermission对象", description = "角色权限关系")
public class SysRolePermission extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty("主键")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty("角色id")
@NotNull(message = "角色id不能为空")
private Long roleId;
@ApiModelProperty("权限id")
@NotNull(message = "权限id不能为空")
private Long permissionId;
@ApiModelProperty("状态,0:禁用,1:启用")
private Integer state;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty("版本")
@Null(message = "版本不用传")
@Version
private Integer version;
@ApiModelProperty("创建时间")
@Null(message = "创建时间不用传")
private Date createTime;
@ApiModelProperty("修改时间")
@Null(message = "修改时间不用传")
private Date updateTime;
}
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wecloud.im.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.Version;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.geekidea.springbootplus.framework.core.validator.groups.Add;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.util.Date;
/**
* <pre>
* 系统用户
* </pre>
*
* @author geekidea
* @since 2019-10-24
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "SysUser对象", description = "系统用户")
public class SysUser extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty("主键")
@NotNull(message = "ID不能为空", groups = {Update.class})
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty("用户名")
@NotNull(message = "用户名不能为空", groups = {Add.class})
private String username;
@ApiModelProperty("昵称")
private String nickname;
@ApiModelProperty("密码")
private String password;
@ApiModelProperty("盐值")
private String salt;
@ApiModelProperty("手机号码")
@NotBlank(message = "手机号码不能为空")
private String phone;
@ApiModelProperty("性别,0:女,1:男,默认1")
private Integer gender;
@ApiModelProperty("头像")
private String head;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty("状态,0:禁用,1:启用,2:锁定")
private Integer state;
@ApiModelProperty("部门id")
@NotNull(message = "部门id不能为空")
private Long departmentId;
@ApiModelProperty("角色id")
@NotNull(message = "角色id不能为空")
private Long roleId;
@ApiModelProperty("逻辑删除,0:未删除,1:已删除")
@Null(message = "逻辑删除不用传")
@TableLogic
private Integer deleted;
@ApiModelProperty("版本")
@Null(message = "版本不用传")
@Version
private Integer version;
@ApiModelProperty("创建时间")
@Null(message = "创建时间不用传")
private Date createTime;
@ApiModelProperty("修改时间")
@Null(message = "修改时间不用传")
private Date updateTime;
}
package com.wecloud.im.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
* app用户活跃记录表
*
* @author giao
* @since 2020-10-21
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "UserActiveRecord对象")
public class UserActiveRecord extends BaseEntity {
private static final long serialVersionUID = 1L;
@NotNull(message = "主键id不能为空")
@ApiModelProperty("主键id")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@NotNull(message = "用户id不能为空")
@ApiModelProperty("用户id")
private Long userId;
@NotNull(message = "记录日期不能为空")
@ApiModelProperty("记录日期")
private Date recordDate;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date modifyTime;
}
package com.wecloud.im.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.sql.Timestamp;
/**
* App版本控制
*
* @author giao
* @since 2020-10-26
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "VersionControl对象")
public class VersionControl extends BaseEntity {
private static final long serialVersionUID = 1L;
@NotNull(message = "id不能为空", groups = {Update.class})
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty("版本号")
private String versionName;
@ApiModelProperty("设备类型,1安卓,2 ios")
private Integer deviceType;
@ApiModelProperty("下载地址")
private String downloadUrl;
@ApiModelProperty("1:强更,0不强制")
private Integer forceUpdate;
@ApiModelProperty("创建时间")
private Timestamp createTime;
@ApiModelProperty("修改时间")
private Timestamp updateTime;
}
package com.wecloud.im.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;
/**
* 会员价格表
*
* @author xxx
* @since 2021-03-11
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "VipPrice对象")
public class VipPrice extends BaseEntity {
private static final long serialVersionUID = 1L;
@NotNull(message = "id不能为空", groups = {Update.class})
@ApiModelProperty("id")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty("会员价格")
private BigDecimal price;
@ApiModelProperty("会员类型(名称)")
private String memberShips;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("修改时间")
private Date updateTime;
@ApiModelProperty("状态,0:禁用,1:启用")
private Integer state;
}
package com.wecloud.im.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.geekidea.springbootplus.framework.common.entity.BaseEntity;
import io.geekidea.springbootplus.framework.core.validator.groups.Update;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;
/**
* 捐款记录
*
* @author hewei
* @since 2021-02-25
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "VipRecord对象")
public class VipRecord extends BaseEntity {
private static final long serialVersionUID = 1L;
@NotNull(message = "id不能为空", groups = {Update.class})
@ApiModelProperty("主键")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@NotNull(message = "外键_用户表不能为空")
@ApiModelProperty("外键_用户表")
private Long fkUserId;
@NotNull(message = "开通人,因为可以给其他人开通,所以要有对应的谁给我充值的不能为空")
@ApiModelProperty("开通人,因为可以给其他人开通,所以要有对应的谁给我充值的")
private Long fkRechargeUser;
@ApiModelProperty("开通会员金额")
private BigDecimal money;
@ApiModelProperty("到期时间")
private Date expiredAt;
@NotNull(message = "开通多久不能为空")
@ApiModelProperty("开通多久")
private Integer years;
// @NotBlank(message = "会员等级不能为空")
// @ApiModelProperty("会员等级")
// private String vipLevel;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("修改时间")
private Date updateTime;
@ApiModelProperty("微信商家订单id")
private String wxMerPayId;
@ApiModelProperty("支付状态,1已支付, 0未支付")
private Integer payStatus;
@ApiModelProperty("支付时间")
private Date payTime;
}
package com.wecloud.im.entity.base;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @ClassName ImgJson
* @Descripteion 请写点注释吧!
* @Date 2020/10/22 11:21
* @Version 1.0
**/
@Data
@ApiModel(value = "图片json对象")
public class ImgJson implements Serializable {
@ApiModelProperty("地址url")
private String url;
@ApiModelProperty("高")
private Long height;
@ApiModelProperty("宽")
private Long width;
}
package com.wecloud.im.enums;
import io.geekidea.springbootplus.framework.common.enums.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 审核状态,0审核中,1审核通过,2审核未通过
*/
@Getter
@AllArgsConstructor
public enum StrokeAuditStatusEnum implements BaseEnum {
UNDER_REVIEW(0, "审核中"),
AUDIT_OK(1, "审核通过"),
AUDIT_FAILED(2, "审核未通过"),
;
/**
* 编号
*/
private final Integer code;
/**
* 名称
*/
private final String desc;
}
package com.wecloud.im.enums;
import io.geekidea.springbootplus.framework.common.enums.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 状态,0-正常,1-完成,99-删除
*/
@Getter
@AllArgsConstructor
public enum StrokeDiscountStatusEnum implements BaseEnum {
OK(0, "正常"),
COMPLETE(1, "完成"),
CANCEL(99, "取消");
/**
* 编号
*/
private final Integer code;
/**
* 名称
*/
private final String desc;
}
package com.wecloud.im.enums;
import io.geekidea.springbootplus.framework.common.enums.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 状态,0-审核中,1-进行中,2-已完成,99-取消
*/
@Getter
@AllArgsConstructor
public enum StrokeStatusEnum implements BaseEnum {
UNDER_REVIEW(0, "审核中"),
PROCESSING(1, "进行中"),
COMPLETED(2, "已完成"),
CANCEL(99, "取消");
/**
* 编号
*/
private final Integer code;
/**
* 名称
*/
private final String desc;
}
package com.wecloud.im.enums;
import io.geekidea.springbootplus.framework.common.enums.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 行程类型,0-单程,1-往返行程,2-货运,3-医疗
*/
@Getter
@AllArgsConstructor
public enum StrokeTypeEnum implements BaseEnum {
ONE_WAY(0, "单程"),
ROUND_TRIP(1, "往返"),
CARGO_FLIGHT(2, "货运"),
MEDICAL_FLIGHT(3, "医疗"),
;
/**
* 编号
*/
private final Integer code;
/**
* 名称
*/
private final String desc;
}
package com.wecloud.im.factory;
import io.geekidea.springbootplus.config.properties.WxMpProperties;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.util.stream.Collectors;
public class GetWx {
private static WxMpProperties properties;
public static WxMpService getWxMpService() {
// 代码里 getConfigs()处报错的同学,请注意仔细阅读项目说明,你的IDE需要引入lombok插件!!!!
final List<WxMpProperties.MpConfig> configs = properties.getConfigs();
if (configs == null) {
throw new RuntimeException("添加下相关配置,注意别配错了!");
}
WxMpService service = new WxMpServiceImpl();
service.setMultiConfigStorages(configs
.stream().map(a -> {
WxMpDefaultConfigImpl configStorage;
//
configStorage = new WxMpDefaultConfigImpl();
configStorage.setAppId(a.getAppId());
configStorage.setSecret(a.getSecret());
configStorage.setToken(a.getToken());
configStorage.setAesKey(a.getAesKey());
return configStorage;
}).collect(Collectors.toMap(WxMpDefaultConfigImpl::getAppId, a -> a, (o, n) -> o)));
return service;
}
@Autowired
public void setProperties(WxMpProperties properties) {
this.properties = properties;
}
}
package com.wecloud.im.factory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author: JJww
* @Date:2020/11/5
*/
@Component
public class PushFactory {
@Autowired
private PushService umengIosPushServiceImpl;
@Autowired
private PushService umengAndroidPushServiceImpl;
/**
* 创建对应实现类
*
* @param type
* @return
*/
public PushService getService(Integer type) {
switch (type) {
case 1:
return umengAndroidPushServiceImpl;
case 2:
return umengIosPushServiceImpl;
default:
return null;
}
}
}
package com.wecloud.im.factory;
/**
* @author: JJww
* @Date:2020/11/5
*/
public interface PushService {
/**
* 单播
*
* @param deviceToken
*/
void unicast(String deviceToken);
void unicast(String deviceToken,String pushType,String title) throws Exception;
}
package com.wecloud.im.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wecloud.im.entity.AppUser;
import com.wecloud.im.param.AppUserPageParam;
import com.wecloud.im.vo.AppUserQueryVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.io.Serializable;
/**
* APP用户 Mapper 接口
*
* @author wei
* @since 2020-09-23
*/
@Repository
public interface AppUserMapper extends BaseMapper<AppUser> {
/**
* 根据ID获取查询对象
*
* @param id
* @return
*/
AppUserQueryVo getAppUserById(Serializable id);
/**
* 获取分页对象
*
* @param page
* @param appUserPageParam
* @return
*/
IPage<AppUserQueryVo> getAppUserPageList(@Param("page") Page page, @Param("param") AppUserPageParam appUserPageParam);
}
package com.wecloud.im.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wecloud.im.entity.DonationAgent;
import com.wecloud.im.param.DonationAgentPageParam;
import com.wecloud.im.vo.DonationAgentQueryVo;
import org.springframework.stereotype.Repository;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import java.io.Serializable;
/**
* 替他人捐款记录表 Mapper 接口
*
* @author hewei
* @since 2021-02-25
*/
@Repository
public interface DonationAgentMapper extends BaseMapper<DonationAgent> {
/**
* 根据ID获取查询对象
*
* @param id
* @return
*/
DonationAgentQueryVo getDonationAgentById(Serializable id);
/**
* 获取分页对象
*
* @param page
* @param donationAgentPageParam
* @return
*/
IPage<DonationAgentQueryVo> getDonationAgentPageList(@Param("page") Page page,@Param("param") DonationAgentPageParam donationAgentPageParam);
}
package com.wecloud.im.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wecloud.im.entity.DonationRecord;
import com.wecloud.im.param.DonationRecordPageParam;
import com.wecloud.im.vo.DonationRankAndTotal;
import com.wecloud.im.vo.DonationRecordQueryVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.io.Serializable;
/**
* 捐款记录 Mapper 接口
*
* @author hewei
* @since 2021-02-25
*/
@Repository
public interface DonationRecordMapper extends BaseMapper<DonationRecord> {
/**
* 根据ID获取查询对象
*
* @param id
* @return
*/
DonationRecordQueryVo getDonationRecordById(Serializable id);
/**
* 获取分页对象
*
* @param page
* @param donationRecordPageParam
* @return
*/
IPage<DonationRecordQueryVo> getDonationRecordPageList(@Param("page") Page page, @Param("param") DonationRecordPageParam donationRecordPageParam, @Param("userId") Long userId);
/**
* 查询捐款排名
*
* @param userId
* @return
*/
DonationRankAndTotal getDonationRankAndTotal(@Param("userId") Long userId);
}
package com.wecloud.im.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wecloud.im.entity.VipPrice;
import com.wecloud.im.param.VipPricePageParam;
import com.wecloud.im.vo.app.VipPriceQueryVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.io.Serializable;
/**
* 会员价格表 Mapper 接口
*
* @author xxx
* @since 2021-03-11
*/
@Repository
public interface VipPriceMapper extends BaseMapper<VipPrice> {
/**
* 根据ID获取查询对象
*
* @param id
* @return
*/
VipPriceQueryVo getVipPriceById(Serializable id);
/**
* 获取分页对象
*
* @param page
* @param vipPricePageParam
* @return
*/
IPage<VipPriceQueryVo> getVipPricePageList(@Param("page") Page page, @Param("param") VipPricePageParam vipPricePageParam);
}
package com.wecloud.im.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wecloud.im.entity.VipRecord;
import com.wecloud.im.param.VipRecordPageParam;
import com.wecloud.im.vo.VipRecordQueryVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.io.Serializable;
/**
* Vip开通记录 Mapper 接口
*
* @author hewei
* @since 2021-02-25
*/
@Repository
public interface VipRecordMapper extends BaseMapper<VipRecord> {
/**
* 根据ID获取查询对象
*
* @param id
* @return
*/
VipRecordQueryVo getVipRecordById(Serializable id);
/**
* 获取分页对象
*
* @param page
* @param vipRecordPageParam
* @return
*/
IPage<VipRecordQueryVo> getVipRecordPageList(@Param("page") Page page, @Param("param") VipRecordPageParam vipRecordPageParam);
}
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wecloud.im.param;
import io.geekidea.springbootplus.framework.shiro.service.LoginUsername;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* 登录参数
*
* @author geekidea
* @date 2019-05-15
**/
@Data
@ApiModel("登录参数")
public class LoginParam implements LoginUsername {
private static final long serialVersionUID = 2854217576695117356L;
@NotBlank(message = "请输入账号")
@ApiModelProperty(value = "账号", example = "admin")
private String username;
@NotBlank(message = "请输入密码")
@ApiModelProperty(value = "密码", example = "123456")
private String password;
@ApiModelProperty("验证码Token")
private String verifyToken;
@ApiModelProperty("验证码")
private String code;
}
package com.wecloud.im.param;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
/**
* <pre>
* 飞机型号表 分页参数对象
* </pre>
*
* @author wei
* @date 2020-10-09
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "飞机型号表分页参数")
public class PlainTypePageParam extends BasePageOrderParam {
private static final long serialVersionUID = 1L;
}
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.wecloud.im.param;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 注册参数
*
* @author geekidea
* @date 2019-05-15
**/
@Data
@ApiModel("登录参数")
public class RegisterParam implements Serializable {
private static final long serialVersionUID = 2854217576695117357L;
@NotBlank(message = "请输入手机号")
@ApiModelProperty(value = "手机号", example = "admin")
private String phone;
@NotBlank(message = "请输入密码")
@ApiModelProperty(value = "密码", example = "123456")
private String password;
//
// @ApiModelProperty("验证码Token")
// private String verifyToken;
//
// @ApiModelProperty("验证码")
// private String code;
}
package com.wecloud.im.param;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* <pre>
* 开通会员参数对象
* </pre>
*
* @author hewei
* @date 2021-02-25
*/
@Data
@Accessors(chain = true)
@ApiModel(value = "VipOpenParam")
public class VipOpenParam implements Serializable {
private static final long serialVersionUID = 1L;
// @ApiModelProperty("开通会员金额")
// private BigDecimal money;
@NotNull(message = "开通多久不能为空")
@ApiModelProperty("开通多少年")
private Integer years;
// @NotNull(message = "会员等级id不能为空")
@ApiModelProperty("会员等级id,传入由会员列表接口返回的id")
private Long vipLevelId;
@ApiModelProperty("是否代替他人开通")
private Integer isReplace;
@ApiModelProperty("捐款接收用户手机号,当isAgent=1为必填")
private String userPhone;
@ApiModelProperty("手机区号,当isAgent=1为必填")
private String phoneArea;
}
package com.wecloud.im.param;
import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <pre>
* 会员价格表 分页参数对象
* </pre>
*
* @author xxx
* @date 2021-03-11
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "会员价格表分页参数")
public class VipPricePageParam extends BasePageOrderParam {
private static final long serialVersionUID = 1L;
}
package com.wecloud.im.param;
import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* <pre>
* 开通会员参数对象
* </pre>
*
* @author hewei
* @date 2021-02-25
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "捐款记录分页参数")
public class VipRecordOpenParam extends BasePageOrderParam {
private static final long serialVersionUID = 1L;
// @ApiModelProperty("开通会员金额")
// private BigDecimal money;
@NotNull(message = "开通多久不能为空")
@ApiModelProperty("开通多少年")
private Integer years;
@NotBlank(message = "会员等级id不能为空")
@ApiModelProperty("会员等级id,传入由会员列表接口返回的id")
private Long vipLevelId;
@NotBlank(message = "不能为空")
@ApiModelProperty("是否代替他人开通")
private Boolean isReplace;
@ApiModelProperty("捐款接收用户手机号,当isAgent=1为必填")
private String userPhone;
@ApiModelProperty("手机区号,当isAgent=1为必填")
private String phoneArea;
}
package com.wecloud.im.param;
import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <pre>
* 捐款记录 分页参数对象
* </pre>
*
* @author hewei
* @date 2021-02-25
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "捐款记录分页参数")
public class VipRecordPageParam extends BasePageOrderParam{
private static final long serialVersionUID=1L;
}
package com.wecloud.im.push.jiguang;
import cn.jiguang.common.ClientConfig;
import cn.jiguang.common.ServiceHelper;
import cn.jiguang.common.connection.NativeHttpClient;
import cn.jiguang.common.connection.NettyHttpClient;
import cn.jiguang.common.resp.APIConnectionException;
import cn.jiguang.common.resp.APIRequestException;
import cn.jiguang.common.resp.ResponseWrapper;
import cn.jpush.api.JPushClient;
import cn.jpush.api.push.CIDResult;
import cn.jpush.api.push.GroupPushClient;
import cn.jpush.api.push.GroupPushResult;
import cn.jpush.api.push.PushResult;
import cn.jpush.api.push.model.*;
import cn.jpush.api.push.model.audience.Audience;
import cn.jpush.api.push.model.audience.AudienceTarget;
import cn.jpush.api.push.model.notification.*;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import io.netty.handler.codec.http.HttpMethod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
/**
* 极光推送Demo
*/
public class PushExample {
protected static final Logger LOG = LoggerFactory.getLogger(PushExample.class);
// demo App defined in resources/jpush-api.conf
protected static final String APP_KEY = "e4ceeaf7a53ad745dd4728f2";
protected static final String MASTER_SECRET = "1582b986adeaf48ceec1e354";
protected static final String GROUP_PUSH_KEY = "2c88a01e073a0fe4fc7b167c";
protected static final String GROUP_MASTER_SECRET = "b11314807507e2bcfdeebe2e";
public static final String TITLE = "标题Test from API example";
public static final String ALERT = "Test from API Example - alert";
public static final String MSG_CONTENT = "内容Test from API Example - msgContent";
public static final String REGISTRATION_ID = "0900e8d85ef";
public static final String TAG = "tag_api";
public static long sendCount = 0;
private static long sendTotalTime = 0;
public static void main(String[] args) {
// 回调参数可参考下面方法
testSendPushWithCustom();
testSendPushWithCustomField();
// testBatchSend();
testSendPushWithCustomConfig();
// testSendIosAlert();
// testSendPush();
// testGetCidList();
// testSendPushes();
testSendPush_fromJSON();
// testSendPushWithCallback();
// testSendPushWithCid();
}
// 使用 NettyHttpClient 异步接口发送请求
public static void testSendPushWithCallback() {
ClientConfig clientConfig = ClientConfig.getInstance();
String host = (String) clientConfig.get(ClientConfig.PUSH_HOST_NAME);
final NettyHttpClient client = new NettyHttpClient(ServiceHelper.getBasicAuthorization(APP_KEY, MASTER_SECRET),
null, clientConfig);
try {
URI uri = new URI(host + clientConfig.get(ClientConfig.PUSH_PATH));
PushPayload payload = buildPushObject_all_alias_alert();
client.sendRequest(HttpMethod.POST, payload.toString(), uri, new NettyHttpClient.BaseCallback() {
@Override
public void onSucceed(ResponseWrapper responseWrapper) {
LOG.info("Got result: " + responseWrapper.responseContent);
}
});
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
public static void testSendPush() {
ClientConfig clientConfig = ClientConfig.getInstance();
final JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY, null, clientConfig);
// String authCode = ServiceHelper.getBasicAuthorization(APP_KEY, MASTER_SECRET);
// Here you can use NativeHttpClient or NettyHttpClient or ApacheHttpClient.
// Call setHttpClient to set httpClient,
// If you don't invoke this method, default httpClient will use NativeHttpClient.
// ApacheHttpClient httpClient = new ApacheHttpClient(authCode, null, clientConfig);
// NettyHttpClient httpClient =new NettyHttpClient(authCode, null, clientConfig);
// jpushClient.getPushClient().setHttpClient(httpClient);
final PushPayload payload = buildPushObject_android_and_ios();
// // For push, all you need do is to build PushPayload object.
// PushPayload payload = buildPushObject_all_alias_alert();
try {
PushResult result = jpushClient.sendPush(payload);
LOG.info("Got result - " + result);
System.out.println(result);
// 如果使用 NettyHttpClient,需要手动调用 close 方法退出进程
// If uses NettyHttpClient, call close when finished sending request, otherwise process will not exit.
// jpushClient.close();
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
LOG.error("Sendno: " + payload.getSendno());
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
LOG.info("Msg ID: " + e.getMsgId());
LOG.error("Sendno: " + payload.getSendno());
}
}
public static void testSendPushWithEncrypt() {
ClientConfig clientConfig = ClientConfig.getInstance();
clientConfig.setEncryptType(EncryptKeys.ENCRYPT_SMS2_TYPE);
final JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY, null, clientConfig);
// String authCode = ServiceHelper.getBasicAuthorization(APP_KEY, MASTER_SECRET);
// Here you can use NativeHttpClient or NettyHttpClient or ApacheHttpClient.
// Call setHttpClient to set httpClient,
// If you don't invoke this method, default httpClient will use NativeHttpClient.
// ApacheHttpClient httpClient = new ApacheHttpClient(authCode, null, clientConfig);
// NettyHttpClient httpClient =new NettyHttpClient(authCode, null, clientConfig);
// jpushClient.getPushClient().setHttpClient(httpClient);
final PushPayload payload = buildPushObject_android_and_ios();
// // For push, all you need do is to build PushPayload object.
// PushPayload payload = buildPushObject_all_alias_alert();
try {
PushResult result = jpushClient.sendPush(payload);
LOG.info("Got result - " + result);
System.out.println(result);
// 如果使用 NettyHttpClient,需要手动调用 close 方法退出进程
// If uses NettyHttpClient, call close when finished sending request, otherwise process will not exit.
// jpushClient.close();
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
LOG.error("Sendno: " + payload.getSendno());
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
LOG.info("Msg ID: " + e.getMsgId());
LOG.error("Sendno: " + payload.getSendno());
}
}
//use String to build PushPayload instance
public static void testSendPush_fromJSON() {
ClientConfig clientConfig = ClientConfig.getInstance();
JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY, null, clientConfig);
Gson gson = new GsonBuilder()
.registerTypeAdapter(PlatformNotification.class, new InterfaceAdapter<PlatformNotification>())
.create();
// Since the type of DeviceType is enum, thus the value should be uppercase, same with the AudienceType.
String payloadString = "{\"platform\":{\"all\":false,\"deviceTypes\":[\"IOS\"]},\"audience\":{\"all\":true,\"targets\":[{\"audienceType\":\"TAG_AND\",\"values\":[\"tag1\",\"tag_all\"]}]},\"notification\":{\"notifications\":[{\"soundDisabled\":false,\"badgeDisabled\":false,\"sound\":\"happy\",\"badge\":\"5\",\"contentAvailable\":false,\"alert\":\"Test from API Example - alert\",\"extras\":{\"from\":\"JPush\"},\"type\":\"cn.jpush.api.push.model.notification.IosNotification\"}]},\"message\":{\"msgContent\":\"Test from API Example - msgContent\"},\"options\":{\"sendno\":1429488213,\"overrideMsgId\":0,\"timeToLive\":-1,\"apnsProduction\":true,\"bigPushDuration\":0}}";
PushPayload payload = gson.fromJson(payloadString, PushPayload.class);
try {
PushResult result = jpushClient.sendPush(payloadString);
LOG.info("Got result - " + result);
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
// LOG.error("Sendno: " + payload.getSendno());
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
LOG.info("Msg ID: " + e.getMsgId());
//LOG.error("Sendno: " + payload.getSendno());
}
}
/**
* 测试多线程发送 2000 条推送耗时
*/
public static void testSendPushes() {
ClientConfig clientConfig = ClientConfig.getInstance();
final JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY, null, clientConfig);
String authCode = ServiceHelper.getBasicAuthorization(APP_KEY, MASTER_SECRET);
// Here you can use NativeHttpClient or NettyHttpClient or ApacheHttpClient.
NativeHttpClient httpClient = new NativeHttpClient(authCode, null, clientConfig);
// Call setHttpClient to set httpClient,
// If you don't invoke this method, default httpClient will use NativeHttpClient.
// ApacheHttpClient httpClient = new ApacheHttpClient(authCode, null, clientConfig);
jpushClient.getPushClient().setHttpClient(httpClient);
final PushPayload payload = buildPushObject_ios_tagAnd_alertWithExtrasAndMessage();
for (int i = 0; i < 10; i++) {
Thread thread = new Thread() {
public void run() {
for (int j = 0; j < 200; j++) {
long start = System.currentTimeMillis();
try {
PushResult result = jpushClient.sendPush(payload);
LOG.info("Got result - " + result);
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
LOG.error("Sendno: " + payload.getSendno());
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
LOG.info("Msg ID: " + e.getMsgId());
LOG.error("Sendno: " + payload.getSendno());
}
System.out.println("耗时" + (System.currentTimeMillis() - start) + "毫秒 sendCount:" + (++sendCount));
}
}
};
thread.start();
}
}
public void testSendGroupPush() {
GroupPushClient groupPushClient = new GroupPushClient(GROUP_MASTER_SECRET, GROUP_PUSH_KEY);
final PushPayload payload = buildPushObject_android_and_ios();
try {
GroupPushResult groupPushResult = groupPushClient.sendGroupPush(payload);
Map<String, PushResult> result = groupPushResult.getAppResultMap();
for (Map.Entry<String, PushResult> entry : result.entrySet()) {
PushResult pushResult = entry.getValue();
PushResult.Error error = pushResult.error;
if (error != null) {
LOG.info("AppKey: " + entry.getKey() + " error code : " + error.getCode() + " error message: " + error.getMessage());
} else {
LOG.info("AppKey: " + entry.getKey() + " sendno: " + pushResult.sendno + " msg_id:" + pushResult.msg_id);
}
}
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
LOG.error("Sendno: " + payload.getSendno());
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
LOG.info("Msg ID: " + e.getMsgId());
LOG.error("Sendno: " + payload.getSendno());
}
}
public static PushPayload buildPushObject_all_all_alert() {
return PushPayload.alertAll(ALERT);
}
public static PushPayload buildPushObject_all_alias_alert() {
return PushPayload.newBuilder()
.setPlatform(Platform.all())
.setAudience(Audience.alias("alias1"))
.setNotification(Notification.alert(ALERT))
.build();
}
public static PushPayload buildPushObject_android_tag_alertWithTitle() {
return PushPayload.newBuilder()
.setPlatform(Platform.android())
.setAudience(Audience.tag("tag1"))
.setNotification(Notification.android(ALERT, TITLE, null))
.build();
}
public static PushPayload buildPushObject_android_and_ios() {
Map<String, String> extras = new HashMap<String, String>();
extras.put("test", "https://community.jiguang.cn/push");
return PushPayload.newBuilder()
.setPlatform(Platform.android_ios())
.setAudience(Audience.all())
.setNotification(Notification.newBuilder()
.setAlert("alert content")
.addPlatformNotification(AndroidNotification.newBuilder()
.setTitle("Android Title")
.addExtras(extras).build())
.addPlatformNotification(IosNotification.newBuilder()
.incrBadge(1)
.addExtra("extra_key", "extra_value").build())
.build())
.build();
}
public static void buildPushObject_with_extra() {
JsonObject jsonExtra = new JsonObject();
jsonExtra.addProperty("extra1", 1);
jsonExtra.addProperty("extra2", false);
Map<String, String> extras = new HashMap<String, String>();
extras.put("extra_1", "val1");
extras.put("extra_2", "val2");
PushPayload payload = PushPayload.newBuilder()
.setPlatform(Platform.android_ios())
.setAudience(Audience.tag("tag1"))
.setNotification(Notification.newBuilder()
.setAlert("alert content")
.addPlatformNotification(AndroidNotification.newBuilder()
.setTitle("Android Title")
.addExtras(extras)
.addExtra("booleanExtra", false)
.addExtra("numberExtra", 1)
.addExtra("jsonExtra", jsonExtra)
.build())
.addPlatformNotification(IosNotification.newBuilder()
.incrBadge(1)
.addExtra("extra_key", "extra_value").build())
.build())
.build();
System.out.println(payload.toJSON());
}
public static PushPayload buildPushObject_ios_tagAnd_alertWithExtrasAndMessage() {
JsonObject sound = new JsonObject();
sound.add("critical", new JsonPrimitive(1));
sound.add("name", new JsonPrimitive("default"));
sound.add("volume", new JsonPrimitive(0.2));
return PushPayload.newBuilder()
.setPlatform(Platform.ios())
.setAudience(Audience.tag_and("tag1", "tag_all"))
.setNotification(Notification.newBuilder()
.addPlatformNotification(IosNotification.newBuilder()
.setAlert(ALERT)
.setBadge(5)
.setMutableContent(false)
// .setSound("happy")
.setSound(sound)
.addExtra("from", "JPush")
.build())
.build())
.setMessage(Message.content(MSG_CONTENT))
.setOptions(Options.newBuilder()
.setApnsProduction(true)
.build())
.build();
}
public static PushPayload buildPushObject_android_newly_support() {
JsonObject inbox = new JsonObject();
inbox.add("line1", new JsonPrimitive("line1 string"));
inbox.add("line2", new JsonPrimitive("line2 string"));
inbox.add("contentTitle", new JsonPrimitive("title string"));
inbox.add("summaryText", new JsonPrimitive("+3 more"));
JsonObject intent = new JsonObject();
intent.add("url", new JsonPrimitive("intent:#Intent;component=com.jiguang.push/com.example.jpushdemo.SettingActivity;end"));
Notification notification = Notification.newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder()
.setAlert(ALERT)
.setBigPicPath("path to big picture")
.setBigText("long text")
.setBuilderId(1)
.setCategory("CATEGORY_SOCIAL")
.setInbox(inbox)
.setStyle(1)
.setTitle("Alert test")
.setPriority(1)
.setLargeIcon("http://www.jiguang.cn/largeIcon.jpg")
.setIntent(intent)
.build())
.build();
return PushPayload.newBuilder()
.setPlatform(Platform.all())
.setAudience(Audience.all())
.setNotification(notification)
.setOptions(Options.newBuilder()
.setApnsProduction(true)
.setSendno(ServiceHelper.generateSendno())
.build())
.build();
}
public static PushPayload buildPushObject_ios_audienceMore_messageWithExtras() {
return PushPayload.newBuilder()
.setPlatform(Platform.android_ios())
.setAudience(Audience.newBuilder()
.addAudienceTarget(AudienceTarget.tag("tag1", "tag2"))
.addAudienceTarget(AudienceTarget.alias("alias1", "alias2"))
.build())
.setMessage(Message.newBuilder()
.setMsgContent(MSG_CONTENT)
.addExtra("from", "JPush")
.build())
.build();
}
public static PushPayload buildPushObject_all_tag_not() {
return PushPayload.newBuilder()
.setPlatform(Platform.all())
.setAudience(Audience.tag_not("abc", "123"))
.setNotification(Notification.alert(ALERT))
.build();
}
public static PushPayload buildPushObject_android_cid() {
Collection<String> list = new LinkedList<String>();
list.add("1507bfd3f79558957de");
list.add("1507bfd3f79554957de");
list.add("1507bfd3f79555957de");
list.add("1507bfd3f79556957de");
list.add("1507ffd3f79545957de");
list.add("1507ffd3f79457957de");
list.add("1507ffd3f79456757de");
return PushPayload.newBuilder()
.setPlatform(Platform.android())
// .setAudience(Audience.registrationId("1507bfd3f79558957de"))
.setAudience(Audience.registrationId(list))
.setNotification(Notification.alert(ALERT))
.setCid("cid")
.build();
}
public static void testSendPushWithCustomConfig() {
ClientConfig config = ClientConfig.getInstance();
// Setup the custom hostname
config.setPushHostName("https://api.jpush.cn");
JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY, null, config);
// For push, all you need do is to build PushPayload object.
PushPayload payload = buildPushObject_all_all_alert();
try {
PushResult result = jpushClient.sendPush(payload);
LOG.info("Got result - " + result);
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
LOG.info("Msg ID: " + e.getMsgId());
}
}
public static void testSendIosAlert() {
JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
IosAlert alert = IosAlert.newBuilder()
.setTitleAndBody("test alert", "subtitle", "test ios alert json")
.setActionLocKey("PLAY")
.build();
try {
PushResult result = jpushClient.sendIosNotificationWithAlias(alert, new HashMap<String, String>(), "alias1");
LOG.info("Got result - " + result);
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
}
}
public static void testSendWithSMS() {
JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY);
try {
// SMS sms = SMS.content(1, 10);
SMS sms = SMS.newBuilder()
.setDelayTime(1000)
.setTempID(2000)
.addPara("Test", 1)
.build();
PushResult result = jpushClient.sendAndroidMessageWithAlias("Test SMS", "test sms", sms, "alias1");
LOG.info("Got result - " + result);
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
}
}
public static void testGetCidList() {
JPushClient jPushClient = new JPushClient(MASTER_SECRET, APP_KEY);
try {
CIDResult result = jPushClient.getCidList(3, "push");
LOG.info("Got result - " + result);
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
}
}
public static void testSendPushWithCid() {
JPushClient jPushClient = new JPushClient(MASTER_SECRET, APP_KEY);
PushPayload pushPayload = buildPushObject_android_cid();
try {
PushResult result = jPushClient.sendPush(pushPayload);
LOG.info("Got result - " + result);
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
}
}
/**
* 批量单推接口
* https://docs.jiguang.cn/jpush/server/push/rest_api_v3_push/#vip
*/
public static void testBatchSend() {
JPushClient jPushClient = new JPushClient(MASTER_SECRET, APP_KEY);
try {
{
List<PushPayload> pushPayloadList = new ArrayList<>();
PushPayload.Builder builder1 = PushPayload.newBuilder();
builder1.setMessage(Message.content("content1 by alias"))
.setNotification(Notification.alert(ALERT))
.setPlatform(Platform.all())
.setAudience(Audience.all())
.setOptions(Options.sendno())
.setTarget("1507ffd3f79456757de");
pushPayloadList.add(builder1.build());
PushPayload.Builder builder2 = PushPayload.newBuilder();
builder2.setMessage(Message.content("content2 by alias"))
.setNotification(Notification.alert(ALERT))
.setPlatform(Platform.android())
.setAudience(Audience.all())
.setOptions(Options.sendno())
.setTarget("1507ffd3f79456757de");
pushPayloadList.add(builder2.build());
BatchPushResult result = jPushClient.batchSendPushByAlias(pushPayloadList);
LOG.info("batchSendPushByAlias param: {}, result: {}", pushPayloadList, new Gson().toJson(result.getBatchPushResult()));
}
{
List<PushPayload> pushPayloadList = new ArrayList<>();
PushPayload.Builder builder1 = PushPayload.newBuilder();
builder1.setMessage(Message.content("content1 by regId"))
.setNotification(Notification.alert(ALERT))
.setPlatform(Platform.android())
.setAudience(Audience.all())
.setOptions(Options.sendno())
.setTarget("1507ffd3f79456757de");
pushPayloadList.add(builder1.build());
PushPayload.Builder builder2 = PushPayload.newBuilder();
builder2.setMessage(Message.content("content2 by regId"))
.setNotification(Notification.alert(ALERT))
.setAudience(Audience.all())
.setPlatform(Platform.ios())
.setOptions(Options.sendno())
.setTarget("1507ffd3f79456757de");
pushPayloadList.add(builder2.build());
BatchPushResult result = jPushClient.batchSendPushByRegId(pushPayloadList);
LOG.info("batchSendPushByRegId param: {}, result: {}", pushPayloadList, new Gson().toJson(result.getBatchPushResult()));
}
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
}
}
/**
* 自定义发送参数名称, 华为客户可参考该方法
*/
public static void testSendPushWithCustomField() {
ClientConfig config = ClientConfig.getInstance();
// Setup the custom hostname
config.setPushHostName("https://api.jpush.cn");
JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY, null, config);
Notification notification = Notification.newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder()
.setAlert(ALERT)
.setTitle("Alert test")
.setLargeIcon("http://www.jiguang.cn/largeIcon.jpg")
.addCustom("uri_activity", "uri_activity")
.addCustom("uri_flag", "uri_flag")
.addCustom("uri_action", "uri_action")
.build())
.build();
PushPayload.Builder payloadBuilder = new PushPayload.Builder()
.setPlatform(Platform.all())
.setAudience(Audience.all())
.setNotification(notification);
try {
PushResult result = jpushClient.sendPush(payloadBuilder.build());
LOG.info("Got result - " + result);
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
LOG.info("Msg ID: " + e.getMsgId());
}
}
/**
* 回调参数示例
*/
public static void testSendPushWithCustom() {
ClientConfig config = ClientConfig.getInstance();
// Setup the custom hostname
config.setPushHostName("https://api.jpush.cn");
JPushClient jpushClient = new JPushClient(MASTER_SECRET, APP_KEY, null, config);
Notification notification = Notification.newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder()
.setAlert(ALERT)
.setTitle("Alert test")
.build())
.build();
JsonObject callback = new JsonObject();
callback.addProperty("url", "https://www.jiguagn.cn/callback");
JsonObject params = new JsonObject();
params.addProperty("name", "joe");
params.addProperty("age", 26);
callback.add("params", params);
callback.addProperty("type", 3);
PushPayload.Builder payloadBuilder = new PushPayload.Builder()
.setPlatform(Platform.all())
.setAudience(Audience.all())
.setNotification(notification)
.addCustom("callback", callback);
try {
PushResult result = jpushClient.sendPush(payloadBuilder.build());
LOG.info("Got result - " + result);
} catch (APIConnectionException e) {
LOG.error("Connection error. Should retry later. ", e);
} catch (APIRequestException e) {
LOG.error("Error response from JPush server. Should review and fix it. ", e);
LOG.info("HTTP Status: " + e.getStatus());
LOG.info("Error Code: " + e.getErrorCode());
LOG.info("Error Message: " + e.getErrorMessage());
LOG.info("Msg ID: " + e.getMsgId());
}
}
}
package com.wecloud.im.push.umeng;
import org.json.JSONObject;
import java.util.Arrays;
import java.util.HashSet;
public abstract class AndroidNotification extends UmengNotification {
// Keys can be set in the payload level
protected static final HashSet<String> PAYLOAD_KEYS = new HashSet<String>(Arrays.asList("display_type"));
// Keys can be set in the body level
protected static final HashSet<String> BODY_KEYS = new HashSet<String>(Arrays.asList("ticker", "title", "text", "builder_id", "icon", "largeIcon", "img", "play_vibrate", "play_lights", "play_sound",
"sound", "after_open", "url", "activity", "custom"));
// Set key/value in the rootJson, for the keys can be set please see ROOT_KEYS, PAYLOAD_KEYS,
// BODY_KEYS and POLICY_KEYS.
@Override
public boolean setPredefinedKeyValue(String key, Object value) throws Exception {
if (ROOT_KEYS.contains(key)) {
// This key should be in the root level
rootJson.put(key, value);
} else if (PAYLOAD_KEYS.contains(key)) {
// This key should be in the payload level
JSONObject payloadJson = null;
if (rootJson.has("payload")) {
payloadJson = rootJson.getJSONObject("payload");
} else {
payloadJson = new JSONObject();
rootJson.put("payload", payloadJson);
}
payloadJson.put(key, value);
} else if (BODY_KEYS.contains(key)) {
// This key should be in the body level
JSONObject bodyJson = null;
JSONObject payloadJson = null;
// 'body' is under 'payload', so build a payload if it doesn't exist
if (rootJson.has("payload")) {
payloadJson = rootJson.getJSONObject("payload");
} else {
payloadJson = new JSONObject();
rootJson.put("payload", payloadJson);
}
// Get body JSONObject, generate one if not existed
if (payloadJson.has("body")) {
bodyJson = payloadJson.getJSONObject("body");
} else {
bodyJson = new JSONObject();
payloadJson.put("body", bodyJson);
}
bodyJson.put(key, value);
} else if (POLICY_KEYS.contains(key)) {
// This key should be in the body level
JSONObject policyJson = null;
if (rootJson.has("policy")) {
policyJson = rootJson.getJSONObject("policy");
} else {
policyJson = new JSONObject();
rootJson.put("policy", policyJson);
}
policyJson.put(key, value);
} else {
if (key == "payload" || key == "body" || key == "policy" || key == "extra") {
throw new Exception("You don't need to set value for " + key + " , just set values for the sub keys in it.");
} else {
throw new Exception("Unknown key: " + key);
}
}
return true;
}
// Set extra key/value for Android notification
public boolean setExtraField(String key, String value) throws Exception {
JSONObject payloadJson = null;
JSONObject extraJson = null;
if (rootJson.has("payload")) {
payloadJson = rootJson.getJSONObject("payload");
} else {
payloadJson = new JSONObject();
rootJson.put("payload", payloadJson);
}
if (payloadJson.has("extra")) {
extraJson = payloadJson.getJSONObject("extra");
} else {
extraJson = new JSONObject();
payloadJson.put("extra", extraJson);
}
extraJson.put(key, value);
return true;
}
//
public void setDisplayType(DisplayType d) throws Exception {
setPredefinedKeyValue("display_type", d.getValue());
}
///通知栏提示文字
public void setTicker(String ticker) throws Exception {
setPredefinedKeyValue("ticker", ticker);
}
///通知标题
public void setTitle(String title) throws Exception {
setPredefinedKeyValue("title", title);
}
///通知文字描述
public void setText(String text) throws Exception {
setPredefinedKeyValue("text", text);
}
///用于标识该通知采用的样式。使用该参数时, 必须在SDK里面实现自定义通知栏样式。
public void setBuilderId(Integer builder_id) throws Exception {
setPredefinedKeyValue("builder_id", builder_id);
}
///状态栏图标ID, R.drawable.[smallIcon],如果没有, 默认使用应用图标。
public void setIcon(String icon) throws Exception {
setPredefinedKeyValue("icon", icon);
}
///通知栏拉开后左侧图标ID
public void setLargeIcon(String largeIcon) throws Exception {
setPredefinedKeyValue("largeIcon", largeIcon);
}
///通知栏大图标的URL链接。该字段的优先级大于largeIcon。该字段要求以http或者https开头。
public void setImg(String img) throws Exception {
setPredefinedKeyValue("img", img);
}
///收到通知是否震动,默认为"true"
public void setPlayVibrate(Boolean play_vibrate) throws Exception {
setPredefinedKeyValue("play_vibrate", play_vibrate.toString());
}
///收到通知是否闪灯,默认为"true"
public void setPlayLights(Boolean play_lights) throws Exception {
setPredefinedKeyValue("play_lights", play_lights.toString());
}
///收到通知是否发出声音,默认为"true"
public void setPlaySound(Boolean play_sound) throws Exception {
setPredefinedKeyValue("play_sound", play_sound.toString());
}
///通知声音,R.raw.[sound]. 如果该字段为空,采用SDK默认的声音
public void setSound(String sound) throws Exception {
setPredefinedKeyValue("sound", sound);
}
///收到通知后播放指定的声音文件
public void setPlaySound(String sound) throws Exception {
setPlaySound(true);
setSound(sound);
}
///点击"通知"的后续行为,默认为打开app。
public void goAppAfterOpen() throws Exception {
setAfterOpenAction(AfterOpenAction.go_app);
}
public void goUrlAfterOpen(String url) throws Exception {
setAfterOpenAction(AfterOpenAction.go_url);
setUrl(url);
}
public void goActivityAfterOpen(String activity) throws Exception {
setAfterOpenAction(AfterOpenAction.go_activity);
setActivity(activity);
}
public void goCustomAfterOpen(String custom) throws Exception {
setAfterOpenAction(AfterOpenAction.go_custom);
setCustomField(custom);
}
public void goCustomAfterOpen(JSONObject custom) throws Exception {
setAfterOpenAction(AfterOpenAction.go_custom);
setCustomField(custom);
}
///点击"通知"的后续行为,默认为打开app。原始接口
public void setAfterOpenAction(AfterOpenAction action) throws Exception {
setPredefinedKeyValue("after_open", action.toString());
}
public void setUrl(String url) throws Exception {
setPredefinedKeyValue("url", url);
}
public void setActivity(String activity) throws Exception {
setPredefinedKeyValue("activity", activity);
}
///can be a string of json
public void setCustomField(String custom) throws Exception {
setPredefinedKeyValue("custom", custom);
}
public void setCustomField(JSONObject custom) throws Exception {
setPredefinedKeyValue("custom", custom);
}
public enum DisplayType {
NOTIFICATION {
public String getValue() {
return "notification";
}
},///通知:消息送达到用户设备后,由友盟SDK接管处理并在通知栏上显示通知内容。
MESSAGE {
public String getValue() {
return "message";
}
};///消息:消息送达到用户设备后,消息内容透传给应用自身进行解析处理。
public abstract String getValue();
}
public enum AfterOpenAction {
go_app,//打开应用
go_url,//跳转到URL
go_activity,//打开特定的activity
go_custom//用户自定义内容。
}
}
package com.wecloud.im.push.umeng;
public class App {
}
package com.wecloud.im.push.umeng;
import com.wecloud.im.push.umeng.android.AndroidBroadcast;
import com.wecloud.im.push.umeng.android.AndroidCustomizedcast;
import com.wecloud.im.push.umeng.android.AndroidFilecast;
import com.wecloud.im.push.umeng.android.AndroidGroupcast;
import com.wecloud.im.push.umeng.android.AndroidUnicast;
import com.wecloud.im.push.umeng.ios.IOSBroadcast;
import com.wecloud.im.push.umeng.ios.IOSCustomizedcast;
import com.wecloud.im.push.umeng.ios.IOSFilecast;
import com.wecloud.im.push.umeng.ios.IOSGroupcast;
import com.wecloud.im.push.umeng.ios.IOSUnicast;
import org.json.JSONArray;
import org.json.JSONObject;
public class Demo {
private String appkey = null;
private String appMasterSecret = null;
private final String timestamp = null;
private final PushClient client = new PushClient();
public Demo(String key, String secret) {
try {
appkey = key;
appMasterSecret = secret;
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
public static void main(String[] args) {
// AppKey:5f963f3ea1491772a2aef713
//
// Umeng Message Secret
// 1c37c3d437d76c1235ee19bcb9d2d8c6
// App Master Secret
// ti5gomxtvmkgehmwgtbq9rtsfhy0khsi
// set your appkey and master secret here
// Demo demo = new Demo("your appkey", "your master secret");
Demo demo = new Demo("5f963f3ea1491772a2aef713", "ti5gomxtvmkgehmwgtbq9rtsfhy0khsi");
try {
demo.sendAndroidUnicast("As3YYnUpKwDLFVzc35_syVTNSctGjkDNfFLwPHGbXtm_");
//demo.sendIOSUnicast();
/* these methods are all available, just fill in some fields and do the test
* demo.sendAndroidCustomizedcastFile();
* demo.sendAndroidBroadcast();
* demo.sendAndroidGroupcast();
* demo.sendAndroidCustomizedcast();
* demo.sendAndroidFilecast();
*
* demo.sendIOSBroadcast();
* demo.sendIOSUnicast();
* demo.sendIOSGroupcast();
* demo.sendIOSCustomizedcast();
* demo.sendIOSFilecast();
*/
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void sendAndroidBroadcast() throws Exception {
AndroidBroadcast broadcast = new AndroidBroadcast(appkey, appMasterSecret);
broadcast.setTicker("Android broadcast ticker");
broadcast.setTitle("中文的title");
broadcast.setText("Android broadcast text");
broadcast.goAppAfterOpen();
broadcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
// Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
broadcast.setProductionMode();
// Set customized fields
broadcast.setExtraField("test", "helloworld");
//厂商通道相关参数
broadcast.setChannelActivity("your channel activity");
broadcast.setChannelProperties("abc");
client.send(broadcast);
}
/**
* 发送安卓单推
*
* @throws Exception
*/
public void sendAndroidUnicast(String token) throws Exception {
AndroidUnicast unicast = new AndroidUnicast(appkey, appMasterSecret);
// Set your device token
unicast.setDeviceToken(token);
unicast.setTicker("Android unicast ticker");
unicast.setTitle("api 中文的title");
unicast.setText("Android unicast text");
unicast.goAppAfterOpen();
unicast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
// Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
unicast.setProductionMode();
// Set customized fields
unicast.setExtraField("test", "helloworld");
unicast.setChannelActivity("your channel activity");
unicast.setChannelProperties("abc");
client.send(unicast);
}
public void sendAndroidGroupcast() throws Exception {
AndroidGroupcast groupcast = new AndroidGroupcast(appkey, appMasterSecret);
/*
* Construct the filter condition:
* "where":
* {
* "and":
* [
* {"tag":"test"},
* {"tag":"Test"}
* ]
* }
*/
JSONObject filterJson = new JSONObject();
JSONObject whereJson = new JSONObject();
JSONArray tagArray = new JSONArray();
JSONObject testTag = new JSONObject();
JSONObject TestTag = new JSONObject();
testTag.put("tag", "test");
TestTag.put("tag", "Test");
tagArray.put(testTag);
tagArray.put(TestTag);
whereJson.put("and", tagArray);
filterJson.put("where", whereJson);
groupcast.setFilter(filterJson);
groupcast.setTicker("Android groupcast ticker");
groupcast.setTitle("中文的title");
groupcast.setText("Android groupcast text");
groupcast.goAppAfterOpen();
groupcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
groupcast.setChannelActivity("your channel activity");
// Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
groupcast.setProductionMode();
//厂商通道相关参数
groupcast.setChannelActivity("your channel activity");
groupcast.setChannelProperties("abc");
client.send(groupcast);
}
public void sendAndroidCustomizedcast() throws Exception {
AndroidCustomizedcast customizedcast = new AndroidCustomizedcast(appkey, appMasterSecret);
// Set your alias here, and use comma to split them if there are multiple alias.
// And if you have many alias, you can also upload a file containing these alias, then
// use file_id to send customized notification.
customizedcast.setAlias("alias", "alias_type");
customizedcast.setTicker("Android customizedcast ticker");
customizedcast.setTitle("中文的title");
customizedcast.setText("Android customizedcast text");
customizedcast.goAppAfterOpen();
customizedcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
// Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
customizedcast.setProductionMode();
//厂商通道相关参数
customizedcast.setChannelActivity("your channel activity");
customizedcast.setChannelProperties("abc");
client.send(customizedcast);
}
public void sendAndroidCustomizedcastFile() throws Exception {
AndroidCustomizedcast customizedcast = new AndroidCustomizedcast(appkey, appMasterSecret);
// Set your alias here, and use comma to split them if there are multiple alias.
// And if you have many alias, you can also upload a file containing these alias, then
// use file_id to send customized notification.
String fileId = client.uploadContents(appkey, appMasterSecret, "aa" + "\n" + "bb" + "\n" + "alias");
customizedcast.setFileId(fileId, "alias_type");
customizedcast.setTicker("Android customizedcast ticker");
customizedcast.setTitle("中文的title");
customizedcast.setText("Android customizedcast text");
customizedcast.goAppAfterOpen();
customizedcast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
// Set 'production_mode' to 'false' if it's a test device.
// For how to register a test device, please see the developer doc.
customizedcast.setProductionMode();
//厂商通道相关参数
customizedcast.setChannelActivity("your channel activity");
customizedcast.setChannelProperties("abc");
client.send(customizedcast);
}
public void sendAndroidFilecast() throws Exception {
AndroidFilecast filecast = new AndroidFilecast(appkey, appMasterSecret);
// upload your device tokens, and use '\n' to split them if there are multiple tokens
String fileId = client.uploadContents(appkey, appMasterSecret, "aa" + "\n" + "bb");
filecast.setFileId(fileId);
filecast.setTicker("Android filecast ticker");
filecast.setTitle("中文的title");
filecast.setText("Android filecast text");
filecast.goAppAfterOpen();
filecast.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
//厂商通道相关参数
filecast.setChannelActivity("your channel activity");
filecast.setChannelProperties("abc");
client.send(filecast);
}
public void sendIOSBroadcast() throws Exception {
IOSBroadcast broadcast = new IOSBroadcast(appkey, appMasterSecret);
//alert值设置为字符串
//broadcast.setAlert("IOS 广播测试");
//alert的值设置为字典
broadcast.setAlert("今日天气", "", "今日可能下雨🌂");
broadcast.setBadge(0);
broadcast.setSound("default");
// set 'production_mode' to 'true' if your app is under production mode
broadcast.setTestMode();
// Set customized fields
broadcast.setCustomizedField("test", "helloworld");
client.send(broadcast);
}
public void sendIOSUnicast() throws Exception {
IOSUnicast unicast = new IOSUnicast(appkey, appMasterSecret);
// Set your device token
unicast.setDeviceToken("your device_token");
//alert值设置为字符串
//unicast.setAlert("IOS 单播测试");
//alert的值设置为字典
unicast.setAlert("今日天气", "", "今日可能下雨🌂");
unicast.setBadge(0);
unicast.setSound("default");
// set 'production_mode' to 'true' if your app is under production mode
unicast.setTestMode();
// Set customized fields
unicast.setCustomizedField("test", "helloworld");
client.send(unicast);
}
public void sendIOSGroupcast() throws Exception {
IOSGroupcast groupcast = new IOSGroupcast(appkey, appMasterSecret);
/*
* Construct the filter condition:
* "where":
* {
* "and":
* [
* {"tag":"iostest"}
* ]
* }
*/
JSONObject filterJson = new JSONObject();
JSONObject whereJson = new JSONObject();
JSONArray tagArray = new JSONArray();
JSONObject testTag = new JSONObject();
testTag.put("tag", "iostest");
tagArray.put(testTag);
whereJson.put("and", tagArray);
filterJson.put("where", whereJson);
System.out.println(filterJson.toString());
// Set filter condition into rootJson
groupcast.setFilter(filterJson);
//groupcast.setAlert("IOS 组播测试");
//alert的值设置为字典
groupcast.setAlert("今日天气", "subtitle", "今日可能下雨🌂");
groupcast.setBadge(0);
groupcast.setSound("default");
// set 'production_mode' to 'true' if your app is under production mode
groupcast.setTestMode();
client.send(groupcast);
}
public void sendIOSCustomizedcast() throws Exception {
IOSCustomizedcast customizedcast = new IOSCustomizedcast(appkey, appMasterSecret);
// Set your alias and alias_type here, and use comma to split them if there are multiple alias.
// And if you have many alias, you can also upload a file containing these alias, then
// use file_id to send customized notification.
customizedcast.setAlias("alias", "alias_type");
//customizedcast.setAlert("IOS 个性化测试");
//alert的值设置为字典
customizedcast.setAlert("今日天气", "", "今日可能下雨🌂");
customizedcast.setBadge(0);
customizedcast.setSound("default");
// set 'production_mode' to 'true' if your app is under production mode
customizedcast.setTestMode();
client.send(customizedcast);
}
public void sendIOSFilecast() throws Exception {
IOSFilecast filecast = new IOSFilecast(appkey, appMasterSecret);
// upload your device tokens, and use '\n' to split them if there are multiple tokens
String fileId = client.uploadContents(appkey, appMasterSecret, "aa" + "\n" + "bb");
filecast.setFileId(fileId);
//filecast.setAlert("IOS 文件播测试");
//alert的值设置为字典
filecast.setAlert("今日天气", "", "今日可能下雨🌂");
filecast.setBadge(0);
filecast.setSound("default");
// set 'production_mode' to 'true' if your app is under production mode
filecast.setTestMode();
client.send(filecast);
}
}
package com.wecloud.im.push.umeng;
import org.json.JSONObject;
import java.util.Arrays;
import java.util.HashSet;
public abstract class IOSNotification extends UmengNotification {
// Keys can be set in the aps level
protected static final HashSet<String> APS_KEYS = new HashSet<String>(Arrays.asList("alert", "badge", "sound", "content-available"));
@Override
public boolean setPredefinedKeyValue(String key, Object value) throws Exception {
if (ROOT_KEYS.contains(key)) {
// This key should be in the root level
rootJson.put(key, value);
} else if (APS_KEYS.contains(key)) {
// This key should be in the aps level
JSONObject apsJson = null;
JSONObject payloadJson = null;
if (rootJson.has("payload")) {
payloadJson = rootJson.getJSONObject("payload");
} else {
payloadJson = new JSONObject();
rootJson.put("payload", payloadJson);
}
if (payloadJson.has("aps")) {
apsJson = payloadJson.getJSONObject("aps");
} else {
apsJson = new JSONObject();
payloadJson.put("aps", apsJson);
}
apsJson.put(key, value);
} else if (POLICY_KEYS.contains(key)) {
// This key should be in the body level
JSONObject policyJson = null;
if (rootJson.has("policy")) {
policyJson = rootJson.getJSONObject("policy");
} else {
policyJson = new JSONObject();
rootJson.put("policy", policyJson);
}
policyJson.put(key, value);
} else {
if (key == "payload" || key == "aps" || key == "policy") {
throw new Exception("You don't need to set value for " + key + " , just set values for the sub keys in it.");
} else {
throw new Exception("Unknownd key: " + key);
}
}
return true;
}
// Set customized key/value for IOS notification
public boolean setCustomizedField(String key, String value) throws Exception {
//rootJson.put(key, value);
JSONObject payloadJson = null;
if (rootJson.has("payload")) {
payloadJson = rootJson.getJSONObject("payload");
} else {
payloadJson = new JSONObject();
rootJson.put("payload", payloadJson);
}
payloadJson.put(key, value);
return true;
}
public void setAlert(String token) throws Exception {
setPredefinedKeyValue("alert", token);
}
public void setAlert(String title, String subtitle, String body) throws Exception {
JSONObject object = new JSONObject();
object.put("title", title);
object.put("subtitle", subtitle);
object.put("body", body);
setPredefinedKeyValue("alert", object);
}
public void setBadge(Integer badge) throws Exception {
setPredefinedKeyValue("badge", badge);
}
public void setSound(String sound) throws Exception {
setPredefinedKeyValue("sound", sound);
}
public void setContentAvailable(Integer contentAvailable) throws Exception {
setPredefinedKeyValue("content-available", contentAvailable);
}
}
package com.wecloud.im.push.umeng;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.json.JSONObject;
import org.springframework.stereotype.Component;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
/**
* @author JJww
*/
@Component
public class PushClient {
// The host
protected static final String host = "http://msg.umeng.com";
// The upload path
protected static final String uploadPath = "/upload";
// The post path
protected static final String postPath = "/api/send";
// The user agent
protected final String USER_AGENT = "Mozilla/5.0";
// This object is used for sending the post request to Umeng
protected HttpClient client = new DefaultHttpClient();
public boolean send(UmengNotification msg) throws Exception {
String timestamp = Integer.toString((int) (System.currentTimeMillis() / 1000));
msg.setPredefinedKeyValue("timestamp", timestamp);
String url = host + postPath;
String postBody = msg.getPostBody();
String sign = DigestUtils.md5Hex(("POST" + url + postBody + msg.getAppMasterSecret()).getBytes(StandardCharsets.UTF_8));
url = url + "?sign=" + sign;
HttpPost post = new HttpPost(url);
post.setHeader("User-Agent", USER_AGENT);
StringEntity se = new StringEntity(postBody, "UTF-8");
post.setEntity(se);
// Send the post request and get the response
HttpResponse response = client.execute(post);
int status = response.getStatusLine().getStatusCode();
System.out.println("Response Code : " + status);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
StringBuffer result = new StringBuffer();
String line = "";
while ((line = rd.readLine()) != null) {
result.append(line);
}
System.out.println(result.toString());
if (status == 200) {
System.out.println("Notification sent successfully.");
} else {
System.out.println("Failed to send the notification!");
}
return true;
}
// Upload file with device_tokens to Umeng
public String uploadContents(String appkey, String appMasterSecret, String contents) throws Exception {
// Construct the json string
JSONObject uploadJson = new JSONObject();
uploadJson.put("appkey", appkey);
String timestamp = Integer.toString((int) (System.currentTimeMillis() / 1000));
uploadJson.put("timestamp", timestamp);
uploadJson.put("content", contents);
// Construct the request
String url = host + uploadPath;
String postBody = uploadJson.toString();
String sign = DigestUtils.md5Hex(("POST" + url + postBody + appMasterSecret).getBytes(StandardCharsets.UTF_8));
url = url + "?sign=" + sign;
HttpPost post = new HttpPost(url);
post.setHeader("User-Agent", USER_AGENT);
StringEntity se = new StringEntity(postBody, "UTF-8");
post.setEntity(se);
// Send the post request and get the response
HttpResponse response = client.execute(post);
System.out.println("Response Code : " + response.getStatusLine().getStatusCode());
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
StringBuffer result = new StringBuffer();
String line = "";
while ((line = rd.readLine()) != null) {
result.append(line);
}
System.out.println(result.toString());
// Decode response string and get file_id from it
JSONObject respJson = new JSONObject(result.toString());
String ret = respJson.getString("ret");
if (!ret.equals("SUCCESS")) {
throw new Exception("Failed to upload file");
}
JSONObject data = respJson.getJSONObject("data");
String fileId = data.getString("file_id");
// Set file_id into rootJson using setPredefinedKeyValue
return fileId;
}
}
package com.wecloud.im.push.umeng;
import com.wecloud.im.factory.PushService;
import com.wecloud.im.push.umeng.android.AndroidNotification;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
/**
* @author: JJww
* @Date:2020/11/5
*/
@Component
public class UmengAndroidPushServiceImpl extends AndroidNotification implements PushService {
@Autowired
private PushClient pushClient;
private static final String APP_KEY = "5f963f3ea1491772a2aef713";
private static final String APP_MASTER_SECRET = "ti5gomxtvmkgehmwgtbq9rtsfhy0khsi";
@PostConstruct
public void init() throws Exception {
setAppMasterSecret(APP_MASTER_SECRET);
setPredefinedKeyValue("appkey", APP_KEY);
}
@Override
@SneakyThrows
public void unicast(String deviceToken) {
this.setTitle("您有一条新信息");
this.setText("");
this.goAppAfterOpen();
this.setPredefinedKeyValue("device_tokens", deviceToken);
this.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
this.setProductionMode();
this.setExtraField("pushType", "1");//自定义字段 推送类型:客服消息
this.setPredefinedKeyValue("type", "unicast");//单播
pushClient.send(this);
}
@Override
public void unicast(String deviceToken, String pushType, String title) throws Exception {
this.setTitle(title);
this.setText("");
this.goAppAfterOpen();
this.setPredefinedKeyValue("device_tokens", deviceToken);
this.setDisplayType(AndroidNotification.DisplayType.NOTIFICATION);
this.setProductionMode();
this.setExtraField("pushType", pushType);//自定义字段 推送类型:客服消息
this.setPredefinedKeyValue("type", "unicast");//单播
pushClient.send(this);
}
}
package com.wecloud.im.push.umeng;
import com.wecloud.im.factory.PushService;
import com.wecloud.im.push.umeng.ios.IOSNotification;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
/**
* @author: JJww
* @Date:2020/11/5
*/
@Component
public class UmengIosPushServiceImpl extends IOSNotification implements PushService {
@Autowired
private PushClient pushClient;
private static final String APP_KEY = "5f963f3ea1491772a2aef713";
private static final String APP_MASTER_SECRET = "ti5gomxtvmkgehmwgtbq9rtsfhy0khsi";
@PostConstruct
public void init() throws Exception {
setAppMasterSecret(APP_MASTER_SECRET);
setPredefinedKeyValue("appkey", APP_KEY);
}
@Override
@SneakyThrows
public void unicast(String deviceToken) {
this.setAlert("您有一条新信息");
this.setBadge(0);
this.setSound("default");
this.setProductionMode();
this.setPredefinedKeyValue("device_tokens", deviceToken);
this.setCustomizedField("pushType", "1");//自定义字段 推送类型:客服消息
this.setPredefinedKeyValue("type", "unicast");
pushClient.send(this);
}
@Override
public void unicast(String deviceToken, String pushType, String title) throws Exception {
this.setAlert(title);
this.setBadge(0);
this.setSound("default");
this.setProductionMode();
this.setPredefinedKeyValue("device_tokens", deviceToken);
this.setCustomizedField("pushType", pushType);//自定义字段 推送类型:客服消息
this.setPredefinedKeyValue("type", "unicast");
pushClient.send(this);
}
}
package com.wecloud.im.push.umeng;
import org.json.JSONObject;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.HashSet;
@Component
public abstract class UmengNotification {
// Keys can be set in the root level
protected static final HashSet<String> ROOT_KEYS = new HashSet<String>(Arrays.asList("appkey", "timestamp", "type", "device_tokens", "alias", "alias_type", "file_id",
"filter", "production_mode", "feedback", "description", "thirdparty_id", "mipush", "mi_activity", "channel_properties"));
// Keys can be set in the policy level
protected static final HashSet<String> POLICY_KEYS = new HashSet<String>(Arrays.asList("start_time", "expire_time", "max_send_num"));
// This JSONObject is used for constructing the whole request string.
protected final JSONObject rootJson = new JSONObject();
// The app master secret
protected String appMasterSecret;
// Set predefined keys in the rootJson, for extra keys(Android) or customized keys(IOS) please
// refer to corresponding methods in the subclass.
public abstract boolean setPredefinedKeyValue(String key, Object value) throws Exception;
public String getPostBody() {
return rootJson.toString();
}
protected final String getAppMasterSecret() {
return appMasterSecret;
}
public void setAppMasterSecret(String secret) {
appMasterSecret = secret;
}
protected void setProductionMode(Boolean prod) throws Exception {
setPredefinedKeyValue("production_mode", prod.toString());
}
///正式模式
public void setProductionMode() throws Exception {
setProductionMode(true);
}
///测试模式
public void setTestMode() throws Exception {
setProductionMode(false);
}
///发送消息描述,建议填写。
public void setDescription(String description) throws Exception {
setPredefinedKeyValue("description", description);
}
///定时发送时间,若不填写表示立即发送。格式: "YYYY-MM-DD hh:mm:ss"。
public void setStartTime(String startTime) throws Exception {
setPredefinedKeyValue("start_time", startTime);
}
///消息过期时间,格式: "YYYY-MM-DD hh:mm:ss"。
public void setExpireTime(String expireTime) throws Exception {
setPredefinedKeyValue("expire_time", expireTime);
}
///发送限速,每秒发送的最大条数。
public void setMaxSendNum(Integer num) throws Exception {
setPredefinedKeyValue("max_send_num", num);
}
//厂商弹窗activity
public void setChannelActivity(String activity) throws Exception {
setPredefinedKeyValue("mipush", "true");
setPredefinedKeyValue("mi_activity", activity);
}
//厂商属性配置
public void setChannelProperties(String xiaoMiChannelId) throws Exception {
JSONObject object = new JSONObject();
object.put("xiaomi_channel_id", xiaoMiChannelId);
setPredefinedKeyValue("channel_properties", object);
}
}
package com.wecloud.im.push.umeng.android;
import com.wecloud.im.push.umeng.AndroidNotification;
public class AndroidBroadcast extends AndroidNotification {
public AndroidBroadcast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "broadcast");
}
}
package com.wecloud.im.push.umeng.android;
import com.wecloud.im.push.umeng.AndroidNotification;
public class AndroidCustomizedcast extends AndroidNotification {
public AndroidCustomizedcast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "customizedcast");
}
public void setAlias(String alias, String aliasType) throws Exception {
setPredefinedKeyValue("alias", alias);
setPredefinedKeyValue("alias_type", aliasType);
}
public void setFileId(String fileId, String aliasType) throws Exception {
setPredefinedKeyValue("file_id", fileId);
setPredefinedKeyValue("alias_type", aliasType);
}
}
package com.wecloud.im.push.umeng.android;
import com.wecloud.im.push.umeng.AndroidNotification;
public class AndroidFilecast extends AndroidNotification {
public AndroidFilecast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "filecast");
}
public void setFileId(String fileId) throws Exception {
setPredefinedKeyValue("file_id", fileId);
}
}
\ No newline at end of file
package com.wecloud.im.push.umeng.android;
import com.wecloud.im.push.umeng.AndroidNotification;
import org.json.JSONObject;
public class AndroidGroupcast extends AndroidNotification {
public AndroidGroupcast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "groupcast");
}
public void setFilter(JSONObject filter) throws Exception {
setPredefinedKeyValue("filter", filter);
}
}
package com.wecloud.im.push.umeng.android;
import com.wecloud.im.push.umeng.UmengNotification;
import org.json.JSONObject;
import java.util.Arrays;
import java.util.HashSet;
public abstract class AndroidNotification extends UmengNotification {
// Keys can be set in the payload level
protected static final HashSet<String> PAYLOAD_KEYS = new HashSet<String>(Arrays.asList("display_type"));
// Keys can be set in the body level
protected static final HashSet<String> BODY_KEYS = new HashSet<String>(Arrays.asList("ticker", "title", "text", "builder_id", "icon", "largeIcon", "img", "play_vibrate", "play_lights", "play_sound",
"sound", "after_open", "url", "activity", "custom"));
// Set key/value in the rootJson, for the keys can be set please see ROOT_KEYS, PAYLOAD_KEYS,
// BODY_KEYS and POLICY_KEYS.
@Override
public boolean setPredefinedKeyValue(String key, Object value) throws Exception {
if (ROOT_KEYS.contains(key)) {
// This key should be in the root level
rootJson.put(key, value);
} else if (PAYLOAD_KEYS.contains(key)) {
// This key should be in the payload level
JSONObject payloadJson = null;
if (rootJson.has("payload")) {
payloadJson = rootJson.getJSONObject("payload");
} else {
payloadJson = new JSONObject();
rootJson.put("payload", payloadJson);
}
payloadJson.put(key, value);
} else if (BODY_KEYS.contains(key)) {
// This key should be in the body level
JSONObject bodyJson = null;
JSONObject payloadJson = null;
// 'body' is under 'payload', so build a payload if it doesn't exist
if (rootJson.has("payload")) {
payloadJson = rootJson.getJSONObject("payload");
} else {
payloadJson = new JSONObject();
rootJson.put("payload", payloadJson);
}
// Get body JSONObject, generate one if not existed
if (payloadJson.has("body")) {
bodyJson = payloadJson.getJSONObject("body");
} else {
bodyJson = new JSONObject();
payloadJson.put("body", bodyJson);
}
bodyJson.put(key, value);
} else if (POLICY_KEYS.contains(key)) {
// This key should be in the body level
JSONObject policyJson = null;
if (rootJson.has("policy")) {
policyJson = rootJson.getJSONObject("policy");
} else {
policyJson = new JSONObject();
rootJson.put("policy", policyJson);
}
policyJson.put(key, value);
} else {
if (key == "payload" || key == "body" || key == "policy" || key == "extra") {
throw new Exception("You don't need to set value for " + key + " , just set values for the sub keys in it.");
} else {
throw new Exception("Unknown key: " + key);
}
}
return true;
}
// Set extra key/value for Android notification
public boolean setExtraField(String key, String value) throws Exception {
JSONObject payloadJson = null;
JSONObject extraJson = null;
if (rootJson.has("payload")) {
payloadJson = rootJson.getJSONObject("payload");
} else {
payloadJson = new JSONObject();
rootJson.put("payload", payloadJson);
}
if (payloadJson.has("extra")) {
extraJson = payloadJson.getJSONObject("extra");
} else {
extraJson = new JSONObject();
payloadJson.put("extra", extraJson);
}
extraJson.put(key, value);
return true;
}
//
public void setDisplayType(DisplayType d) throws Exception {
setPredefinedKeyValue("display_type", d.getValue());
}
///通知栏提示文字
public void setTicker(String ticker) throws Exception {
setPredefinedKeyValue("ticker", ticker);
}
///通知标题
public void setTitle(String title) throws Exception {
setPredefinedKeyValue("title", title);
}
///通知文字描述
public void setText(String text) throws Exception {
setPredefinedKeyValue("text", text);
}
///用于标识该通知采用的样式。使用该参数时, 必须在SDK里面实现自定义通知栏样式。
public void setBuilderId(Integer builder_id) throws Exception {
setPredefinedKeyValue("builder_id", builder_id);
}
///状态栏图标ID, R.drawable.[smallIcon],如果没有, 默认使用应用图标。
public void setIcon(String icon) throws Exception {
setPredefinedKeyValue("icon", icon);
}
///通知栏拉开后左侧图标ID
public void setLargeIcon(String largeIcon) throws Exception {
setPredefinedKeyValue("largeIcon", largeIcon);
}
///通知栏大图标的URL链接。该字段的优先级大于largeIcon。该字段要求以http或者https开头。
public void setImg(String img) throws Exception {
setPredefinedKeyValue("img", img);
}
///收到通知是否震动,默认为"true"
public void setPlayVibrate(Boolean play_vibrate) throws Exception {
setPredefinedKeyValue("play_vibrate", play_vibrate.toString());
}
///收到通知是否闪灯,默认为"true"
public void setPlayLights(Boolean play_lights) throws Exception {
setPredefinedKeyValue("play_lights", play_lights.toString());
}
///收到通知是否发出声音,默认为"true"
public void setPlaySound(Boolean play_sound) throws Exception {
setPredefinedKeyValue("play_sound", play_sound.toString());
}
///通知声音,R.raw.[sound]. 如果该字段为空,采用SDK默认的声音
public void setSound(String sound) throws Exception {
setPredefinedKeyValue("sound", sound);
}
///收到通知后播放指定的声音文件
public void setPlaySound(String sound) throws Exception {
setPlaySound(true);
setSound(sound);
}
///点击"通知"的后续行为,默认为打开app。
public void goAppAfterOpen() throws Exception {
setAfterOpenAction(AfterOpenAction.go_app);
}
public void goUrlAfterOpen(String url) throws Exception {
setAfterOpenAction(AfterOpenAction.go_url);
setUrl(url);
}
public void goActivityAfterOpen(String activity) throws Exception {
setAfterOpenAction(AfterOpenAction.go_activity);
setActivity(activity);
}
public void goCustomAfterOpen(String custom) throws Exception {
setAfterOpenAction(AfterOpenAction.go_custom);
setCustomField(custom);
}
public void goCustomAfterOpen(JSONObject custom) throws Exception {
setAfterOpenAction(AfterOpenAction.go_custom);
setCustomField(custom);
}
///点击"通知"的后续行为,默认为打开app。原始接口
public void setAfterOpenAction(AfterOpenAction action) throws Exception {
setPredefinedKeyValue("after_open", action.toString());
}
public void setUrl(String url) throws Exception {
setPredefinedKeyValue("url", url);
}
public void setActivity(String activity) throws Exception {
setPredefinedKeyValue("activity", activity);
}
///can be a string of json
public void setCustomField(String custom) throws Exception {
setPredefinedKeyValue("custom", custom);
}
public void setCustomField(JSONObject custom) throws Exception {
setPredefinedKeyValue("custom", custom);
}
public enum DisplayType {
NOTIFICATION {
public String getValue() {
return "notification";
}
},///通知:消息送达到用户设备后,由友盟SDK接管处理并在通知栏上显示通知内容。
MESSAGE {
public String getValue() {
return "message";
}
};///消息:消息送达到用户设备后,消息内容透传给应用自身进行解析处理。
public abstract String getValue();
}
public enum AfterOpenAction {
go_app,//打开应用
go_url,//跳转到URL
go_activity,//打开特定的activity
go_custom//用户自定义内容。
}
}
package com.wecloud.im.push.umeng.android;
import com.wecloud.im.push.umeng.AndroidNotification;
public class AndroidUnicast extends AndroidNotification {
public AndroidUnicast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "unicast");
}
public void setDeviceToken(String token) throws Exception {
setPredefinedKeyValue("device_tokens", token);
}
}
\ No newline at end of file
package com.wecloud.im.push.umeng.ios;
import com.wecloud.im.push.umeng.IOSNotification;
public class IOSBroadcast extends IOSNotification {
public IOSBroadcast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "broadcast");
}
}
package com.wecloud.im.push.umeng.ios;
import com.wecloud.im.push.umeng.IOSNotification;
public class IOSCustomizedcast extends IOSNotification {
public IOSCustomizedcast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "customizedcast");
}
public void setAlias(String alias, String aliasType) throws Exception {
setPredefinedKeyValue("alias", alias);
setPredefinedKeyValue("alias_type", aliasType);
}
public void setFileId(String fileId, String aliasType) throws Exception {
setPredefinedKeyValue("file_id", fileId);
setPredefinedKeyValue("alias_type", aliasType);
}
}
package com.wecloud.im.push.umeng.ios;
import com.wecloud.im.push.umeng.IOSNotification;
public class IOSFilecast extends IOSNotification {
public IOSFilecast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "filecast");
}
public void setFileId(String fileId) throws Exception {
setPredefinedKeyValue("file_id", fileId);
}
}
package com.wecloud.im.push.umeng.ios;
import com.wecloud.im.push.umeng.IOSNotification;
import org.json.JSONObject;
public class IOSGroupcast extends IOSNotification {
public IOSGroupcast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "groupcast");
}
public void setFilter(JSONObject filter) throws Exception {
setPredefinedKeyValue("filter", filter);
}
}
package com.wecloud.im.push.umeng.ios;
import com.wecloud.im.push.umeng.UmengNotification;
import org.json.JSONObject;
import java.util.Arrays;
import java.util.HashSet;
public abstract class IOSNotification extends UmengNotification {
// Keys can be set in the aps level
protected static final HashSet<String> APS_KEYS = new HashSet<String>(Arrays.asList("alert", "badge", "sound", "content-available"));
@Override
public boolean setPredefinedKeyValue(String key, Object value) throws Exception {
if (ROOT_KEYS.contains(key)) {
// This key should be in the root level
rootJson.put(key, value);
} else if (APS_KEYS.contains(key)) {
// This key should be in the aps level
JSONObject apsJson = null;
JSONObject payloadJson = null;
if (rootJson.has("payload")) {
payloadJson = rootJson.getJSONObject("payload");
} else {
payloadJson = new JSONObject();
rootJson.put("payload", payloadJson);
}
if (payloadJson.has("aps")) {
apsJson = payloadJson.getJSONObject("aps");
} else {
apsJson = new JSONObject();
payloadJson.put("aps", apsJson);
}
apsJson.put(key, value);
} else if (POLICY_KEYS.contains(key)) {
// This key should be in the body level
JSONObject policyJson = null;
if (rootJson.has("policy")) {
policyJson = rootJson.getJSONObject("policy");
} else {
policyJson = new JSONObject();
rootJson.put("policy", policyJson);
}
policyJson.put(key, value);
} else {
if (key == "payload" || key == "aps" || key == "policy") {
throw new Exception("You don't need to set value for " + key + " , just set values for the sub keys in it.");
} else {
throw new Exception("Unknownd key: " + key);
}
}
return true;
}
// Set customized key/value for IOS notification
public boolean setCustomizedField(String key, String value) throws Exception {
//rootJson.put(key, value);
JSONObject payloadJson = null;
if (rootJson.has("payload")) {
payloadJson = rootJson.getJSONObject("payload");
} else {
payloadJson = new JSONObject();
rootJson.put("payload", payloadJson);
}
payloadJson.put(key, value);
return true;
}
public void setAlert(String token) throws Exception {
setPredefinedKeyValue("alert", token);
}
public void setAlert(String title, String subtitle, String body) throws Exception {
JSONObject object = new JSONObject();
object.put("title", title);
object.put("subtitle", subtitle);
object.put("body", body);
setPredefinedKeyValue("alert", object);
}
public void setBadge(Integer badge) throws Exception {
setPredefinedKeyValue("badge", badge);
}
public void setSound(String sound) throws Exception {
setPredefinedKeyValue("sound", sound);
}
public void setContentAvailable(Integer contentAvailable) throws Exception {
setPredefinedKeyValue("content-available", contentAvailable);
}
}
package com.wecloud.im.push.umeng.ios;
import com.wecloud.im.push.umeng.IOSNotification;
public class IOSUnicast extends IOSNotification {
public IOSUnicast(String appkey, String appMasterSecret) throws Exception {
setAppMasterSecret(appMasterSecret);
setPredefinedKeyValue("appkey", appkey);
this.setPredefinedKeyValue("type", "unicast");
}
public void setDeviceToken(String token) throws Exception {
setPredefinedKeyValue("device_tokens", token);
}
}
package com.wecloud.im.service;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
public interface AppSmsService {
void deleteRegisterCode(String area, String number);
void deleteUpdatePhoneCode(String area, String number);
void deleteUpdatePhoneCodeNew(String area, String number);
/**
* 获取注册验证码
*/
ApiResult<Object> registerOrLoginCode(String phoneArea, String phone);
ApiResult<Object> updatePhoneCodeSendToOld() throws Exception;
/**
* 修改手机号,向新手机号发验证码
*/
ApiResult<Object> updatePhoneCodeSendToNew(String phoneArea, String phone);
/**
* 修改手机号,校验旧手机验证码
*/
ApiResult<Boolean> checkPhoneCodeOld(String code) throws Exception;
/**
* 获取注册验证码
*/
ApiResult LoginType(String area, String number);
/**
* 校验注册验证码
*
* @param area
* @param number
* @param code
* @return
*/
boolean equalsRegisterCode(String area, String number, String code);
boolean equalsUpdatePhoneCodeOld(String area, String number, String code);
boolean equalsUpdatePhoneCodeNew(String area, String number, String code);
/**
* 校验验登陆证码
*
* @param area
* @param number
* @param code
* @return
*/
boolean equalsLoginCode(String area, String number, String code);
}
package com.wecloud.im.service;
import com.wecloud.im.entity.AppUser;
import com.wecloud.im.param.app.AppSmsRegisterParam;
import com.wecloud.im.param.app.AppUserInfoParam;
import com.wecloud.im.vo.app.LoginAppUserTokenVo;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import java.util.List;
import java.util.Set;
public interface AppUserApiService {
/**
* 注册
*
* @param loginParam
* @param language
* @return
* @throws Exception
*/
ApiResult<LoginAppUserTokenVo> register(AppSmsRegisterParam loginParam, String language) throws Exception;
// ApiResult<LoginAppUserTokenVo> login(AppSmsRegisterParam loginParam, String language) throws Exception;
/**
* 修改或补充用户信息
*
* @param appUserInfoParam
* @return
* @throws Exception
*/
boolean updateAppUser(AppUserInfoParam appUserInfoParam) throws Exception;
/**
* 修改手机号
*
* @param phoneArea
* @param phone
* @param code
* @return
* @throws Exception
*/
ApiResult<Boolean> updatePhone(String phoneArea, String phone, String code, String codeNew) throws Exception;
/**
* 获取用户信息
*
* @param userId
* @return
*/
AppUser getUserInfo(Long userId);
/**
* 批量获取用户信息
*
* @param uids
* @return
*/
ApiResult<List<AppUser>> getAppUserList(Set<Long> uids);
}
package com.wecloud.im.service;
import com.wecloud.im.entity.DonationAgent;
import com.wecloud.im.param.DonationAgentPageParam;
import com.wecloud.im.vo.DonationAgentQueryVo;
import io.geekidea.springbootplus.framework.common.service.BaseService;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
/**
* 替他人捐款记录表 服务类
*
* @author hewei
* @since 2021-02-25
*/
public interface DonationAgentService extends BaseService<DonationAgent> {
/**
* 保存
*
* @param donationAgent
* @return
* @throws Exception
*/
boolean saveDonationAgent(DonationAgent donationAgent)throws Exception;
/**
* 修改
*
* @param donationAgent
* @return
* @throws Exception
*/
boolean updateDonationAgent(DonationAgent donationAgent)throws Exception;
/**
* 删除
*
* @param id
* @return
* @throws Exception
*/
boolean deleteDonationAgent(Long id)throws Exception;
/**
* 根据ID获取查询对象
*
* @param id
* @return
* @throws Exception
*/
DonationAgentQueryVo getDonationAgentById(Long id)throws Exception;
/**
* 获取分页对象
*
* @param donationAgentPageParam
* @return
* @throws Exception
*/
Paging<DonationAgentQueryVo> getDonationAgentPageList(DonationAgentPageParam donationAgentPageParam) throws Exception;
}
package com.wecloud.im.service;
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
import com.wecloud.im.entity.DonationRecord;
import com.wecloud.im.param.DonationRecordPageParam;
import com.wecloud.im.param.app.DonationRecordAdd;
import com.wecloud.im.vo.DonationRankAndTotal;
import com.wecloud.im.vo.DonationRecordQueryVo;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.service.BaseService;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import java.util.List;
/**
* 捐款记录 服务类
*
* @author hewei
* @since 2021-02-25
*/
public interface DonationRecordService extends BaseService<DonationRecord> {
/**
* 查询捐款排名和总捐款
*
* @param userId
* @return
*/
DonationRankAndTotal getDonationRankAndTotal(Long userId);
/**
* 保存
*
* @param donationRecord
* @return
* @throws Exception
*/
boolean saveDonationRecord(DonationRecord donationRecord) throws Exception;
/**
* 回调
*/
String donationOrderNotifyResult(String xmlData);
/**
* 我要捐款
*
* @param donationRecordAdd
* @return
* @throws Exception
*/
ApiResult<WxPayMpOrderResult> add(DonationRecordAdd donationRecordAdd) throws Exception;
/**
* 修改
*
* @param donationRecord
* @return
* @throws Exception
*/
boolean updateDonationRecord(DonationRecord donationRecord) throws Exception;
/**
* 删除
*
* @param id
* @return
* @throws Exception
*/
boolean deleteDonationRecord(Long id) throws Exception;
/**
* 根据ID获取查询对象
*
* @param id
* @return
* @throws Exception
*/
DonationRecordQueryVo getDonationRecordById(Long id) throws Exception;
/**
* 获取分页对象
*
* @param donationRecordPageParam
* @return
* @throws Exception
*/
Paging<DonationRecordQueryVo> getDonationRecordPageList(DonationRecordPageParam donationRecordPageParam) throws Exception;
ApiResult<List<DonationRecord>> getDonationRecordAllList() throws Exception;
}
package com.wecloud.im.service;
import com.wecloud.im.entity.VipPrice;
import com.wecloud.im.param.VipPricePageParam;
import com.wecloud.im.vo.app.VipPriceQueryVo;
import io.geekidea.springbootplus.framework.common.service.BaseService;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
/**
* 会员价格表 服务类
*
* @author xxx
* @since 2021-03-11
*/
public interface VipPriceService extends BaseService<VipPrice> {
/**
* 保存
*
* @param vipPrice
* @return
* @throws Exception
*/
boolean saveVipPrice(VipPrice vipPrice) throws Exception;
/**
* 修改
*
* @param vipPrice
* @return
* @throws Exception
*/
boolean updateVipPrice(VipPrice vipPrice) throws Exception;
/**
* 删除
*
* @param id
* @return
* @throws Exception
*/
boolean deleteVipPrice(Long id) throws Exception;
/**
* 根据ID获取查询对象
*
* @param id
* @return
* @throws Exception
*/
VipPriceQueryVo getVipPriceById(Long id) throws Exception;
/**
* 获取分页对象
*
* @param vipPricePageParam
* @return
* @throws Exception
*/
Paging<VipPriceQueryVo> getVipPricePageList(VipPricePageParam vipPricePageParam) throws Exception;
}
package com.wecloud.im.service;
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
import com.wecloud.im.entity.VipRecord;
import com.wecloud.im.param.VipOpenParam;
import com.wecloud.im.param.VipRecordPageParam;
import com.wecloud.im.vo.VipRecordQueryVo;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.service.BaseService;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
/**
* Vip开通记录 服务类
*
* @author hewei
* @since 2021-02-25
*/
public interface VipRecordService extends BaseService<VipRecord> {
/**
* 支付回调
* @param xmlData
* @return
*/
String vipOrderNotifyResult(String xmlData);
/**
* 保存
*
* @param vipRecord
* @return
* @throws Exception
*/
boolean saveVipRecord(VipRecord vipRecord)throws Exception;
/**
* 开通vip
*
* @param vipOpenParam
* @return
* @throws Exception
*/
ApiResult<WxPayMpOrderResult> openVip(VipOpenParam vipOpenParam) throws Exception;
/**
* 修改
*
* @param vipRecord
* @return
* @throws Exception
*/
boolean updateVipRecord(VipRecord vipRecord)throws Exception;
/**
* 删除
*
* @param id
* @return
* @throws Exception
*/
boolean deleteVipRecord(Long id)throws Exception;
/**
* 根据ID获取查询对象
*
* @param id
* @return
* @throws Exception
*/
VipRecordQueryVo getVipRecordById(Long id)throws Exception;
/**
* 获取分页对象
*
* @param vipRecordPageParam
* @return
* @throws Exception
*/
Paging<VipRecordQueryVo> getVipRecordPageList(VipRecordPageParam vipRecordPageParam) throws Exception;
}
package com.wecloud.im.service.impl;
import com.wecloud.im.entity.DonationAgent;
import com.wecloud.im.mapper.DonationAgentMapper;
import com.wecloud.im.service.DonationAgentService;
import com.wecloud.im.param.DonationAgentPageParam;
import com.wecloud.im.vo.DonationAgentQueryVo;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
/**
* 替他人捐款记录表 服务实现类
*
* @author hewei
* @since 2021-02-25
*/
@Slf4j
@Service
public class DonationAgentServiceImpl extends BaseServiceImpl<DonationAgentMapper, DonationAgent> implements DonationAgentService {
@Autowired
private DonationAgentMapper donationAgentMapper;
@Transactional(rollbackFor = Exception.class)
@Override
public boolean saveDonationAgent(DonationAgent donationAgent)throws Exception{
return super.save(donationAgent);
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean updateDonationAgent(DonationAgent donationAgent)throws Exception{
return super.updateById(donationAgent);
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean deleteDonationAgent(Long id)throws Exception{
return super.removeById(id);
}
@Override
public DonationAgentQueryVo getDonationAgentById(Long id)throws Exception{
return donationAgentMapper.getDonationAgentById(id);
}
@Override
public Paging<DonationAgentQueryVo> getDonationAgentPageList(DonationAgentPageParam donationAgentPageParam)throws Exception{
Page<DonationAgentQueryVo> page=new PageInfo<>(donationAgentPageParam,OrderItem.desc(getLambdaColumn(DonationAgent::getCreateTime)));
IPage<DonationAgentQueryVo> iPage= donationAgentMapper.getDonationAgentPageList(page, donationAgentPageParam);
return new Paging<DonationAgentQueryVo>(iPage);
}
}
package com.wecloud.im.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wecloud.im.entity.VipPrice;
import com.wecloud.im.mapper.VipPriceMapper;
import com.wecloud.im.param.VipPricePageParam;
import com.wecloud.im.service.VipPriceService;
import com.wecloud.im.vo.app.VipPriceQueryVo;
import io.geekidea.springbootplus.framework.common.service.impl.BaseServiceImpl;
import io.geekidea.springbootplus.framework.core.pagination.PageInfo;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 会员价格表 服务实现类
*
* @author xxx
* @since 2021-03-11
*/
@Slf4j
@Service
public class VipPriceServiceImpl extends BaseServiceImpl<VipPriceMapper, VipPrice> implements VipPriceService {
@Autowired
private VipPriceMapper vipPriceMapper;
@Transactional(rollbackFor = Exception.class)
@Override
public boolean saveVipPrice(VipPrice vipPrice) throws Exception {
return super.save(vipPrice);
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean updateVipPrice(VipPrice vipPrice) throws Exception {
return super.updateById(vipPrice);
}
@Transactional(rollbackFor = Exception.class)
@Override
public boolean deleteVipPrice(Long id) throws Exception {
return super.removeById(id);
}
@Override
public VipPriceQueryVo getVipPriceById(Long id) throws Exception {
return vipPriceMapper.getVipPriceById(id);
}
@Override
public Paging<VipPriceQueryVo> getVipPricePageList(VipPricePageParam vipPricePageParam) throws Exception {
Page<VipPriceQueryVo> page = new PageInfo<>(vipPricePageParam, OrderItem.desc(getLambdaColumn(VipPrice::getCreateTime)));
IPage<VipPriceQueryVo> iPage = vipPriceMapper.getVipPricePageList(page, vipPricePageParam);
return new Paging<VipPriceQueryVo>(iPage);
}
}
package com.wecloud.im.sms;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.Writer;
import java.net.URL;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.text.SimpleDateFormat;
import java.util.Base64;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
//如果JDK版本是1.8,可使用原生Base64类
//如果JDK版本低于1.8,请使用三方库提供Base64类
//import org.apache.commons.codec.binary.Base64;
public class SendSms {
//无需修改,用于格式化鉴权头域,给"X-WSSE"参数赋值
private static final String WSSE_HEADER_FORMAT = "UsernameToken Username=\"%s\",PasswordDigest=\"%s\",Nonce=\"%s\",Created=\"%s\"";
//无需修改,用于格式化鉴权头域,给"Authorization"参数赋值
private static final String AUTH_HEADER_VALUE = "WSSE realm=\"SDP\",profile=\"UsernameToken\",type=\"Appkey\"";
public static void main(String[] args) throws Exception {
String ramdom = "369751";
send("+8617621701106", ramdom);
}
public static void send(String receiver, String ramdom) throws Exception {
//必填,请参考"开发准备"获取如下数据,替换为实际值
String url = "https://rtcsms.cn-north-1.myhuaweicloud.com:10743/sms/batchSendSms/v1"; //APP接入地址+接口访问URI
String appKey = "FKFPgk3X6VRYAMJ9r9CIJWG2709W"; //APP_Key
String appSecret = "gvS2S8nD01vKCA1v45qi379gu1T5"; //APP_Secret
String sender = "8821030205711"; //国内短信签名通道号或国际/港澳台短信通道号
String templateId = "b55b51e3871947cebc65ca716e2e43a0"; //模板ID
//条件必填,国内短信关注,当templateId指定的模板类型为通用模板时生效且必填,必须是已审核通过的,与模板类型一致的签名名称
//国际/港澳台短信不用关注该参数
String signature = "四恩慈善会"; //签名名称
//必填,全局号码格式(包含国家码),示例:+8615123456789,多个号码之间用英文逗号分隔
// String receiver = "+8615123456789,+8615234567890"; //短信接收人号码
// String receiver = "+8617621701106"; //短信接收人号码
//选填,短信状态报告接收地址,推荐使用域名,为空或者不填表示不接收状态报告
String statusCallBack = "";
/**
* 选填,使用无变量模板时请赋空值 String templateParas = "";
* 单变量模板示例:模板内容为"您的验证码是${1}"时,templateParas可填写为"[\"369751\"]"
* 双变量模板示例:模板内容为"您有${1}件快递请到${2}领取"时,templateParas可填写为"[\"3\",\"人民公园正门\"]"
* 模板中的每个变量都必须赋值,且取值不能为空
* 查看更多模板和变量规范:产品介绍>模板和变量规范
*/
String templateParas = "[\"" + ramdom + "\"]"; //模板变量,此处以单变量验证码短信为例,请客户自行生成6位验证码,并定义为字符串类型,以杜绝首位0丢失的问题(例如:002569变成了2569)。
//请求Body,不携带签名名称时,signature请填null
String body = buildRequestBody(sender, receiver, templateId, templateParas, statusCallBack, signature);
if (null == body || body.isEmpty()) {
System.out.println("body is null.");
return;
}
//请求Headers中的X-WSSE参数值
String wsseHeader = buildWsseHeader(appKey, appSecret);
if (null == wsseHeader || wsseHeader.isEmpty()) {
System.out.println("wsse header is null.");
return;
}
Writer out = null;
BufferedReader in = null;
StringBuffer result = new StringBuffer();
HttpsURLConnection connection = null;
InputStream is = null;
HostnameVerifier hv = new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
return true;
}
};
trustAllHttpsCertificates();
try {
URL realUrl = new URL(url);
connection = (HttpsURLConnection) realUrl.openConnection();
connection.setHostnameVerifier(hv);
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setUseCaches(true);
//请求方法
connection.setRequestMethod("POST");
//请求Headers参数
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("Authorization", AUTH_HEADER_VALUE);
connection.setRequestProperty("X-WSSE", wsseHeader);
connection.connect();
out = new OutputStreamWriter(connection.getOutputStream());
out.write(body); //发送请求Body参数
out.flush();
out.close();
int status = connection.getResponseCode();
if (200 == status) { //200
is = connection.getInputStream();
} else { //400/401
is = connection.getErrorStream();
}
in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
String line = "";
while ((line = in.readLine()) != null) {
result.append(line);
}
System.out.println(result.toString()); //打印响应消息实体
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != out) {
out.close();
}
if (null != is) {
is.close();
}
if (null != in) {
in.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* 构造请求Body体
*
* @param sender
* @param receiver
* @param templateId
* @param templateParas
* @param statusCallBack
* @param signature | 签名名称,使用国内短信通用模板时填写
* @return
*/
static String buildRequestBody(String sender, String receiver, String templateId, String templateParas,
String statusCallBack, String signature) {
if (null == sender || null == receiver || null == templateId || sender.isEmpty() || receiver.isEmpty()
|| templateId.isEmpty()) {
System.out.println("buildRequestBody(): sender, receiver or templateId is null.");
return null;
}
Map<String, String> map = new HashMap<String, String>();
map.put("from", sender);
map.put("to", receiver);
map.put("templateId", templateId);
if (null != templateParas && !templateParas.isEmpty()) {
map.put("templateParas", templateParas);
}
if (null != statusCallBack && !statusCallBack.isEmpty()) {
map.put("statusCallback", statusCallBack);
}
if (null != signature && !signature.isEmpty()) {
map.put("signature", signature);
}
StringBuilder sb = new StringBuilder();
String temp = "";
for (String s : map.keySet()) {
try {
temp = URLEncoder.encode(map.get(s), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
sb.append(s).append("=").append(temp).append("&");
}
return sb.deleteCharAt(sb.length() - 1).toString();
}
/**
* 构造X-WSSE参数值
*
* @param appKey
* @param appSecret
* @return
*/
static String buildWsseHeader(String appKey, String appSecret) {
if (null == appKey || null == appSecret || appKey.isEmpty() || appSecret.isEmpty()) {
System.out.println("buildWsseHeader(): appKey or appSecret is null.");
return null;
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
String time = sdf.format(new Date()); //Created
String nonce = UUID.randomUUID().toString().replace("-", ""); //Nonce
MessageDigest md;
byte[] passwordDigest = null;
try {
md = MessageDigest.getInstance("SHA-256");
md.update((nonce + time + appSecret).getBytes());
passwordDigest = md.digest();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
//如果JDK版本是1.8,请加载原生Base64类,并使用如下代码
String passwordDigestBase64Str = Base64.getEncoder().encodeToString(passwordDigest); //PasswordDigest
//如果JDK版本低于1.8,请加载三方库提供Base64类,并使用如下代码
//String passwordDigestBase64Str = Base64.encodeBase64String(passwordDigest); //PasswordDigest
//若passwordDigestBase64Str中包含换行符,请执行如下代码进行修正
//passwordDigestBase64Str = passwordDigestBase64Str.replaceAll("[\\s*\t\n\r]", "");
return String.format(WSSE_HEADER_FORMAT, appKey, passwordDigestBase64Str, nonce, time);
}
/**
* @throws Exception
*/
static void trustAllHttpsCertificates() throws Exception {
TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
return;
}
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
return;
}
public X509Certificate[] getAcceptedIssuers() {
return null;
}
}
};
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, null);
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
}
}
......@@ -54,7 +54,6 @@ public class AppImHandler extends SimpleChannelInboundHandler<TextWebSocketFrame
ChannelFuture channelFuture = ctx.writeAndFlush(new TextWebSocketFrame(data));
log.debug("data:" + data);
try {
if (data.isEmpty()) {
return;
......@@ -77,7 +76,7 @@ public class AppImHandler extends SimpleChannelInboundHandler<TextWebSocketFrame
// Long userIdByChannel = appUserChannelsService.getUserIdByChannel(ctx);
//
// log.debug("appWS收到" + userIdByChannel + ":" + data + ",channelId:" + ctx.channel().id().asLongText());
System.out.println("appWS收到" + data);
log.debug("WS收到" + data);
String language = ctx.channel().attr(AppUserChannelsService.LANGUAGE).get();
// readWsData.convertModel(data, userIdByChannel, language);
......@@ -94,11 +93,11 @@ public class AppImHandler extends SimpleChannelInboundHandler<TextWebSocketFrame
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
//排除当客户端意外关闭的情况,不是发送指定指令通知服务器退出,就会产生此错误。
if (ctx.channel().isActive()) {
Long userIdByChannel = appUserChannelsService.getUserIdByChannel(ctx);
log.error("uid:" + userIdByChannel + ",ws异常,channelId:" + ctx.channel().id().asLongText(), cause);
}
// //排除当客户端意外关闭的情况,不是发送指定指令通知服务器退出,就会产生此错误。
// if (ctx.channel().isActive()) {
// Long userIdByChannel = appUserChannelsService.getUserIdByChannel(ctx);
// log.error("uid:" + userIdByChannel + ",ws异常,channelId:" + ctx.channel().id().asLongText(), cause);
// }
}
@Override
......@@ -106,7 +105,7 @@ public class AppImHandler extends SimpleChannelInboundHandler<TextWebSocketFrame
// Long userIdByChannel = appUserChannelsService.getUserIdByChannel(ctx);
//
// log.debug("uid:" + userIdByChannel + ",app端连接WS成功" + ",channelId:" + ctx.channel().id().asLongText());
System.out.println("连接WS成功");
log.debug("连接WS成功handlerAdded");
}
......@@ -118,9 +117,8 @@ public class AppImHandler extends SimpleChannelInboundHandler<TextWebSocketFrame
*/
@Override
public void channelInactive(ChannelHandlerContext ctx) {
log.debug("连接WS成功");
log.debug("连接WS成功channelInactive");
System.out.println("连接WS成功");
// Long userIdByChannel = appUserChannelsService.getUserIdByChannel(ctx);
// log.debug("uid:" + userIdByChannel + "," + "不活跃" + ",channelId:" + ctx.channel().id().asLongText());
......@@ -134,7 +132,7 @@ public class AppImHandler extends SimpleChannelInboundHandler<TextWebSocketFrame
@Override
public void handlerRemoved(ChannelHandlerContext ctx) {
System.out.println("handlerRemoved");
log.debug("handlerRemoved");
// Long userIdByChannel = appUserChannelsService.getUserIdByChannel(ctx);
// log.debug("uid:" + userIdByChannel + "," + "handlerRemoved" + ",channelId:" + ctx.channel().id().asLongText());
......
package com.wecloud.im.tillo.app_ws.utils;
import javax.crypto.Cipher;
import java.security.Key;
public class EncrypDES {
// 字符串默认键值
private static String strDefaultKey = "inventec2020@#$%^&";
//加密工具
private Cipher encryptCipher = null;
// 解密工具
private Cipher decryptCipher = null;
/**
* 默认构造方法,使用默认密钥
*/
public EncrypDES() throws Exception {
this(strDefaultKey);
}
/**
* 指定密钥构造方法
*
* @param strKey 指定的密钥
* @throws Exception
*/
public EncrypDES(String strKey) throws Exception {
// Security.addProvider(new com.sun.crypto.provider.SunJCE());
Key key = getKey(strKey.getBytes());
encryptCipher = Cipher.getInstance("DES");
encryptCipher.init(Cipher.ENCRYPT_MODE, key);
decryptCipher = Cipher.getInstance("DES");
decryptCipher.init(Cipher.DECRYPT_MODE, key);
}
/**
* 将byte数组转换为表示16进制值的字符串, 如:byte[]{8,18}转换为:0813,和public static byte[]
* <p>
* hexStr2ByteArr(String strIn) 互为可逆的转换过程
*
* @param arrB 需要转换的byte数组
* @return 转换后的字符串
* @throws Exception 本方法不处理任何异常,所有异常全部抛出
*/
public static String byteArr2HexStr(byte[] arrB) throws Exception {
int iLen = arrB.length;
// 每个byte用2个字符才能表示,所以字符串的长度是数组长度的2倍
StringBuffer sb = new StringBuffer(iLen * 2);
for (int i = 0; i < iLen; i++) {
int intTmp = arrB[i];
// 把负数转换为正数
while (intTmp < 0) {
intTmp = intTmp + 256;
}
// 小于0F的数需要在前面补0
if (intTmp < 16) {
sb.append("0");
}
sb.append(Integer.toString(intTmp, 16));
}
return sb.toString();
}
/**
* 将表示16进制值的字符串转换为byte数组,和public static String byteArr2HexStr(byte[] arrB)
* 互为可逆的转换过程
*
* @param strIn 需要转换的字符串
* @return 转换后的byte数组
*/
public static byte[] hexStr2ByteArr(String strIn) throws Exception {
byte[] arrB = strIn.getBytes();
int iLen = arrB.length;
// 两个字符表示一个字节,所以字节数组长度是字符串长度除以2
byte[] arrOut = new byte[iLen / 2];
for (int i = 0; i < iLen; i = i + 2) {
String strTmp = new String(arrB, i, 2);
arrOut[i / 2] = (byte) Integer.parseInt(strTmp, 16);
}
return arrOut;
}
/**
* 加密字节数组
*
* @param arrB 需加密的字节数组
* @return 加密后的字节数组
*/
public byte[] encrypt(byte[] arrB) throws Exception {
return encryptCipher.doFinal(arrB);
}
/**
* 加密字符串
*
* @param strIn 需加密的字符串
* @return 加密后的字符串
*/
public String encrypt(String strIn) throws Exception {
return byteArr2HexStr(encrypt(strIn.getBytes()));
}
/**
* 解密字节数组
*
* @param arrB 需解密的字节数组
* @return 解密后的字节数组
*/
public byte[] decrypt(byte[] arrB) throws Exception {
return decryptCipher.doFinal(arrB);
}
/**
* 解密字符串
*
* @param strIn 需解密的字符串
* @return 解密后的字符串
*/
public String decrypt(String strIn) throws Exception {
return new String(decrypt(hexStr2ByteArr(strIn)));
}
/**
* 从指定字符串生成密钥,密钥所需的字节数组长度为8位 不足8位时后面补0,超出8位只取前8位
*
* @param arrBTmp 构成该字符串的字节数组
* @return 生成的密钥
*/
private Key getKey(byte[] arrBTmp) throws Exception {
// 创建一个空的8位字节数组(默认值为0)
byte[] arrB = new byte[8];
// 将原始字节数组转换为8位
for (int i = 0; i < arrBTmp.length && i < arrB.length; i++) {
arrB[i] = arrBTmp[i];
}
// 生成密钥
Key key = new javax.crypto.spec.SecretKeySpec(arrB, "DES");
return key;
}
public static void main(String[] args) throws Exception {
String code = "427d68ae59e577f7b87f05d43670df58";
EncrypDES encrypDES = new EncrypDES();
//System.out.println(encrypDES.decrypt(code));
System.out.println(encrypDES.encrypt("18011953567"));
}
/*public static void main(String[] args) {
try {
*//*String msg1 = "1";
EncrypDES des1 = new EncrypDES();// 使用默认密钥
System.out.println("加密前的字符:" + msg1);
System.out.println("加密后的字符:" + des1.encrypt(msg1));
System.out.println("解密后的字符:" + des1.decrypt(des1.encrypt(msg1)));*//*
*//* System.out.println("--------优美分隔符------");
String msg2 = "1";
String key = "2020@#$2020";
EncrypDES des2 = new EncrypDES(key);// 自定义密钥
System.out.println("加密前的字符:" + msg2);
System.out.println("加密后的字符:" + des2.encrypt(msg2));
//c170d8716c90266d
System.out.println("解密后的字符:" + des2.decrypt(des2.encrypt(msg2)));*//*
} catch (Exception e) {
e.printStackTrace();
}
}*/
}
\ No newline at end of file
package com.wecloud.im.tillo.app_ws.utils;
import java.util.UUID;
public class RSAGenerator {
private final static String[] chars = new String[]{"a", "b", "c", "d", "e", "f",
"g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
"t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5",
"6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I",
"J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
"W", "X", "Y", "Z"};
//生成8位appKey
public static String getAppKey() {
StringBuffer shortBuffer = new StringBuffer();
//获取用户id进行字符串截取
String uuid = UUID.randomUUID().toString().replace("-", "");
for (int i = 0; i < 16; i++) {
String str = uuid.substring(i * 2, i * 2 + 2);
int x = Integer.parseInt(str, 16);
shortBuffer.append(chars[x % 0x3E]);
}
return shortBuffer.toString();
// return UUID.randomUUID().toString().replace("-", "");
}
//生成32位appSecret
public static String getAppSecret(String appId){
String EncryoAppSecret="";
try {
EncrypDES des1 = new EncrypDES();// 使用默认密钥
EncryoAppSecret=des1.encrypt(appId);
} catch (Exception e) {
e.printStackTrace();
}
return EncryoAppSecret;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wecloud.im.mapper.AppUserMapper">
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, username, wechat_open_id, nickname, idcard, nation, password, salt, phone, phone_area, gender, head, remark, state, deleted, version, create_time, update_time, date_of_birth, education_background, email, location, location_detail, profession, company, emergency_phone
</sql>
<select id="getAppUserById" resultType="com.wecloud.im.vo.AppUserQueryVo">
select
<include refid="Base_Column_List"/>
from app_user where id = #{id}
</select>
<select id="getAppUserPageList" parameterType="com.wecloud.im.param.AppUserPageParam" resultType="com.wecloud.im.vo.AppUserQueryVo">
select
<include refid="Base_Column_List"/>
from app_user
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wecloud.im.mapper.DonationAgentMapper">
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, fk_user_id, fk_record_id, remark, create_time, update_time
</sql>
<select id="getDonationAgentById" resultType="com.wecloud.im.vo.DonationAgentQueryVo">
select
<include refid="Base_Column_List"/>
from donation_agent where id = #{id}
</select>
<select id="getDonationAgentPageList" parameterType="com.wecloud.im.param.DonationAgentPageParam" resultType="com.wecloud.im.vo.DonationAgentQueryVo">
select
<include refid="Base_Column_List"/>
from donation_agent
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wecloud.im.mapper.DonationRecordMapper">
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id
, fk_user_id, money, purpose, way, remark, create_time, update_time, is_replace,wx_mer_pay_id,pay_status,pay_time
</sql>
<select id="getDonationRecordById" resultType="com.wecloud.im.vo.DonationRecordQueryVo">
select
<include refid="Base_Column_List"/>
from donation_record where id = #{id}
</select>
<select id="getDonationRecordPageList" parameterType="com.wecloud.im.param.DonationRecordPageParam"
resultType="com.wecloud.im.vo.DonationRecordQueryVo">
select
<include refid="Base_Column_List"/>
from donation_record
where pay_status=1
and fk_user_id=#{userId}
</select>
<select id="getDonationRankAndTotal" resultType="com.wecloud.im.vo.DonationRankAndTotal">
SELECT
*
FROM
(
SELECT
tb.*,
@curRank := @curRank + 1 AS rank
FROM
( SELECT fk_user_id, sum( money ) AS drTotal FROM donation_record WHERE donation_record.pay_status = 1 GROUP BY fk_user_id ORDER BY drTotal DESC ) AS tb,
( SELECT @curRank := 0 ) r
) AS giao
WHERE
giao.fk_user_id = #{userId}
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wecloud.im.mapper.VipPriceMapper">
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id
, price, member_ships, create_time, update_time, state
</sql>
<select id="getVipPriceById" resultType="com.wecloud.im.vo.app.VipPriceQueryVo">
select
<include refid="Base_Column_List"/>
from vip_price where id = #{id}
</select>
<select id="getVipPricePageList" parameterType="com.wecloud.im.param.VipPricePageParam"
resultType="com.wecloud.im.vo.app.VipPriceQueryVo">
select
<include refid="Base_Column_List"/>
from vip_price
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.wecloud.im.mapper.VipRecordMapper">
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, fk_user_id, fk_recharge_user, money, expired_at, years, remark, create_time, update_time,wx_mer_pay_id,pay_status,pay_time
</sql>
<select id="getVipRecordById" resultType="com.wecloud.im.vo.VipRecordQueryVo">
select
<include refid="Base_Column_List"/>
from vip_record where id = #{id}
</select>
<select id="getVipRecordPageList" parameterType="com.wecloud.im.param.VipRecordPageParam" resultType="com.wecloud.im.vo.VipRecordQueryVo">
select
<include refid="Base_Column_List"/>
from vip_record
</select>
</mapper>
......@@ -10,7 +10,8 @@ server:
min-spare-threads: 5
uri-encoding: UTF-8
############################# 访问路径、端口tomcat end ###############################
netty:
port: 8899
################################ spring config start ###############################
spring:
application:
......
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