Commit 8bb64b86 8bb64b863f65c85e70d19f77290fee70b41b7750 by xianghan

Merge remote-tracking branch 'remotes/origin/2.2.0-release'

# Conflicts:
#	src/main/java/com/topdraw/business/module/member/repository/MemberRepository.java
#	src/main/java/com/topdraw/business/module/member/service/MemberService.java
#	src/main/java/com/topdraw/business/module/member/service/impl/MemberServiceImpl.java
#	src/main/java/com/topdraw/business/process/service/impl/UserOperationServiceImpl.java
#	src/main/java/com/topdraw/business/process/service/impl/member/MemberOperationServiceImpl.java
#	src/main/java/com/topdraw/mq/consumer/UcEventBusIptv2ManagementUcEngine.java
#	src/main/java/com/topdraw/mq/consumer/UcGatewayIptv2IptvConsumer.java
#	src/main/java/com/topdraw/mq/consumer/WeiXinEventConsumer.java
#	src/main/java/com/topdraw/mq/domain/DataSyncMsg.java
#	src/main/java/com/topdraw/resttemplate/RestTemplateClient.java
#	src/main/resources/config/application-dev.yml
2 parents 77995e43 80f8168f
Showing 109 changed files with 4622 additions and 1624 deletions
package com.topdraw.business;
/**
* @author :
* @description:
* @function :
* @date :Created in 2022/6/13 11:22
* @version: :
* @modified By:
* @since : modified in 2022/6/13 11:22
*/
public interface ResponseStatus {
Integer OK = 00000;
}
......@@ -42,7 +42,8 @@ public class MemberBuilder {
member.setCouponAmount(DEFAULT_VALUE);
member.setDueCouponAmount(DEFAULT_VALUE);
member.setBlackStatus(DEFAULT_VALUE);
member.setBirthday(StringUtils.isBlank(member.getBirthday())?"1900-01-01":member.getBirthday());
// member.setBirthday(StringUtils.isBlank(member.getBirthday())?"1900-01-01":member.getBirthday());
member.setBirthday(null);
String nickname = member.getNickname();
if (StringUtils.isNotEmpty(nickname)) {
// String base64Nickname = new String(Base64.getEncoder().encode(nickname.getBytes(StandardCharsets.UTF_8)));
......
package com.topdraw.business.module.member.domain;
/**
* @author :
* @description:
* @function :
* @date :Created in 2022/6/27 15:38
* @version: :
* @modified By:
* @since : modified in 2022/6/27 15:38
*/
public interface MemberTypeConstant {
// 大屏
Integer vis = 1;
// 微信
Integer weixin = 2;
// app
Integer app = 3;
}
......@@ -10,6 +10,7 @@ import org.springframework.data.repository.query.Param;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
import java.util.Set;
/**
* @author XiangHan
......@@ -43,4 +44,26 @@ public interface MemberRepository extends JpaRepository<Member, Long>, JpaSpecif
" WHERE `id` = :#{#resources.id}", nativeQuery = true)
void doUpdateMemberCoupon(@Param("resources") Member member);
@Modifying
@Query(value = "UPDATE `uc_member` SET `avatar_url` = :#{#resources.avatarUrl}, `update_time` = now() , " +
" `nickname`= :#{#resources.nickname}, " +
" `gender`=:#{#resources.gender} WHERE `id` = :#{#resources.id}", nativeQuery = true)
Integer updateMemberAvatarUrlAndNicknameAndGender(@Param("resources") Member resources);
@Modifying
@Query(value = "UPDATE `uc_member` SET `vip` = :#{#resources.vip}, " +
"`vip_expire_time` = :#{#resources.vipExpireTime} , `update_time`= now() " +
" WHERE `id` = :#{#resources.id}", nativeQuery = true)
Integer updateMemberVipAndVipExpireTime(@Param("resources") Member member);
@Modifying
@Query(value = "UPDATE `uc_member` SET `user_iptv_id` = :#{#resources.userIptvId}, " +
"`bind_iptv_platform_type` = :#{#resources.bindIptvPlatformType} , `bind_iptv_time` = :#{#resources.bindIptvTime} , " +
" `update_time`= now() " +
" WHERE `id` = :#{#resources.id}", nativeQuery = true)
Integer doUpdateMemberUserIptvIdAndBindPlatformTypeAndBingTime(@Param("resources") Member member);
@Modifying
@Query(value = "UPDATE `uc_member` SET `groups` = ?1, `update_time` = now() WHERE `code` IN ?2 ", nativeQuery = true)
Integer doUpdateGroupsBatch(String groups, Set<String> codes);
}
......
......@@ -12,7 +12,12 @@ import java.util.List;
*/
public interface MemberService {
/**
*
* @param member
* @return
*/
MemberDTO doUpdateMemberVipAndVipExpireTime(Member member);
/**
* 根据ID查询
......@@ -36,30 +41,23 @@ public interface MemberService {
MemberDTO create(Member resources);
/**
* 创建并返回会员
* @param resources 会员
* @return Member
*/
MemberDTO createAndReturnMember(Member resources);
/**
* 修改会员
* @param resources
*/
MemberDTO update(Member resources);
/**
* 修改会员积分
* @param member 会员
*
* @param resources
* @return
*/
MemberDTO doUpdateMemberPoints(Member member);
MemberDTO doUpdateMemberAvatarUrlAndNicknameAndGender(Member resources);
/**
* 查询绑定了大屏会员列表
* @param id 条件参数
* @return Map<String,Object>
* 修改会员积分
* @param resources 会员
*/
List<MemberDTO> findByUserIptvId(Long id);
MemberDTO doUpdateMemberPoints(Member resources);
/**
* 检查会员信息
......@@ -88,4 +86,8 @@ public interface MemberService {
void updateUserIptvIdById(Long id, Long userIptvId, LocalDateTime now);
void doUpdateMemberCoupon(Member member);
Integer doUpdateMemberUserIptvIdAndBindPlatformTypeAndBingTime(Member member);
Integer asyncDoUpdateGroupsBatch(List<Member> resources);
}
......
......@@ -25,6 +25,8 @@ import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
/**
* @author XiangHan
......@@ -46,38 +48,30 @@ public class MemberServiceImpl implements MemberService {
@Override
public MemberDTO findById(Long id) {
Member member = this.memberRepository.findById(id).orElseGet(Member::new);
ValidationUtil.isNull(member.getId(),"Member","id",id);
@Transactional(rollbackFor = Exception.class)
public MemberDTO doUpdateMemberVipAndVipExpireTime(Member resource) {
log.info("修改会员vip和vip过期时间 ==>> {}", resource);
Integer count = this.memberRepository.updateMemberVipAndVipExpireTime(resource);
if (Objects.nonNull(count) && count > 0) {
Member member = this.memberRepository.findById(resource.getId()).orElseGet(Member::new);
return this.memberMapper.toDto(member);
}
@Override
public MemberDTO findByCode(String code) {
Member member = this.memberRepository.findFirstByCode(code).orElseGet(Member::new);
return this.memberMapper.toDto(member);
return this.memberMapper.toDto(resource);
}
private MemberDTO findByIdOrCode(Long id, String code) {
Member member = this.memberRepository.findByIdOrCode(id,code).orElseGet(Member::new);
ValidationUtil.isNull(member.getId(),"Member","param",code);
@Override
public MemberDTO findById(Long id) {
Member member = this.memberRepository.findById(id).orElseGet(Member::new);
return this.memberMapper.toDto(member);
}
@Override
public List<MemberDTO> findByUserIptvId(Long id) {
List<Member> memberList = this.memberRepository.findByUserIptvId(id);
return this.memberMapper.toDto(memberList);
public MemberDTO findByCode(String code) {
Member member = this.memberRepository.findFirstByCode(code).orElseGet(Member::new);
return this.memberMapper.toDto(member);
}
@Override
......@@ -151,16 +145,6 @@ public class MemberServiceImpl implements MemberService {
@Override
@Transactional(rollbackFor = Exception.class)
public MemberDTO createAndReturnMember(Member resources) {
MemberDTO memberDTO = this.create(MemberBuilder.build(resources));
return memberDTO;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void unbind(Member resources) {
try {
String code = resources.getCode();
......@@ -194,6 +178,18 @@ public class MemberServiceImpl implements MemberService {
@Override
@Transactional(rollbackFor = Exception.class)
public Integer doUpdateMemberUserIptvIdAndBindPlatformTypeAndBingTime(Member member) {
return this.memberRepository.doUpdateMemberUserIptvIdAndBindPlatformTypeAndBingTime(member);
}
@Override
public Integer asyncDoUpdateGroupsBatch(List<Member> resources) {
Set<String> codes = resources.stream().map(t -> t.getCode()).collect(Collectors.toSet());
return this.memberRepository.doUpdateGroupsBatch( resources.get(0).getGroups(), codes);
}
@Override
@Transactional(rollbackFor = Exception.class)
public MemberDTO update(Member resources) {
log.info("MemberServiceImpl ==>> update ==>> resources ==>> [{}]" , resources);
......@@ -224,6 +220,17 @@ public class MemberServiceImpl implements MemberService {
}
@Override
@Transactional(rollbackFor = Exception.class)
public MemberDTO doUpdateMemberAvatarUrlAndNicknameAndGender(Member resources) {
Integer count = this.memberRepository.updateMemberAvatarUrlAndNicknameAndGender(resources);
if (Objects.nonNull(count) && count > 0) {
Member member = this.memberRepository.findById(resources.getId()).orElseGet(Member::new);
return this.memberMapper.toDto(member);
}
return this.memberMapper.toDto(resources);
}
public Member save(Member member){
return this.memberRepository.save(member);
}
......
......@@ -17,6 +17,9 @@ public class MemberVipHistoryDTO implements Serializable {
// 主键
private Long id;
//
private String memberCode;
// 会员id
private Long memberId;
......
......@@ -5,7 +5,6 @@ import com.topdraw.business.module.points.available.repository.PointsAvailableRe
import com.topdraw.business.module.points.available.service.PointsAvailableService;
import com.topdraw.business.module.points.available.service.dto.PointsAvailableDTO;
import com.topdraw.business.module.points.available.service.mapper.PointsAvailableMapper;
import com.topdraw.utils.RedisUtils;
import com.topdraw.utils.StringUtils;
import com.topdraw.utils.ValidationUtil;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -31,8 +30,6 @@ public class PointsAvailableServiceImpl implements PointsAvailableService {
private PointsAvailableRepository pointsAvailableRepository;
@Autowired
private PointsAvailableMapper pointsAvailableMapper;
@Autowired
private RedisUtils redisUtils;
@Override
public List<PointsAvailableDTO> findByMemberIdOrderByExpireTime(Long memberId) {
......@@ -50,16 +47,11 @@ public class PointsAvailableServiceImpl implements PointsAvailableService {
@Transactional(rollbackFor = Exception.class)
public PointsAvailableDTO create(PointsAvailable resources) {
try {
this.redisUtils.doLock("PointsAvailable::create::id"+resources.getMemberId().toString());
PointsAvailable pointsAvailable = this.pointsAvailableRepository.save(resources);
return this.pointsAvailableMapper.toDto(pointsAvailable);
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
this.redisUtils.doUnLock("PointsAvailable::create::id"+resources.getMemberId().toString());
}
}
......@@ -67,7 +59,6 @@ public class PointsAvailableServiceImpl implements PointsAvailableService {
@Transactional(rollbackFor = Exception.class)
public PointsAvailableDTO update(PointsAvailable resources) {
try {
this.redisUtils.doLock("PointsAvailable::update::id"+resources.getMemberId().toString());
PointsAvailable pointsAvailable = this.pointsAvailableRepository.findById(resources.getId()).orElseGet(PointsAvailable::new);
ValidationUtil.isNull(pointsAvailable.getId(),"PointsAvailable","id",resources.getId());
pointsAvailable.copy(resources);
......@@ -77,8 +68,6 @@ public class PointsAvailableServiceImpl implements PointsAvailableService {
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
this.redisUtils.doUnLock("PointsAvailable::update::id"+resources.getMemberId().toString());
}
}
......@@ -86,7 +75,6 @@ public class PointsAvailableServiceImpl implements PointsAvailableService {
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
this.redisUtils.doLock("PointsAvailable::delete::id"+id);
try {
PointsAvailable PointsAvailable = this.pointsAvailableRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", com.topdraw.business.module.points.available.domain.PointsAvailable.class, id), 1));
......@@ -94,22 +82,17 @@ public class PointsAvailableServiceImpl implements PointsAvailableService {
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
this.redisUtils.doLock("PointsAvailable::delete::id"+id);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteBatchByIds(List<Long> id) {
this.redisUtils.doLock("PointsAvailable::create::id"+id);
try {
this.pointsAvailableRepository.deleteBatchByIds(id);
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
this.redisUtils.doUnLock("PointsAvailable::create::id"+id);
}
}
......@@ -146,7 +129,6 @@ public class PointsAvailableServiceImpl implements PointsAvailableService {
@Override
public void delete4Custom(Long id) {
Assert.notNull(id, "The given id must not be null!");
this.redisUtils.doLock("PointsAvailable::delete::id"+id);
try {
PointsAvailable PointsAvailable = this.pointsAvailableRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", com.topdraw.business.module.points.available.domain.PointsAvailable.class, id), 1));
......@@ -154,22 +136,17 @@ public class PointsAvailableServiceImpl implements PointsAvailableService {
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
this.redisUtils.doUnLock("PointsAvailable::delete::id"+id);
}
}
@Override
public PointsAvailableDTO create4Custom(PointsAvailable resources) {
this.redisUtils.doLock("PointsAvailable::create::id"+resources.getMemberId().toString());
try {
PointsAvailable pointsAvailable = this.pointsAvailableRepository.save(resources);
return this.pointsAvailableMapper.toDto(pointsAvailable);
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
this.redisUtils.doUnLock("PointsAvailable::create::id"+resources.getMemberId().toString());
}
}
......
......@@ -33,6 +33,10 @@ public class Task implements Serializable {
@Column(name = "task_template_id", nullable = false)
private Long taskTemplateId;
/** 关联实体id */
@Column(name = "entity_id", nullable = false)
private String entityId;
@Transient
private String taskTemplateCode;
......
......@@ -19,6 +19,9 @@ public class TaskDTO implements Serializable {
/** 任务模板id */
private Long taskTemplateId;
/** 关联实体id */
private String entityId;
/** 任务重复类型,-1:不限次;1:单次;>1:多次 */
private Integer taskRepeatType;
......
package com.topdraw.business.module.task.template.constant;
/**
* @author :
* @description:
* @function :
* @date :Created in 2022/6/18 14:30
* @version: :
* @modified By:
* @since : modified in 2022/6/18 14:30
*/
public interface TaskEventName {
//类型 1:登录;2:观影;3:参加活动;4:订购;5:优享会员;6:签到;7:完成设置;
// 8:播放记录;10:跨屏绑定;11:积分转移;30:积分兑换商品;98:系统操作;99:其他
String LOGIN = "LOGIN";
String VIEW = "VIEW";
String ACTIVITY = "ACTIVITY";
String ORDER = "ORDER";
String MEMBER_PRIORITY = "MEMBER_PRIORITY";
String SIGN = "SIGN";
String COMPLETE_INFO = "COMPLETE_INFO";
String PLAY = "PLAY";
String BINDING = "BINDING";
String POINTS_TRANS = "POINTS_TRANS";
String POINTS_EXCHANGE_GOODS = "POINTS_EXCHANGE_GOODS";
String SYSTEM_OPERATE = "SYSTEM_OPERATE";
String OTHER = "OHHER";
}
package com.topdraw.business.module.task.template.constant;
/**
* @author :
* @description:
* @function :
* @date :Created in 2022/6/18 14:30
* @version: :
* @modified By:
* @since : modified in 2022/6/18 14:30
*/
public interface TaskEventType {
//类型 1:登录;2:观影;3:参加活动;4:订购;5:优享会员;6:签到;7:完成设置;
// 8:播放记录;10:跨屏绑定;11:积分转移;30:积分兑换商品;98:系统操作;99:其他
int LOGIN = 1;
int VIEW = 2;
int ACTIVITY = 3;
int ORDER = 4;
int MEMBER_PRIORITY = 5;
int SIGN = 6;
int COMPLETE_INFO = 7;
int PLAY = 8;
int BINDING = 10;
int POINTS_TRANS = 11;
int POINTS_EXCHANGE_GOODS = 30;
int SYSTEM_OPERATE = 98;
int OHHER = 99;
}
package com.topdraw.business.module.user.app.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author XiangHan
* @date 2022-06-27
*/
@Entity
@Data
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="uc_user_app")
public class UserApp implements Serializable {
// 第三方账号类型 3:微信;4:QQ;5:微博;6:苹果账号
@Transient
private Integer accountType;
// 第三方账号
@Transient
private String account;
// ID
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 会员id
@Column(name = "member_id")
private Long memberId;
// 用户名(一般为手机号)
@Column(name = "username", nullable = false)
private String username;
// 密码
@Column(name = "password")
private String password;
// 类型 0:苹果;1:安卓;-1:未知
@Column(name = "type", nullable = false)
private Integer type;
// 状态 0:禁用;1:生效;-1:注销
@Column(name = "status", nullable = false)
private Integer status;
// 昵称
@Column(name = "nickname")
private String nickname;
// 头像地址
@Column(name = "headimgurl")
private String headimgurl;
// 邮箱
@Column(name = "email")
private String email;
// 手机号
@Column(name = "cellphone")
private String cellphone;
// 性别 0:女;1:男;-1:其他
@Column(name = "gender")
private Integer gender;
// 生日
@Column(name = "birthday")
private String birthday;
// 最近活跃时间
@Column(name = "last_active_time")
private Timestamp lastActiveTime;
// 注销时间
@Column(name = "delete_time")
private Timestamp deleteTime;
// 标签
@Column(name = "tags")
private String tags;
// 描述
@Column(name = "description")
private String description;
// 创建时间
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
// 更新时间
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
public void copy(UserApp source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}
package com.topdraw.business.module.user.app.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author XiangHan
* @date 2022-06-27
*/
@Entity
@Data
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="uc_user_app_bind")
public class UserAppBind implements Serializable {
@Transient
private String username;
@Transient
private String password;
@Transient
private String headImgUrl;
// 主键
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 第三方账号类型 3:微信;4:QQ;5:微博;6:苹果账号
@Column(name = "account_type", nullable = false)
private Integer accountType;
// 第三方账号
@Column(name = "account", nullable = false)
private String account;
// app账号id
@Column(name = "user_app_id", nullable = false)
private Long userAppId;
// 绑定状态 0:解绑;1 绑定
@Column(name = "status", nullable = false)
private Integer status;
// 昵称
@Column(name = "nickname", nullable = false)
private String nickname;
// 创建时间
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
// 更新时间
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
public void copy(UserAppBind source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}
package com.topdraw.business.module.user.app.domain;
/**
* @author :
* @description:
* @function :
* @date :Created in 2022/6/30 13:18
* @version: :
* @modified By:
* @since : modified in 2022/6/30 13:18
*/
public class UserAppBindBuilder {
public static UserAppBind build(Long userAppId, String account, Integer accountType){
UserAppBind userAppBind = new UserAppBind();
userAppBind.setAccount(account);
userAppBind.setUserAppId(userAppId);
userAppBind.setAccountType(accountType);
userAppBind.setStatus(UserAppStatusConstant.VALID_STATUS);
return userAppBind;
}
}
package com.topdraw.business.module.user.app.domain;
/**
* @author :
* @description:
* @function :
* @date :Created in 2022/6/30 11:42
* @version: :
* @modified By:
* @since : modified in 2022/6/30 11:42
*/
public interface UserAppBindStatusConstant {
// 绑定状态 0:解绑;1 绑定
Integer VALID_STATUS = 1;
Integer INVALID_STATUS = 0;
}
package com.topdraw.business.module.user.app.domain;
import com.topdraw.util.TimestampUtil;
import org.apache.commons.lang3.StringUtils;
import java.util.Objects;
/**
* @author :
* @description:
* @function :
* @date :Created in 2022/6/30 11:35
* @version: :
* @modified By:
* @since : modified in 2022/6/30 11:35
*/
public class UserAppBuilder {
public static UserApp build(Long memberId, UserApp resource){
UserApp userApp = new UserApp();
userApp.setId(null);
userApp.setMemberId(memberId);
userApp.setUsername(resource.getUsername());
userApp.setTags(resource.getTags());
userApp.setLastActiveTime(TimestampUtil.now());
userApp.setEmail(resource.getEmail());
userApp.setType(Objects.isNull(resource.getType()) ? resource.getType() : -1);
userApp.setNickname(StringUtils.isNotBlank(resource.getNickname()) ? resource.getNickname() : resource.getUsername());
userApp.setHeadimgurl(resource.getHeadimgurl());
userApp.setPassword(resource.getPassword());
userApp.setCellphone(StringUtils.isNotBlank(resource.getCellphone()) ? resource.getCellphone() : resource.getUsername());
userApp.setBirthday(StringUtils.isNotBlank(resource.getBirthday()) ? resource.getBirthday() : "1900-01-01");
userApp.setGender(Objects.nonNull(resource.getGender()) ? resource.getGender() : 0);
userApp.setStatus(UserAppStatusConstant.VALID_STATUS);
userApp.setCreateTime(null);
userApp.setUpdateTime(null);
return userApp;
}
}
package com.topdraw.business.module.user.app.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author XiangHan
* @date 2022-06-27
*/
@Entity
@Data
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="uc_user_app")
public class UserAppIdManual implements Serializable {
// 第三方账号类型 3:微信;4:QQ;5:微博;6:苹果账号
@Transient
private Integer accountType;
// 第三方账号
@Transient
private String account;
@Transient
private String memberCode;
// ID
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(name = "id")
private Long id;
// 会员id
@Column(name = "member_id")
private Long memberId;
// 用户名(一般为手机号)
@Column(name = "username", nullable = false)
private String username;
// 密码
@Column(name = "password")
private String password;
// 类型 0:苹果;1:安卓;-1:未知
@Column(name = "type", nullable = false)
private Integer type;
// 状态 0:禁用;1:生效;-1:注销
@Column(name = "status", nullable = false)
private Integer status;
// 昵称
@Column(name = "nickname")
private String nickname;
// 头像地址
@Column(name = "headimgurl")
private String headimgurl;
// 邮箱
@Column(name = "email")
private String email;
// 手机号
@Column(name = "cellphone")
private String cellphone;
// 性别 0:女;1:男;-1:其他
@Column(name = "gender")
private Integer gender;
// 生日
@Column(name = "birthday")
private String birthday;
// 最近活跃时间
@Column(name = "last_active_time")
private Timestamp lastActiveTime;
// 注销时间
@Column(name = "delete_time")
private Timestamp deleteTime;
// 标签
@Column(name = "tags")
private String tags;
// 描述
@Column(name = "description")
private String description;
// 创建时间
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
// 更新时间
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
public void copy(UserAppIdManual source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}
package com.topdraw.business.module.user.app.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
/**
* @author XiangHan
* @date 2022-06-27
*/
@Entity
@Data
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="uc_user_app")
public class UserAppSimple implements Serializable {
// ID
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 会员id
@Column(name = "member_id")
private Long memberId;
// 用户名(一般为手机号)
@Column(name = "username", nullable = false)
private String username;
// 状态 0:禁用;1:生效;-1:注销
@Column(name = "status", nullable = false)
private Integer status;
// 昵称
@Column(name = "nickname")
private String nickname;
// 头像地址
@Column(name = "headimgurl")
private String headimgurl;
// 邮箱
@Column(name = "email")
private String email;
// 手机号
@Column(name = "cellphone")
private String cellphone;
// 性别 0:女;1:男;-1:其他
@Column(name = "gender")
private Integer gender;
// 生日
@Column(name = "birthday")
private String birthday;
// 标签
@Column(name = "tags")
private String tags;
// 描述
@Column(name = "description")
private String description;
public void copy(UserAppSimple source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}
package com.topdraw.business.module.user.app.domain;
/**
* @author :
* @description:
* @function :
* @date :Created in 2022/6/30 11:42
* @version: :
* @modified By:
* @since : modified in 2022/6/30 11:42
*/
public interface UserAppStatusConstant {
// 状态 0:禁用;1:生效;-1:注销
Integer VALID_STATUS = 1;
Integer FORBID_STATUS = 0;
Integer INVALID_STATUS = -1;
}
package com.topdraw.business.module.user.app.repository;
import com.topdraw.business.module.user.app.domain.UserAppBind;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;
import java.util.Optional;
/**
* @author XiangHan
* @date 2022-06-27
*/
public interface UserAppBindRepository extends JpaRepository<UserAppBind, Long>, JpaSpecificationExecutor<UserAppBind> {
Optional<UserAppBind> findFirstByAccount(String account);
@Modifying
@Query(value = "UPDATE `uc_user_app_bind` SET `status` = 0 , `update_time` = now() WHERE `account` = ?1 AND `account_type` = ?2", nativeQuery = true)
Integer cancelUserAppBind(String account, Integer accountType);
Optional<UserAppBind> findFirstByAccountAndAccountType(String account, Integer accountType);
@Modifying
@Query(value = "UPDATE `uc_user_app_bind` SET `status` = :#{#resources.status}, `update_time` = now(), " +
" `user_app_id` = :#{#resources.userAppId}, `nickname` = :#{#resources.nickname} " +
" WHERE `account` = :#{#resources.account} AND accountType = :#{#resources.accountType}", nativeQuery = true)
Integer updateThirdAccount(@Param("resources") UserAppBind resources);
@Modifying
@Query(value = "UPDATE `uc_user_app_bind` SET `status` = :#{#resources.status}, `update_time` = now(), " +
" `user_app_id` = :#{#resources.userAppId} WHERE `account` = :#{#resources.account} AND accountType = :#{#resources.accountType}",
nativeQuery = true)
Integer updateThirdAccountStatusAndUserAppId(@Param("resources") UserAppBind resources);
@Modifying
@Query(value = "UPDATE `uc_user_app_bind` SET `status` = 1, `update_time` = now(), " +
" `user_app_id` = :#{#resources.userAppId} WHERE `account` = :#{#resources.account} AND accountType = :#{#resources.accountType}",
nativeQuery = true)
Integer updateValidStatusAndUserAppId(@Param("resources") UserAppBind resources);
@Modifying
@Query(value = "UPDATE `uc_user_app_bind` SET `update_time` = now(), `nickname` = :#{#resources.nickname} " +
" WHERE `account` = :#{#resources.account} AND `account_type` = :#{#resources.accountType}", nativeQuery = true)
Integer updateThirdAccountNickname(@Param("resources") UserAppBind resources);
@Modifying
@Query(value = "UPDATE `uc_user_app_bind` SET `update_time` = now(), `nickname` = :#{#resources.nickname}, `status` = 1, `user_app_id` = :#{#resources.userAppId} " +
" WHERE `account` = :#{#resources.account} AND `account_type` = :#{#resources.accountType}", nativeQuery = true)
Integer updateValidStatusAndUserAppIdAndNickname(@Param("resources") UserAppBind resources);
@Modifying
@Query(value = "UPDATE `uc_user_app_bind` SET `update_time` = now(), `status` = 0 WHERE `id` IN ?1", nativeQuery = true)
Integer appCancellation(List<Long> ids);
List<UserAppBind> findByUserAppId(Long id);
}
package com.topdraw.business.module.user.app.repository;
import com.topdraw.business.module.user.app.domain.UserApp;
import com.topdraw.business.module.user.app.domain.UserAppIdManual;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.Optional;
/**
* @author XiangHan
* @date 2022-06-27
*/
public interface UserAppRepository extends JpaRepository<UserApp, Long>, JpaSpecificationExecutor<UserApp> {
@Query(value = "SELECT ua.* FROM uc_user_app ua WHERE ua.`username` = ?1 and ua.`status` IN (0 , 1)", nativeQuery = true)
Optional<UserApp> findByUsername(String username);
Optional<UserApp> findByUsernameAndPassword(String username, String password);
@Modifying
@Query(value = "UPDATE `uc_user_app` SET `update_time` = now(), `last_active_time` = now() WHERE `username` = ?1 AND `status` = 1 ", nativeQuery = true)
Integer updateLastActiveTime(String username);
@Modifying
@Query(value = "UPDATE `uc_user_app` SET `update_time` = now(), `password` = ?2 WHERE `username` = ?1 AND `status` = 1", nativeQuery = true)
Integer updatePasswordByUsername(String username, String password);
@Modifying
@Query(value = "UPDATE `uc_user_app` SET `update_time` = now(), `nickname` = :#{#resources.nickname}, " +
" `headimgurl` = :#{#resources.headimgurl}, `email` = :#{#resources.email}, `cellphone` = :#{#resources.cellphone}, " +
" `gender` = :#{#resources.gender}, `birthday` = :#{#resources.birthday}, `tags` = :#{#resources.tags}, `description` = :#{#resources.description}" +
" WHERE `id` = :#{#resources.id}", nativeQuery = true)
Integer updateAppInfo(@Param("resources") UserApp resources);
@Modifying
@Query(value = "UPDATE `uc_user_app` SET `update_time` = now(), `password` = ?2 WHERE `id` = ?1", nativeQuery = true)
Integer updatePasswordById(Long id, String password);
@Modifying
@Query(value = "UPDATE `uc_user_app` SET `update_time` = now(),`delete_time` = now(), `status` = -1 WHERE `id` = ?1", nativeQuery = true)
Integer appCancellation(Long id);
@Modifying
@Query(value = "UPDATE `uc_user_app` SET `last_active_time` = now(), `nickname` = ?2, `headimgurl` = ?3 " +
" WHERE `username` = ?1 and `status` = 1 ", nativeQuery = true)
Integer updateAppLastActiveTimeAndNicknameAndHeadImg(String username, String nickname, String headimgurl);
@Modifying
@Query(value = "INSERT INTO `uc_user_app`(`id`, `member_id`, `username`, `password`, `type`, `status`, `nickname`, `headimgurl`, `email`, `cellphone`, `gender`, `birthday`, `last_active_time`, `delete_time`, `tags`, `description`, `create_time`, `update_time`) " +
" VALUES (:#{#resources.id}, :#{#resources.memberId}, :#{#resources.username}, :#{#resources.password}, :#{#resources.type}," +
" 1, :#{#resources.nickname}, :#{#resources.headimgurl}, :#{#resources.email}, :#{#resources.cellphone}, " +
" :#{#resources.gender}, NULL, now(), NULL, :#{#resources.tags}, " +
" :#{#resources.description}, :#{#resources.createTime}, now());", nativeQuery = true)
void saveByIdManual(@Param("resources") UserAppIdManual userAppIdManual);
@Modifying
@Query(value = "UPDATE `uc_user_app` SET `username`= :#{#resources.username},`cellphone`= :#{#resources.cellphone}, `last_active_time` = now(), `nickname` = :#{#resources.nickname}, `headimgurl` = :#{#resources.headimgurl} " +
" WHERE `id` = :#{#resources.id} and `status` = 1 ", nativeQuery = true)
Integer updateAppLastActiveTimeAndNicknameAndHeadImgById(@Param("resources") UserApp userApp);
}
package com.topdraw.business.module.user.app.repository;
import com.topdraw.business.module.user.app.domain.UserAppSimple;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author XiangHan
* @date 2022-06-27
*/
public interface UserAppSimpleRepository extends JpaRepository<UserAppSimple, Long>, JpaSpecificationExecutor<UserAppSimple> {
}
package com.topdraw.business.module.user.app.service;
import com.topdraw.business.module.user.app.domain.UserAppBind;
import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO;
import java.util.List;
/**
* @author XiangHan
* @date 2022-06-27
*/
public interface UserAppBindService {
/**
* 根据ID查询
* @param id ID
* @return UserAppBindDTO
*/
UserAppBindDTO findById(Long id);
/**
*
* @param resources
*/
UserAppBindDTO create(UserAppBind resources);
/**
*
* @param resources
*/
void update(UserAppBind resources);
/**
*
* @param id
*/
void delete(Long id);
/**
*
* @param account
* @return
*/
UserAppBindDTO findFirstByAccount(String account);
/**
*
* @param account
* @return
*/
boolean cancelUserAppBind(String account, Integer accountType);
/**
*
* @param account
* @param accountType
* @return
*/
UserAppBindDTO findFirstByAccountAndAccountType(String account, Integer accountType);
/**
*
* @param resources
* @return
*/
boolean updateThirdAccount(UserAppBind resources);
/**
*
* @param resources
* @return
*/
boolean updateThirdAccountNickname(UserAppBind resources);
/**
*
* @param resources
* @return
*/
boolean updateValidStatusAndUserAppIdAndNickname(UserAppBind resources);
boolean appCancellation(List<Long> ids);
List<UserAppBindDTO> findByUserAppId(Long id);
}
package com.topdraw.business.module.user.app.service;
import com.topdraw.business.module.user.app.domain.UserApp;
import com.topdraw.business.module.user.app.domain.UserAppBind;
import com.topdraw.business.module.user.app.domain.UserAppIdManual;
import com.topdraw.business.module.user.app.service.dto.UserAppDTO;
import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO;
import com.topdraw.business.module.vis.hainan.apple.domain.VisUserApple;
import com.topdraw.business.module.vis.hainan.qq.domain.VisUserQq;
import com.topdraw.business.module.vis.hainan.weibo.domain.VisUserWeibo;
import com.topdraw.business.module.vis.hainan.weixin.domain.VisUserWeixin;
/**
* @author XiangHan
* @date 2022-06-27
*/
public interface UserAppService {
/**
* 根据ID查询
* @param id ID
* @return UserAppDTO
*/
UserAppDTO findById(Long id);
/**
* 检查账号和秘密
* @param username
* @return
*/
UserAppDTO findByUsername(String username);
/**
*
* @param resources
*/
UserAppDTO create(UserApp resources);
/**
*
* @param resources
*/
UserAppDTO update(UserApp resources);
/**
*
* @param id
*/
void delete(Long id);
/**
*
* @param resources
* @return
*/
boolean updateLastActiveTime(UserAppBind resources);
/**
*
* @param resources
* @return
*/
boolean updatePasswordByUsername(UserApp resources);
/**
*
* @param resources
* @return
*/
boolean updatePasswordById(UserApp resources);
/**
*
* @param resources
* @return
*/
boolean updateAppInfo(UserApp resources);
/**
*
* @param id
* @return
*/
boolean appCancellation(Long id);
/**
*
* @param resources
* @return
*/
boolean updateAppLastActiveTimeAndNicknameAndHeadImg(UserApp resources);
/**
*
* @param resources
* @return
*/
boolean asyncSaveByIdManual(UserAppIdManual resources);
}
package com.topdraw.business.module.user.app.service.dto;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import lombok.Data;
/**
* @author :
* @description:
* @function :
* @date :Created in 2022/7/11 21:21
* @version: :
* @modified By:
* @since : modified in 2022/7/11 21:21
*/
@Data
public class AppRegisterDTO {
private UserAppDTO userAppDTO;
private MemberDTO memberDTO;
}
package com.topdraw.business.module.user.app.service.dto;
import lombok.Data;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author XiangHan
* @date 2022-06-27
*/
@Data
public class UserAppBindDTO implements Serializable {
// 主键
private Long id;
// 第三方账号类型 3:微信;4:QQ;5:微博;6:苹果账号
private Integer accountType;
// 第三方账号
private String account;
// app账号id
private Long userAppId;
// 绑定状态 0:解绑;1 绑定
private Integer status;
// 昵称
private String nickname;
// 创建时间
private Timestamp createTime;
// 更新时间
private Timestamp updateTime;
}
package com.topdraw.business.module.user.app.service.dto;
import lombok.Data;
import javax.persistence.Transient;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author XiangHan
* @date 2022-06-27
*/
@Data
public class UserAppDTO implements Serializable {
// 第三方账号类型 3:微信;4:QQ;5:微博;6:苹果账号
private Integer accountType;
// 第三方账号
private String account;
// ID
private Long id;
// 会员id
private Long memberId;
// 用户名(一般为手机号)
private String username;
// 密码
private String password;
// 类型 0:苹果;1:安卓;-1:未知
private Integer type;
// 状态 0:禁用;1:生效;-1:注销
private Integer status;
// 昵称
private String nickname;
// 头像地址
private String headimgurl;
// 邮箱
private String email;
// 手机号
private String cellphone;
// 性别 0:女;1:男;-1:其他
private Integer gender;
// 生日
private String birthday;
// 最近活跃时间
private Timestamp lastActiveTime;
// 注销时间
private Timestamp deleteTime;
// 标签
private String tags;
// 描述
private String description;
// 创建时间
private Timestamp createTime;
// 更新时间
private Timestamp updateTime;
}
package com.topdraw.business.module.user.app.service.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @author XiangHan
* @date 2022-06-27
*/
@Data
public class UserAppSimpleDTO implements Serializable {
// ID
private Long id;
// 会员id
private Long memberId;
// 用户名(一般为手机号)
private String username;
// 状态 0:禁用;1:生效;-1:注销
private Integer status;
// 昵称
private String nickname;
// 头像地址
private String headimgurl;
// 邮箱
private String email;
// 手机号
private String cellphone;
// 性别 0:女;1:男;-1:其他
private Integer gender;
// 生日
private String birthday;
// 标签
private String tags;
// 描述
private String description;
}
package com.topdraw.business.module.user.app.service.impl;
import com.topdraw.business.module.user.app.domain.UserAppBind;
import com.topdraw.business.module.user.app.repository.UserAppBindRepository;
import com.topdraw.business.module.user.app.service.UserAppBindService;
import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO;
import com.topdraw.business.module.user.app.service.mapper.UserAppBindMapper;
import com.topdraw.utils.ValidationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import java.util.List;
/**
* @author XiangHan
* @date 2022-06-27
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class UserAppBindServiceImpl implements UserAppBindService {
@Autowired
private UserAppBindRepository userAppBindRepository;
@Autowired
private UserAppBindMapper userAppBindMapper;
@Override
public UserAppBindDTO findById(Long id) {
UserAppBind userAppBind = this.userAppBindRepository.findById(id).orElseGet(UserAppBind::new);
ValidationUtil.isNull(userAppBind.getId(),"UserAppBind","id",id);
return this.userAppBindMapper.toDto(userAppBind);
}
@Override
@Transactional(rollbackFor = Exception.class)
public UserAppBindDTO create(UserAppBind resources) {
UserAppBind userAppBind = this.userAppBindRepository.save(resources);
return this.userAppBindMapper.toDto(userAppBind);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(UserAppBind resources) {
UserAppBind userAppBind = this.userAppBindRepository.findById(resources.getId()).orElseGet(UserAppBind::new);
ValidationUtil.isNull( userAppBind.getId(),"UserAppBind","id",resources.getId());
userAppBind.copy(resources);
this.userAppBindRepository.save(userAppBind);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
UserAppBind UserAppBind = this.userAppBindRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", com.topdraw.business.module.user.app.domain.UserAppBind.class, id), 1));
this.userAppBindRepository.delete(UserAppBind);
}
@Override
public UserAppBindDTO findFirstByAccount(String account) {
UserAppBind userAppBind = this.userAppBindRepository.findFirstByAccount(account).orElseGet(UserAppBind::new);
return this.userAppBindMapper.toDto(userAppBind);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean cancelUserAppBind(String account, Integer accountType) {
return this.userAppBindRepository.cancelUserAppBind(account, accountType) > 0;
}
@Override
@Transactional(readOnly = true)
public UserAppBindDTO findFirstByAccountAndAccountType(String account, Integer accountType) {
UserAppBind userAppBind = this.userAppBindRepository.findFirstByAccountAndAccountType(account, accountType).orElseGet(UserAppBind::new);
return this.userAppBindMapper.toDto(userAppBind);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateThirdAccount(UserAppBind resources) {
return this.userAppBindRepository.updateThirdAccount(resources) > 0;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateThirdAccountNickname(UserAppBind resources) {
return this.userAppBindRepository.updateThirdAccountNickname(resources) > 0;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateValidStatusAndUserAppIdAndNickname(UserAppBind resources) {
return this.userAppBindRepository.updateValidStatusAndUserAppIdAndNickname(resources) > 0;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean appCancellation(List<Long> ids) {
return this.userAppBindRepository.appCancellation(ids) > 0;
}
@Override
@Transactional(readOnly = true)
public List<UserAppBindDTO> findByUserAppId(Long id) {
List<UserAppBind> userAppBinds = this.userAppBindRepository.findByUserAppId(id);
return this.userAppBindMapper.toDto(userAppBinds);
}
}
package com.topdraw.business.module.user.app.service.impl;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.domain.MemberBuilder;
import com.topdraw.business.module.member.domain.MemberTypeConstant;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.user.app.domain.UserApp;
import com.topdraw.business.module.user.app.domain.UserAppBind;
import com.topdraw.business.module.user.app.domain.UserAppIdManual;
import com.topdraw.business.module.user.app.repository.UserAppRepository;
import com.topdraw.business.module.user.app.repository.UserAppSimpleRepository;
import com.topdraw.business.module.user.app.service.UserAppService;
import com.topdraw.business.module.user.app.service.dto.UserAppDTO;
import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO;
import com.topdraw.business.module.user.app.service.mapper.UserAppMapper;
import com.topdraw.business.module.vis.hainan.apple.domain.VisUserApple;
import com.topdraw.business.module.vis.hainan.qq.domain.VisUserQq;
import com.topdraw.business.module.vis.hainan.weibo.domain.VisUserWeibo;
import com.topdraw.business.module.vis.hainan.weixin.domain.VisUserWeixin;
import com.topdraw.utils.ValidationUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import java.util.Objects;
/**
* @author XiangHan
* @date 2022-06-27
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
@Slf4j
public class UserAppServiceImpl implements UserAppService {
@Autowired
private UserAppRepository userAppRepository;
@Autowired
private UserAppSimpleRepository userAppSimpleRepository;
@Autowired
private UserAppMapper userAppMapper;
@Autowired
private MemberService memberService;
@Override
@Transactional(readOnly = true)
public UserAppDTO findById(Long id) {
UserApp userApp = this.userAppRepository.findById(id).orElseGet(UserApp::new);
ValidationUtil.isNull(userApp.getId(),"UserApp","id",id);
return this.userAppMapper.toDto(userApp);
}
@Override
@Transactional(readOnly = true)
public UserAppDTO findByUsername(String username) {
UserApp userApp = this.userAppRepository.findByUsername(username).orElseGet(UserApp::new);
return this.userAppMapper.toDto(userApp);
}
@Override
@Transactional(rollbackFor = Exception.class)
public UserAppDTO create(UserApp resources) {
UserApp userApp = this.userAppRepository.save(resources);
return this.userAppMapper.toDto(userApp);
}
@Override
@Transactional(rollbackFor = Exception.class)
public UserAppDTO update(UserApp resources) {
UserApp userApp = this.userAppRepository.findById(resources.getId()).orElseGet(UserApp::new);
ValidationUtil.isNull( userApp.getId(),"UserApp","id",resources.getId());
userApp.copy(resources);
UserApp _userApp = this.userAppRepository.save(userApp);
if (Objects.nonNull(_userApp.getId())) {
return this.userAppMapper.toDto(_userApp);
}
return this.userAppMapper.toDto(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
UserApp UserApp = this.userAppRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", UserApp.class, id), 1));
this.userAppRepository.delete(UserApp);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateLastActiveTime(UserAppBind resources) {
return this.userAppRepository.updateLastActiveTime(resources.getUsername()) > 0;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updatePasswordByUsername(UserApp resources) {
return this.userAppRepository.updatePasswordByUsername(resources.getUsername(), resources.getPassword()) > 0;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateAppInfo(UserApp resources) {
Long id = resources.getId();
UserApp userApp = this.userAppRepository.findById(id).orElseGet(UserApp::new);
if (Objects.isNull(userApp.getId())) {
log.error("修改app信息失败,app账号信息不存在[updateAppInfo#]");
return false;
}
userApp.copy(resources);
this.userAppRepository.updateAppInfo(userApp);
return true;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean appCancellation(Long id) {
return this.userAppRepository.appCancellation(id) > 0;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateAppLastActiveTimeAndNicknameAndHeadImg(UserApp resources) {
return this.userAppRepository.updateAppLastActiveTimeAndNicknameAndHeadImg(resources.getUsername(),
resources.getNickname(), resources.getHeadimgurl()) > 0;
}
@Transactional(rollbackFor = Exception.class)
public void asyncUpdateAppLastActiveTimeAndNicknameAndHeadImgById(UserApp resources) {
this.userAppRepository.updateAppLastActiveTimeAndNicknameAndHeadImgById(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean asyncSaveByIdManual(UserAppIdManual resources) {
String memberCode = resources.getMemberCode();
Member member = new Member();
member.setVip(0);
member.setType(MemberTypeConstant.app);
member.setCode(memberCode);
member.setNickname(resources.getNickname());
member.setAvatarUrl(resources.getHeadimgurl());
Member _member = MemberBuilder.build(member);
MemberDTO memberDTO = memberService.create(_member);
resources.setMemberId(memberDTO.getId());
this.userAppRepository.saveByIdManual(resources);
return true;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updatePasswordById(UserApp resources) {
return this.userAppRepository.updatePasswordById(resources.getId(), resources.getPassword()) > 0;
}
}
package com.topdraw.business.module.user.app.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.module.user.app.domain.UserAppBind;
import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author XiangHan
* @date 2022-06-27
*/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface UserAppBindMapper extends BaseMapper<UserAppBindDTO, UserAppBind> {
}
package com.topdraw.business.module.user.app.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.module.user.app.domain.UserApp;
import com.topdraw.business.module.user.app.service.dto.UserAppDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author XiangHan
* @date 2022-06-27
*/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface UserAppMapper extends BaseMapper<UserAppDTO, UserApp> {
}
package com.topdraw.business.module.user.app.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.module.user.app.domain.UserAppSimple;
import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author XiangHan
* @date 2022-06-27
*/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface UserAppSimpleMapper extends BaseMapper<UserAppSimpleDTO, UserAppSimple> {
}
package com.topdraw.business.module.user.iptv.growreport.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author XiangHan
* @date 2022-07-07
*/
@Entity
@Data
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="uc_growth_report")
public class GrowthReport implements Serializable {
@Id
@Column(name = "id")
private Long id;
// 用户id
@Column(name = "user_id")
private Long userId;
// 会员id
@Column(name = "member_id")
private Long memberId;
// 会员code
@Column(name = "member_code")
private String memberCode;
// 大屏账号
@Column(name = "platform_account")
private String platformAccount;
// 开始日期
@Column(name = "start_date")
private String startDate;
// 结束时间
@Column(name = "end_date")
private String endDate;
// 栏目播放时长数据
@Column(name = "data")
private String data;
// 创建时间
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
// 修改时间
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
public void copy(GrowthReport source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}
package com.topdraw.business.module.user.iptv.growreport.repository;
import com.topdraw.business.module.user.iptv.growreport.domain.GrowthReport;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import java.util.Optional;
/**
* @author XiangHan
* @date 2022-07-07
*/
public interface GrowthReportRepository extends JpaRepository<GrowthReport, Long>, JpaSpecificationExecutor<GrowthReport> {
Optional<GrowthReport> findByPlatformAccountAndStartDateAndEndDate(String platformAccount, String startDate, String endDate);
@Modifying
@Query(value = "UPDATE `uc_growth_report` SET `data` = ?2, `update_time` = now() WHERE `id` =?1", nativeQuery = true)
Integer updateGrowthReportData(Long id, String data);
}
package com.topdraw.business.module.user.iptv.growreport.service;
import com.topdraw.business.module.user.iptv.growreport.domain.GrowthReport;
import com.topdraw.business.module.user.iptv.growreport.service.dto.GrowthReportDTO;
/**
* @author XiangHan
* @date 2022-07-07
*/
public interface GrowthReportService {
/**
* 根据ID查询
* @param id ID
* @return GrowthReportDTO
*/
GrowthReportDTO findById(Long id);
void create(GrowthReport resources);
void update(GrowthReport resources);
void delete(Long id);
GrowthReportDTO findByPlatformAccountAndStartDateAndEndDate(String platformAccount, String weekFirstDay, String weekLastDay);
Integer updateGrowthReportData(Long id, String data);
}
package com.topdraw.business.module.user.iptv.growreport.service.dto;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author XiangHan
* @date 2022-07-07
*/
@Data
public class GrowthReportDTO implements Serializable {
// 处理精度丢失问题
@JsonSerialize(using= ToStringSerializer.class)
private Long id;
// 用户id
private Long userId;
// 会员id
private Long memberId;
// 会员code
private String memberCode;
// 大屏账号
private String platformAccount;
// 开始日期
private String startDate;
// 结束时间
private String endDate;
// 栏目播放时长数据
private String data;
// 创建时间
private Timestamp createTime;
// 修改时间
private Timestamp updateTime;
}
package com.topdraw.business.module.user.iptv.growreport.service.impl;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import com.topdraw.business.module.user.iptv.growreport.domain.GrowthReport;
import com.topdraw.business.module.user.iptv.growreport.repository.GrowthReportRepository;
import com.topdraw.business.module.user.iptv.growreport.service.GrowthReportService;
import com.topdraw.business.module.user.iptv.growreport.service.dto.GrowthReportDTO;
import com.topdraw.business.module.user.iptv.growreport.service.mapper.GrowthReportMapper;
import com.topdraw.utils.ValidationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
/**
* @author XiangHan
* @date 2022-07-07
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class GrowthReportServiceImpl implements GrowthReportService {
@Autowired
private GrowthReportRepository growthReportRepository;
@Autowired
private GrowthReportMapper growthReportMapper;
@Override
public GrowthReportDTO findById(Long id) {
GrowthReport growthReport = this.growthReportRepository.findById(id).orElseGet(GrowthReport::new);
ValidationUtil.isNull(growthReport.getId(),"GrowthReport","id",id);
return this.growthReportMapper.toDto(growthReport);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(GrowthReport resources) {
Snowflake snowflake = IdUtil.createSnowflake(1, 1);
resources.setId(snowflake.nextId());
this.growthReportRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(GrowthReport resources) {
GrowthReport growthReport = this.growthReportRepository.findById(resources.getId()).orElseGet(GrowthReport::new);
ValidationUtil.isNull( growthReport.getId(),"GrowthReport","id",resources.getId());
growthReport.copy(resources);
this.growthReportRepository.save(growthReport);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
GrowthReport growthReport = this.growthReportRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", GrowthReport.class, id), 1));
this.growthReportRepository.delete(growthReport);
}
@Override
public GrowthReportDTO findByPlatformAccountAndStartDateAndEndDate(String platformAccount, String weekFirstDay, String weekLastDay) {
GrowthReport growthReport = this.growthReportRepository.findByPlatformAccountAndStartDateAndEndDate(platformAccount, weekFirstDay, weekLastDay).orElseGet(GrowthReport::new);
return this.growthReportMapper.toDto(growthReport);
}
@Override
@Transactional(rollbackFor = Exception.class)
public Integer updateGrowthReportData(Long id, String data) {
return this.growthReportRepository.updateGrowthReportData(id, data);
}
}
package com.topdraw.business.module.user.iptv.growreport.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.module.user.iptv.growreport.domain.GrowthReport;
import com.topdraw.business.module.user.iptv.growreport.service.dto.GrowthReportDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author XiangHan
* @date 2022-07-07
*/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface GrowthReportMapper extends BaseMapper<GrowthReportDTO, GrowthReport> {
}
......@@ -3,7 +3,11 @@ package com.topdraw.business.module.user.iptv.repository;
import com.topdraw.business.module.user.iptv.domain.UserTv;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.time.LocalDateTime;
import java.util.Optional;
/**
......@@ -18,4 +22,45 @@ public interface UserTvRepository extends JpaRepository<UserTv, Long>, JpaSpecif
Optional<UserTv> findByMemberId(Long memberId);
@Modifying
@Query(value = "UPDATE `uc_user_tv` SET `vis_user_id` = ?2, `update_time` = ?3 WHERE `id` = ?1", nativeQuery = true)
Integer updateUserTvVisUserId(Long id, Long visUserId, LocalDateTime now);
@Modifying
@Query(value = "UPDATE `uc_user_tv` SET `member_id` = ?2, `update_time` = now() WHERE `platform_account` = ?1", nativeQuery = true)
void updateMemberId(String platformAccount, Long memberId);
@Modifying
@Query(value = "UPDATE `uc_user_tv` SET `priority_member_code` = ?2, `update_time` = now() WHERE `platform_account` = ?1", nativeQuery = true)
void updatePriorityMemberCode(String platformAccount, String priorityMemberCode);
@Modifying
@Query(value = "UPDATE `uc_user_tv` SET " +
" `cellphone` = :#{#resources.cellphone}, " +
" `username` = :#{#resources.username}, " +
" `nickname` = :#{#resources.nickname}, " +
" `image` = :#{#resources.image}, " +
" `platform` = :#{#resources.platform}, " +
" `login_days` = :#{#resources.loginDays}, " +
" `continue_days` = :#{#resources.continueDays}, " +
" `active_time` = :#{#resources.activeTime}, " +
" `groups` = :#{#resources.groups}, " +
" `tags` = :#{#resources.tags}, " +
" `login_type` = :#{#resources.loginType}, " +
" `status` = :#{#resources.status}, " +
" `description` = :#{#resources.description}, " +
" `create_by` = :#{#resources.createBy}, " +
" `update_by` = :#{#resources.updateBy}, " +
" `priority_member_code` = :#{#resources.priorityMemberCode}, " +
" `vis_user_id` = :#{#resources.visUserId}, " +
" `update_time` = now() WHERE `platform_account` = :#{#resources.platformAccount}", nativeQuery = true)
void updateUserTvByPlatformAccount(@Param("resources") UserTv userTv);
Long countByPlatformAccount(String platformAccount);
@Modifying
@Query(value = "UPDATE `uc_user_tv` SET `priority_member_code` = :#{#resources.priorityMemberCode}, " +
"`update_time` = now() WHERE `platform_account` = :#{#resources.platformAccount}", nativeQuery = true)
void updatePriorityMemberCode(@Param("resources") UserTv userTv);
}
......
......@@ -80,4 +80,45 @@ public interface UserTvService {
*/
MemberDTO findMemberByPlatformAccount(String platformAccount);
/**
*
* @param resources
* @return
*/
UserTvDTO asyncUpdateUserTvVisUserId(UserTv resources);
/**
*
* @param platformAccount
* @param id
*/
void updateMemberId(String platformAccount, Long id);
/**
*
* @param platformAccount
* @param priorityMemberCode
*/
void updatePriorityMemberCode(String platformAccount, String priorityMemberCode);
/**
*
* @param userTv
*/
void updateUserTvByPlatformAccount(UserTv userTv);
/**
*
* @param platformAccount
* @return
*/
Long countByPlatformAccount(String platformAccount);
/**
*
* @param userTv
*/
void doUpdatePriorityMemberCode(UserTv userTv);
}
......
......@@ -7,10 +7,13 @@ import com.topdraw.business.module.user.iptv.repository.UserTvRepository;
import com.topdraw.business.module.user.iptv.service.UserTvService;
import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.module.user.iptv.service.mapper.UserTvMapper;
import com.topdraw.exception.BadRequestException;
import com.topdraw.exception.EntityNotFoundException;
import com.topdraw.exception.GlobeExceptionMsg;
import com.topdraw.utils.ValidationUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
......@@ -20,6 +23,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.Objects;
import java.util.Optional;
......@@ -29,6 +33,7 @@ import java.util.Optional;
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
@Slf4j
public class UserTvServiceImpl implements UserTvService {
......@@ -39,6 +44,36 @@ public class UserTvServiceImpl implements UserTvService {
@Autowired
private UserTvRepository userTvRepository;
@Override
@Transactional(rollbackFor = Exception.class)
public void updateMemberId(String platformAccount, Long memberId) {
this.userTvRepository.updateMemberId(platformAccount, memberId);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updatePriorityMemberCode(String platformAccount, String priorityMemberCode) {
this.userTvRepository.updatePriorityMemberCode(platformAccount, priorityMemberCode);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateUserTvByPlatformAccount(UserTv userTv) {
this.userTvRepository.updateUserTvByPlatformAccount(userTv);
}
@Override
public Long countByPlatformAccount(String platformAccount) {
return this.userTvRepository.countByPlatformAccount(platformAccount);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void doUpdatePriorityMemberCode(UserTv userTv) {
this.userTvRepository.updatePriorityMemberCode(userTv);
}
/**
* 获取大屏账户对应的会员
* <Waring>
......@@ -66,6 +101,34 @@ public class UserTvServiceImpl implements UserTvService {
throw new EntityNotFoundException(UserTvDTO.class,"platformAccount", GlobeExceptionMsg.IPTV_IS_NULL);
}
@Override
@Transactional(rollbackFor = Exception.class)
public UserTvDTO asyncUpdateUserTvVisUserId(UserTv resources) {
log.info("UserTvServiceImpl ==> updateUserTvVisUserId ==>> param ==> {}",resources);
if (StringUtils.isBlank(resources.getPlatformAccount())){
throw new BadRequestException(GlobeExceptionMsg.IPTV_PLATFORM_ACCOUNT_IS_NULL);
}
if (Objects.isNull(resources.getVisUserId())){
throw new BadRequestException(GlobeExceptionMsg.VIS_USER_ID_IS_NULL);
}
UserTvDTO userTvDTO = this.findByPlatformAccount(resources.getPlatformAccount());
if (Objects.nonNull(userTvDTO.getId())) {
this.userTvRepository.updateUserTvVisUserId(userTvDTO.getId(), resources.getVisUserId(), LocalDateTime.now());
} else {
log.error("修改大屏账号vis_user_id字段异常,请检查");
}
return null;
}
private MemberDTO findMemberByMemberCode(String memberCode) {
return this.memberService.findByCode(memberCode);
}
......@@ -121,13 +184,6 @@ public class UserTvServiceImpl implements UserTvService {
@Override
@Transactional(rollbackFor = Exception.class)
public void unbindPriorityMemberCode(UserTv resources) {
String platformAccount = resources.getPlatformAccount();
if (StringUtils.isNotBlank(platformAccount)) {
UserTvDTO userTvDTO = this.findByPlatformAccount(platformAccount);
Long id = userTvDTO.getId();
resources.setId(id);
resources.setMemberId(userTvDTO.getMemberId());
}
this.userTvRepository.save(resources);
}
......
......@@ -45,7 +45,7 @@ public class UserWeixinServiceImpl implements UserWeixinService {
@Transactional(rollbackFor = Exception.class)
public UserWeixin create(UserWeixin resources) {
MemberDTO memberDTO = memberService.findByCode(resources.getMemberCode());
if (Objects.nonNull(memberDTO)) {
if (Objects.nonNull(memberDTO.getId())) {
Long id = memberDTO.getId();
resources.setMemberId(id);
}
......
package com.topdraw.business.module.vis.hainan.app.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author XiangHan
* @date 2022-07-14
*/
@Entity
@Data
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="vis_user")
public class VisUser implements Serializable {
// ID
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 所有者ID
@Column(name = "person_id")
private Long personId;
// 平台
@Column(name = "platform")
private String platform;
// 平台账号
@Column(name = "platform_account")
private String platformAccount;
// 用户名
@Column(name = "username")
private String username;
// 密码
@Column(name = "password")
private String password;
// 积分
@Column(name = "points")
private Integer points;
// 昵称
@Column(name = "nickname")
private String nickname;
// 真实姓名
@Column(name = "realname")
private String realname;
// 头像
@Column(name = "image")
private String image;
// 电子邮件
@Column(name = "email")
private String email;
// 手机号
@Column(name = "cellphone")
private String cellphone;
// 0-女 1-男 2-其他
@Column(name = "gender")
private Integer gender;
// 生日
@Column(name = "birthday")
private Integer birthday;
// 登录天数(总天数)
@Column(name = "login_days")
private Integer loginDays;
// 连续天数
@Column(name = "continue_days")
private Integer continueDays;
// 活跃时间
@Column(name = "active_time")
private Timestamp activeTime;
// 标签
@Column(name = "tags")
private String tags;
// 登录类型:1-运营商隐式登录 2-手机验证登录 3-微信登录 4-QQ登录 5-微博登录 6-苹果登录
@Column(name = "login_type")
private Integer loginType;
// 用户绑定ID
@Column(name = "vis_user_id")
private Long visUserId;
// 微信绑定ID
@Column(name = "vis_user_weixin_id")
private Long visUserWeixinId;
// QQ绑定ID
@Column(name = "vis_user_qq_id")
private Long visUserQqId;
// 微博绑定ID
@Column(name = "vis_user_weibo_id")
private Long visUserWeiboId;
// 苹果绑定ID
@Column(name = "vis_user_apple_id")
private Long visUserAppleId;
// 状态:默认1-生效 2-失效
@Column(name = "status")
private Integer status;
// 创建时间
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
// 更新时间
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
public void copy(VisUser source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}
package com.topdraw.business.module.vis.hainan.app.repository;
import com.topdraw.business.module.vis.hainan.app.domain.VisUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author XiangHan
* @date 2022-07-14
*/
public interface VisUserRepository extends JpaRepository<VisUser, Long>, JpaSpecificationExecutor<VisUser> {
}
package com.topdraw.business.module.vis.hainan.app.service;
import com.topdraw.business.module.vis.hainan.app.domain.VisUser;
import com.topdraw.business.module.vis.hainan.app.service.dto.VisUserDTO;
/**
* @author XiangHan
* @date 2022-07-14
*/
public interface VisUserService {
/**
* 根据ID查询
* @param id ID
* @return UserDTO
*/
VisUserDTO findById(Long id);
void create(VisUser resources);
void update(VisUser resources);
void delete(Long id);
}
package com.topdraw.business.module.vis.hainan.app.service.dto;
import lombok.Data;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author XiangHan
* @date 2022-07-14
*/
@Data
public class VisUserDTO implements Serializable {
// ID
private Long id;
// 所有者ID
private Long personId;
// 平台
private String platform;
// 平台账号
private String platformAccount;
// 用户名
private String username;
// 密码
private String password;
// 积分
private Integer points;
// 昵称
private String nickname;
// 真实姓名
private String realname;
// 头像
private String image;
// 电子邮件
private String email;
// 手机号
private String cellphone;
// 0-女 1-男 2-其他
private Integer gender;
// 生日
private Integer birthday;
// 登录天数(总天数)
private Integer loginDays;
// 连续天数
private Integer continueDays;
// 活跃时间
private Timestamp activeTime;
// 标签
private String tags;
// 登录类型:1-运营商隐式登录 2-手机验证登录 3-微信登录 4-QQ登录 5-微博登录 6-苹果登录
private Integer loginType;
// 用户绑定ID
private Long visUserId;
// 微信绑定ID
private Long visUserWeixinId;
// QQ绑定ID
private Long visUserQqId;
// 微博绑定ID
private Long visUserWeiboId;
// 苹果绑定ID
private Long visUserAppleId;
// 状态:默认1-生效 2-失效
private Integer status;
// 创建时间
private Timestamp createTime;
// 更新时间
private Timestamp updateTime;
}
package com.topdraw.business.module.vis.hainan.app.service.impl;
import com.topdraw.business.module.vis.hainan.app.domain.VisUser;
import com.topdraw.business.module.vis.hainan.app.repository.VisUserRepository;
import com.topdraw.business.module.vis.hainan.app.service.VisUserService;
import com.topdraw.business.module.vis.hainan.app.service.dto.VisUserDTO;
import com.topdraw.business.module.vis.hainan.app.service.mapper.VisUserMapper;
import com.topdraw.utils.ValidationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
/**
* @author XiangHan
* @date 2022-07-14
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class VisUserServiceImpl implements VisUserService {
@Autowired
private VisUserRepository visUserRepository;
@Autowired
private VisUserMapper visUserMapper;
@Override
public VisUserDTO findById(Long id) {
VisUser visUser = visUserRepository.findById(id).orElseGet(VisUser::new);
ValidationUtil.isNull(visUser.getId(),"User","id",id);
return visUserMapper.toDto(visUser);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(VisUser resources) {
visUserRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(VisUser resources) {
VisUser User = visUserRepository.findById(resources.getId()).orElseGet(VisUser::new);
ValidationUtil.isNull( User.getId(),"User","id",resources.getId());
User.copy(resources);
visUserRepository.save(User);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
VisUser User = visUserRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", VisUser.class, id), 1));
visUserRepository.delete(User);
}
}
package com.topdraw.business.module.vis.hainan.app.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.module.vis.hainan.app.domain.VisUser;
import com.topdraw.business.module.vis.hainan.app.service.dto.VisUserDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author XiangHan
* @date 2022-07-14
*/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface VisUserMapper extends BaseMapper<VisUserDTO, VisUser> {
}
package com.topdraw.business.module.vis.hainan.apple.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author XiangHan
* @date 2022-07-14
*/
@Entity
@Data
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="vis_user_apple")
public class VisUserApple implements Serializable {
@Transient
private String username;
@Transient
private Integer type;
// ID
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 所有者ID
@Column(name = "person_id")
private Long personId;
// 用户ID
@Column(name = "vis_user_id")
private Long visUserId;
// 苹果用户ID
@Column(name = "user")
private String user;
@Column(name = "identity_token")
private String identityToken;
@Column(name = "real_user_status")
private String realUserStatus;
@Column(name = "authorized_scopes")
private String authorizedScopes;
@Column(name = "authorization_code")
private String authorizationCode;
// 状态 0-失效 1-有效
@Column(name = "status")
private Integer status;
// 全名
@Column(name = "full_name")
private String fullName;
// E-main
@Column(name = "email")
private String email;
// 昵称
@Column(name = "nickname")
private String nickname;
// 性别
@Column(name = "sex")
private Integer sex;
// 国家
@Column(name = "country")
private String country;
// 省份
@Column(name = "province")
private String province;
// 城市
@Column(name = "city")
private String city;
// 头像地址
@Column(name = "icon")
private String icon;
// 描述
@Column(name = "description")
private String description;
// 创建时间
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
// 更新时间
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
public void copy(VisUserApple source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}
package com.topdraw.business.module.vis.hainan.apple.repository;
import com.topdraw.business.module.vis.hainan.apple.domain.VisUserApple;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author XiangHan
* @date 2022-07-14
*/
public interface VisUserAppleRepository extends JpaRepository<VisUserApple, Long>, JpaSpecificationExecutor<VisUserApple> {
}
package com.topdraw.business.module.vis.hainan.apple.service;
import com.topdraw.business.module.vis.hainan.apple.domain.VisUserApple;
import com.topdraw.business.module.vis.hainan.apple.service.dto.VisUserAppleDTO;
/**
* @author XiangHan
* @date 2022-07-14
*/
public interface VisUserAppleService {
/**
* 根据ID查询
* @param id ID
* @return VisUserAppleDTO
*/
VisUserAppleDTO findById(Long id);
void create(VisUserApple resources);
void update(VisUserApple resources);
void delete(Long id);
}
package com.topdraw.business.module.vis.hainan.apple.service.dto;
import lombok.Data;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author XiangHan
* @date 2022-07-14
*/
@Data
public class VisUserAppleDTO implements Serializable {
// ID
private Long id;
// 所有者ID
private Long personId;
// 用户ID
private Long visUserId;
// 苹果用户ID
private String user;
private String identityToken;
private String realUserStatus;
private String authorizedScopes;
private String authorizationCode;
// 状态 0-失效 1-有效
private Integer status;
// 全名
private String fullName;
// E-main
private String email;
// 昵称
private String nickname;
// 性别
private Integer sex;
// 国家
private String country;
// 省份
private String province;
// 城市
private String city;
// 头像地址
private String icon;
// 描述
private String description;
// 创建时间
private Timestamp createTime;
// 更新时间
private Timestamp updateTime;
}
package com.topdraw.business.process.domian.weixin;
package com.topdraw.business.module.vis.hainan.apple.service.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 微信账户信息
* @author XiangHan
* @date 2021-01-18
* @date 2022-07-14
*/
@Data
public class BuyVipBean extends WeiXinUserBean {
private Integer vip;
@JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime vipExpireTime;
public class VisUserAppleQueryCriteria{
}
......
package com.topdraw.business.module.vis.hainan.apple.service.impl;
import com.topdraw.business.module.vis.hainan.apple.domain.VisUserApple;
import com.topdraw.business.module.vis.hainan.apple.repository.VisUserAppleRepository;
import com.topdraw.business.module.vis.hainan.apple.service.VisUserAppleService;
import com.topdraw.business.module.vis.hainan.apple.service.dto.VisUserAppleDTO;
import com.topdraw.business.module.vis.hainan.apple.service.mapper.VisUserAppleMapper;
import com.topdraw.utils.ValidationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
/**
* @author XiangHan
* @date 2022-07-14
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class VisUserAppleServiceImpl implements VisUserAppleService {
@Autowired
private VisUserAppleRepository visUserAppleRepository;
@Autowired
private VisUserAppleMapper visUserAppleMapper;
@Override
public VisUserAppleDTO findById(Long id) {
VisUserApple visUserApple = visUserAppleRepository.findById(id).orElseGet(VisUserApple::new);
ValidationUtil.isNull(visUserApple.getId(),"VisUserApple","id",id);
return visUserAppleMapper.toDto(visUserApple);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(VisUserApple resources) {
visUserAppleRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(VisUserApple resources) {
VisUserApple visUserApple = visUserAppleRepository.findById(resources.getId()).orElseGet(VisUserApple::new);
ValidationUtil.isNull( visUserApple.getId(),"VisUserApple","id",resources.getId());
visUserApple.copy(resources);
visUserAppleRepository.save(visUserApple);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
VisUserApple visUserApple = visUserAppleRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", VisUserApple.class, id), 1));
visUserAppleRepository.delete(visUserApple);
}
}
package com.topdraw.business.module.vis.hainan.apple.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.module.vis.hainan.apple.domain.VisUserApple;
import com.topdraw.business.module.vis.hainan.apple.service.dto.VisUserAppleDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author XiangHan
* @date 2022-07-14
*/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface VisUserAppleMapper extends BaseMapper<VisUserAppleDTO, VisUserApple> {
}
package com.topdraw.business.module.vis.hainan.qq.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author XiangHan
* @date 2022-07-14
*/
@Entity
@Data
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="vis_user_qq")
public class VisUserQq implements Serializable {
@Transient
private String username;
@Transient
private Integer type;
// ID
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 所有者ID
@Column(name = "person_id")
private Long personId;
// 用户ID
@Column(name = "vis_user_id")
private Long visUserId;
// QQunionid,针对开发者
@Column(name = "unionid")
private String unionid;
// QQappid
@Column(name = "app_id")
private String appId;
// QQopenid
@Column(name = "openid")
private String openid;
// QQuserid
@Column(name = "user_id")
private String userId;
// 状态 0-失效 1-有效
@Column(name = "status")
private Integer status;
// 昵称
@Column(name = "nickname")
private String nickname;
// 性别
@Column(name = "sex")
private Integer sex;
// 国家
@Column(name = "country")
private String country;
// 省份
@Column(name = "province")
private String province;
// 城市
@Column(name = "city")
private String city;
// 头像地址
@Column(name = "icon")
private String icon;
@Column(name = "pay_token")
private String payToken;
@Column(name = "secretType")
private String secretType;
@Column(name = "secret")
private String secret;
@Column(name = "pfkey")
private String pfkey;
@Column(name = "pf")
private String pf;
// access_token
@Column(name = "access_token")
private String accessToken;
// expires_in
@Column(name = "expires_in")
private Integer expiresIn;
// expires_time
@Column(name = "expires_time")
private Timestamp expiresTime;
// 描述
@Column(name = "description")
private String description;
// 创建时间
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
// 更新时间
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
public void copy(VisUserQq source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}
package com.topdraw.business.module.vis.hainan.qq.repository;
import com.topdraw.business.module.vis.hainan.qq.domain.VisUserQq;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author XiangHan
* @date 2022-07-14
*/
public interface VisUserQqRepository extends JpaRepository<VisUserQq, Long>, JpaSpecificationExecutor<VisUserQq> {
}
package com.topdraw.business.module.vis.hainan.qq.service;
import com.topdraw.business.module.vis.hainan.qq.domain.VisUserQq;
import com.topdraw.business.module.vis.hainan.qq.service.dto.VisUserQqDTO;
/**
* @author XiangHan
* @date 2022-07-14
*/
public interface VisUserQqService {
/**
* 根据ID查询
* @param id ID
* @return VisUserQqDTO
*/
VisUserQqDTO findById(Long id);
void create(VisUserQq resources);
void update(VisUserQq resources);
void delete(Long id);
VisUserQqDTO findByOpenid(String account);
}
package com.topdraw.business.module.vis.hainan.qq.service.dto;
import lombok.Data;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author XiangHan
* @date 2022-07-14
*/
@Data
public class VisUserQqDTO implements Serializable {
// ID
private Long id;
// 所有者ID
private Long personId;
// 用户ID
private Long visUserId;
// QQunionid,针对开发者
private String unionid;
// QQappid
private String appId;
// QQopenid
private String openid;
// QQuserid
private String userId;
// 状态 0-失效 1-有效
private Integer status;
// 昵称
private String nickname;
// 性别
private Integer sex;
// 国家
private String country;
// 省份
private String province;
// 城市
private String city;
// 头像地址
private String icon;
private String payToken;
private String secretType;
private String secret;
private String pfkey;
private String pf;
// access_token
private String accessToken;
// expires_in
private Integer expiresIn;
// expires_time
private Timestamp expiresTime;
// 描述
private String description;
// 创建时间
private Timestamp createTime;
// 更新时间
private Timestamp updateTime;
}
package com.topdraw.business.module.vis.hainan.qq.service.impl;
import com.topdraw.business.module.vis.hainan.qq.domain.VisUserQq;
import com.topdraw.business.module.vis.hainan.qq.repository.VisUserQqRepository;
import com.topdraw.business.module.vis.hainan.qq.service.VisUserQqService;
import com.topdraw.business.module.vis.hainan.qq.service.dto.VisUserQqDTO;
import com.topdraw.business.module.vis.hainan.qq.service.mapper.VisUserQqMapper;
import com.topdraw.utils.ValidationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
/**
* @author XiangHan
* @date 2022-07-14
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class VisUserQqServiceImpl implements VisUserQqService {
@Autowired
private VisUserQqRepository visUserQqRepository;
@Autowired
private VisUserQqMapper visUserQqMapper;
@Override
public VisUserQqDTO findById(Long id) {
VisUserQq visUserQq = visUserQqRepository.findById(id).orElseGet(VisUserQq::new);
ValidationUtil.isNull(visUserQq.getId(),"VisUserQq","id",id);
return visUserQqMapper.toDto(visUserQq);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(VisUserQq resources) {
visUserQqRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(VisUserQq resources) {
VisUserQq visUserQq = visUserQqRepository.findById(resources.getId()).orElseGet(VisUserQq::new);
ValidationUtil.isNull( visUserQq.getId(),"VisUserQq","id",resources.getId());
visUserQq.copy(resources);
visUserQqRepository.save(visUserQq);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
VisUserQq visUserQq = visUserQqRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", VisUserQq.class, id), 1));
visUserQqRepository.delete(visUserQq);
}
@Override
public VisUserQqDTO findByOpenid(String account) {
return null;
}
}
package com.topdraw.business.module.vis.hainan.qq.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.module.vis.hainan.qq.domain.VisUserQq;
import com.topdraw.business.module.vis.hainan.qq.service.dto.VisUserQqDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author XiangHan
* @date 2022-07-14
*/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface VisUserQqMapper extends BaseMapper<VisUserQqDTO, VisUserQq> {
}
package com.topdraw.business.module.vis.hainan.weibo.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author XiangHan
* @date 2022-07-14
*/
@Entity
@Data
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="vis_user_weibo")
public class VisUserWeibo implements Serializable {
@Transient
private String username;
@Transient
private Integer type;
// ID
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 所有者ID
@Column(name = "person_id")
private Long personId;
// 用户ID
@Column(name = "vis_user_id")
private Long visUserId;
// 微博appid
@Column(name = "app_id")
private String appId;
// 微博用户ID
@Column(name = "user_id")
private String userId;
// 状态 0-失效 1-有效
@Column(name = "status")
private Integer status;
// 昵称
@Column(name = "nickname")
private String nickname;
// 性别
@Column(name = "sex")
private Integer sex;
// 国家
@Column(name = "country")
private String country;
// 省份
@Column(name = "province")
private String province;
// 城市
@Column(name = "city")
private String city;
// 头像地址
@Column(name = "icon")
private String icon;
// secretType
@Column(name = "secretType")
private String secretType;
// secret
@Column(name = "secret")
private String secret;
// snsregat
@Column(name = "snsregat")
private String snsregat;
// snsUserUrl
@Column(name = "snsUserUrl")
private String snsUserUrl;
// shareCount
@Column(name = "shareCount")
private String shareCount;
// followerCount
@Column(name = "followerCount")
private String followerCount;
// refresh_token
@Column(name = "refresh_token")
private String refreshToken;
// access_token
@Column(name = "access_token")
private String accessToken;
// expires_in
@Column(name = "expires_in")
private Long expiresIn;
// expires_time
@Column(name = "expires_time")
private Timestamp expiresTime;
// 描述
@Column(name = "description")
private String description;
// 创建时间
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
// 更新时间
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
public void copy(VisUserWeibo source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}
package com.topdraw.business.module.vis.hainan.weibo.repository;
import com.topdraw.business.module.vis.hainan.weibo.domain.VisUserWeibo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author XiangHan
* @date 2022-07-14
*/
public interface VisUserWeiboRepository extends JpaRepository<VisUserWeibo, Long>, JpaSpecificationExecutor<VisUserWeibo> {
}
package com.topdraw.business.module.vis.hainan.weibo.service;
import com.topdraw.business.module.vis.hainan.weibo.domain.VisUserWeibo;
import com.topdraw.business.module.vis.hainan.weibo.service.dto.VisUserWeiboDTO;
/**
* @author XiangHan
* @date 2022-07-14
*/
public interface VisUserWeiboService {
/**
* 根据ID查询
* @param id ID
* @return VisUserWeiboDTO
*/
VisUserWeiboDTO findById(Long id);
void create(VisUserWeibo resources);
void update(VisUserWeibo resources);
void delete(Long id);
VisUserWeiboDTO findByUserid(String account);
}
package com.topdraw.business.module.vis.hainan.weibo.service.dto;
import lombok.Data;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author XiangHan
* @date 2022-07-14
*/
@Data
public class VisUserWeiboDTO implements Serializable {
// ID
private Long id;
// 所有者ID
private Long personId;
// 用户ID
private Long visUserId;
// 微博appid
private String appId;
// 微博用户ID
private String userId;
// 状态 0-失效 1-有效
private Integer status;
// 昵称
private String nickname;
// 性别
private Integer sex;
// 国家
private String country;
// 省份
private String province;
// 城市
private String city;
// 头像地址
private String icon;
// secretType
private String secretType;
// secret
private String secret;
// snsregat
private String snsregat;
// snsUserUrl
private String snsUserUrl;
// shareCount
private String shareCount;
// followerCount
private String followerCount;
// refresh_token
private String refreshToken;
// access_token
private String accessToken;
// expires_in
private Long expiresIn;
// expires_time
private Timestamp expiresTime;
// 描述
private String description;
// 创建时间
private Timestamp createTime;
// 更新时间
private Timestamp updateTime;
}
package com.topdraw.business.module.vis.hainan.weibo.service.impl;
import com.topdraw.business.module.vis.hainan.weibo.domain.VisUserWeibo;
import com.topdraw.business.module.vis.hainan.weibo.repository.VisUserWeiboRepository;
import com.topdraw.business.module.vis.hainan.weibo.service.VisUserWeiboService;
import com.topdraw.business.module.vis.hainan.weibo.service.dto.VisUserWeiboDTO;
import com.topdraw.business.module.vis.hainan.weibo.service.mapper.VisUserWeiboMapper;
import com.topdraw.utils.ValidationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
/**
* @author XiangHan
* @date 2022-07-14
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class VisUserWeiboServiceImpl implements VisUserWeiboService {
@Autowired
private VisUserWeiboRepository visUserWeiboRepository;
@Autowired
private VisUserWeiboMapper visUserWeiboMapper;
@Override
public VisUserWeiboDTO findById(Long id) {
VisUserWeibo visUserWeibo = visUserWeiboRepository.findById(id).orElseGet(VisUserWeibo::new);
ValidationUtil.isNull(visUserWeibo.getId(),"VisUserWeibo","id",id);
return visUserWeiboMapper.toDto(visUserWeibo);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(VisUserWeibo resources) {
visUserWeiboRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(VisUserWeibo resources) {
VisUserWeibo visUserWeibo = visUserWeiboRepository.findById(resources.getId()).orElseGet(VisUserWeibo::new);
ValidationUtil.isNull( visUserWeibo.getId(),"VisUserWeibo","id",resources.getId());
visUserWeibo.copy(resources);
visUserWeiboRepository.save(visUserWeibo);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
VisUserWeibo visUserWeibo = visUserWeiboRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", VisUserWeibo.class, id), 1));
visUserWeiboRepository.delete(visUserWeibo);
}
@Override
public VisUserWeiboDTO findByUserid(String account) {
return null;
}
}
package com.topdraw.business.module.vis.hainan.weibo.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.module.vis.hainan.weibo.domain.VisUserWeibo;
import com.topdraw.business.module.vis.hainan.weibo.service.dto.VisUserWeiboDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author XiangHan
* @date 2022-07-14
*/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface VisUserWeiboMapper extends BaseMapper<VisUserWeiboDTO, VisUserWeibo> {
}
package com.topdraw.business.module.vis.hainan.weixin.domain;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author XiangHan
* @date 2022-07-14
*/
@Entity
@Data
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="vis_user_weixin")
public class VisUserWeixin implements Serializable {
@Transient
private String username;
@Transient
private Integer type;
// ID
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 所有者ID
@Column(name = "person_id")
private Long personId;
// 用户ID
@Column(name = "vis_user_id")
private Long visUserId;
// 微信unionid,针对开发者
@Column(name = "unionid")
private String unionid;
// 微信appid
@Column(name = "appid")
private String appid;
// 微信appid
@Column(name = "app_id")
private String appId;
// 微信openid,针对微信app
@Column(name = "openid")
private String openid;
// 状态 0-失效 1-有效
@Column(name = "status")
private Integer status;
// 昵称
@Column(name = "nickname")
private String nickname;
// 性别
@Column(name = "sex")
private Integer sex;
// 国家
@Column(name = "country")
private String country;
// 省份
@Column(name = "province")
private String province;
// 城市
@Column(name = "city")
private String city;
// 头像地址
@Column(name = "headimgurl")
private String headimgurl;
// 特权信息
@Column(name = "privilege")
private String privilege;
// refresh_token
@Column(name = "refresh_token")
private String refreshToken;
// access_token
@Column(name = "access_token")
private String accessToken;
// expires_in
@Column(name = "expires_in")
private Integer expiresIn;
// expires_time
@Column(name = "expires_time")
private Timestamp expiresTime;
// 描述
@Column(name = "description")
private String description;
// 创建时间
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
// 更新时间
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
public void copy(VisUserWeixin source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}
package com.topdraw.business.module.vis.hainan.weixin.repository;
import com.topdraw.business.module.vis.hainan.weixin.domain.VisUserWeixin;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.Optional;
/**
* @author XiangHan
* @date 2022-07-14
*/
public interface VisUserWeixinRepository extends JpaRepository<VisUserWeixin, Long>, JpaSpecificationExecutor<VisUserWeixin> {
Optional<VisUserWeixin> findByOpenid(String account);
}
package com.topdraw.business.module.vis.hainan.weixin.service;
import com.topdraw.business.module.vis.hainan.weixin.domain.VisUserWeixin;
import com.topdraw.business.module.vis.hainan.weixin.service.dto.VisUserWeixinDTO;
/**
* @author XiangHan
* @date 2022-07-14
*/
public interface VisUserWeixinService {
/**
* 根据ID查询
* @param id ID
* @return VisUserWeixinDTO
*/
VisUserWeixinDTO findById(Long id);
void create(VisUserWeixin resources);
void update(VisUserWeixin resources);
void delete(Long id);
VisUserWeixinDTO findByOpenid(String account);
}
package com.topdraw.business.module.vis.hainan.weixin.service.dto;
import lombok.Data;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* @author XiangHan
* @date 2022-07-14
*/
@Data
public class VisUserWeixinDTO implements Serializable {
// ID
private Long id;
// 所有者ID
private Long personId;
// 用户ID
private Long visUserId;
// 微信unionid,针对开发者
private String unionid;
// 微信appid
private String appid;
// 微信appid
private String appId;
// 微信openid,针对微信app
private String openid;
// 状态 0-失效 1-有效
private Integer status;
// 昵称
private String nickname;
// 性别
private Integer sex;
// 国家
private String country;
// 省份
private String province;
// 城市
private String city;
// 头像地址
private String headimgurl;
// 特权信息
private String privilege;
// refresh_token
private String refreshToken;
// access_token
private String accessToken;
// expires_in
private Integer expiresIn;
// expires_time
private Timestamp expiresTime;
// 描述
private String description;
// 创建时间
private Timestamp createTime;
// 更新时间
private Timestamp updateTime;
}
package com.topdraw.business.module.vis.hainan.weixin.service.impl;
import com.topdraw.business.module.vis.hainan.weixin.domain.VisUserWeixin;
import com.topdraw.business.module.vis.hainan.weixin.repository.VisUserWeixinRepository;
import com.topdraw.business.module.vis.hainan.weixin.service.VisUserWeixinService;
import com.topdraw.business.module.vis.hainan.weixin.service.dto.VisUserWeixinDTO;
import com.topdraw.business.module.vis.hainan.weixin.service.mapper.VisUserWeixinMapper;
import com.topdraw.utils.ValidationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
/**
* @author XiangHan
* @date 2022-07-14
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class VisUserWeixinServiceImpl implements VisUserWeixinService {
@Autowired
private VisUserWeixinRepository visUserWeixinRepository;
@Autowired
private VisUserWeixinMapper visUserWeixinMapper;
@Override
public VisUserWeixinDTO findById(Long id) {
VisUserWeixin visUserWeixin = visUserWeixinRepository.findById(id).orElseGet(VisUserWeixin::new);
ValidationUtil.isNull(visUserWeixin.getId(),"VisUserWeixin","id",id);
return visUserWeixinMapper.toDto(visUserWeixin);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(VisUserWeixin resources) {
visUserWeixinRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(VisUserWeixin resources) {
VisUserWeixin visUserWeixin = visUserWeixinRepository.findById(resources.getId()).orElseGet(VisUserWeixin::new);
ValidationUtil.isNull( visUserWeixin.getId(),"VisUserWeixin","id",resources.getId());
visUserWeixin.copy(resources);
visUserWeixinRepository.save(visUserWeixin);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
VisUserWeixin visUserWeixin = visUserWeixinRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", VisUserWeixin.class, id), 1));
visUserWeixinRepository.delete(visUserWeixin);
}
@Override
public VisUserWeixinDTO findByOpenid(String account) {
VisUserWeixin visUserWeixin = visUserWeixinRepository.findByOpenid(account).orElseGet(VisUserWeixin::new);
return visUserWeixinMapper.toDto(visUserWeixin);
}
}
package com.topdraw.business.module.vis.hainan.weixin.service.mapper;
import com.topdraw.base.BaseMapper;
import com.topdraw.business.module.vis.hainan.weixin.domain.VisUserWeixin;
import com.topdraw.business.module.vis.hainan.weixin.service.dto.VisUserWeixinDTO;
import org.mapstruct.Mapper;
import org.mapstruct.ReportingPolicy;
/**
* @author XiangHan
* @date 2022-07-14
*/
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface VisUserWeixinMapper extends BaseMapper<VisUserWeixinDTO, VisUserWeixin> {
}
package com.topdraw.business.process.domian;
public enum RightType {
/**积分*/
POINTS,
/**成长值*/
EXP,
/**优惠券券*/
COUPON,
/**权益统称*/
RIGHTS
}
package com.topdraw.business.process.domian.result;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CustomPointsResult {
private boolean result;
private Long point;
}
package com.topdraw.business.process.domian.result;
public interface TaskTemplateType {
int TYPE_1 = 1;
int TYPE_2 = 2;
int TYPE_3 = 3;
int TYPE_4 = 4;
}
package com.topdraw.business.process.domian.weixin;
import lombok.Data;
@Data
public class BindBean extends WeiXinUserBean {
private Long platformUserId;
private String platformAccount;
}
package com.topdraw.business.process.domian.weixin;
import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.topdraw.exception.BadRequestException;
import com.topdraw.utils.StringUtils;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Date;
import java.util.UUID;
@Data
@Component
public class DefaultWeiXinBeanDefinition implements WeiXinBeanDefinition {
//
private String appid;
private String openId;
private String code;
private String token;
private String secret;
private String unionId;
private String nickname;
private String headImgUrl;
private JSONObject userInfo;
private String phoneNumber;
@Value("${file.upload:upload}")
private String filePath;
public DefaultWeiXinBeanDefinition() {
}
public DefaultWeiXinBeanDefinition(String appId, String code, String unionId, String openId, JSONObject userInfoWxJo, String phone) {
this.userInfo = userInfoWxJo;
if (userInfo != null) {
if (StringUtils.isNotBlank(userInfoWxJo.getString("unionId"))) {
unionId = userInfoWxJo.getString("unionId");
}
if (StringUtils.isNotBlank(userInfoWxJo.getString("openId"))) {
openId = userInfoWxJo.getString("openId");
}
headImgUrl = userInfoWxJo.getString("avatarUrl");
if (StringUtils.isNotBlank(userInfoWxJo.getString("nickName"))) {
nickname = Base64.getEncoder().encodeToString(userInfoWxJo.getString("nickName").getBytes(StandardCharsets.UTF_8));
}
String phoneNumber = userInfoWxJo.getString("phoneNumber");
if (StringUtils.isBlank(phoneNumber)) {
throw new BadRequestException("phoneNumber is null...");
}
this.phoneNumber = phoneNumber;
if (StringUtils.isNotBlank(headImgUrl)) {
new Thread(() -> {
String s = UUID.randomUUID().toString();
File file = new File(System.getProperty("user.dir") + "/" + filePath + "/icon/" + DateUtil.format(new Date(), "yyyy-MM-dd"));
if (!file.exists()) {
file.mkdirs();
}
HttpUtil.downloadFile(headImgUrl, new File(System.getProperty("user.dir") + "/" + filePath + "/icon/" + DateUtil.format(new Date(), "yyyy-MM-dd") + "/" + s + ".jpg"));
headImgUrl = filePath + "/icon/" + DateUtil.format(new Date(), "yyyy-MM-dd") + "/" + s + ".jpg";
}).start();
}
}
this.unionId = unionId;
this.phoneNumber = phone;
this.openId = openId;
this.appid = appId;
this.code = code;
}
@Override
public String getAppId() {
return this.appid;
}
@Override
public String getCode() {
return this.code;
}
@Override
public String getToken() {
return this.token;
}
@Override
public String getSecret() {
return this.secret;
}
@Override
public String getOpenId() {
return this.openId;
}
@Override
public String getUnionId() {
return this.unionId;
}
@Override
public String getNickname() {
return this.nickname;
}
@Override
public String getHeadImgUrl() {
return this.headImgUrl;
}
@Override
public JSONObject getUserInfo() {
return this.userInfo;
}
}
package com.topdraw.business.process.domian.weixin;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
@Data
public class SubscribeBean extends WeiXinUserBean {
private JSONObject userInfoJson;
private JSONObject iptvUserInfo;
private String msgType;
private String event;
/** */
private String openId;
/** */
private String appId;
/** */
private String eventKey;
private String unionid;
private String nickname;
private String headimgurl;
}
package com.topdraw.business.process.domian.weixin;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SubscribeBeanEvent {
@NotNull(message = "【content】 not be null !!!")
private String content;
}
package com.topdraw.business.process.domian.weixin;
import com.alibaba.fastjson.JSONObject;
public interface WeiXinBeanDefinition {
String getAppId();
String getCode();
String getToken();
String getSecret();
String getOpenId();
String getUnionId();
String getNickname();
String getHeadImgUrl();
JSONObject getUserInfo();
}
package com.topdraw.business.process.domian.weixin;
import lombok.Data;
/**
* 微信账户信息
* @author XiangHan
* @date 2021-01-18
*/
@Data
public class WeiXinUserBean {
private Long id;
private String unionid;
/** */
private String openid;
/** */
private String appid;
/** 加密后的appId,参数 */
private String wxAppid;
/** 加密后的code,参数 */
private String wxCode;
/** */
private String userInfo;
/** 会员id */
private Long memberId;
/** 加密信息 */
private String encryptedData;
/** 解析用户电话号码时使用,参数 */
private String iv;
/** 资源id */
private String sourceId;
/** 资源类型 */
private String sourceType;
/** 资源描述,用来表示从哪个地方链接进来的 */
private String sourceDesc;
/** 资源实例 */
private String sourceEntity;
/** 推荐者id */
private Long sourceUser;
private String nikename;
private String headimgurl;
}
package com.topdraw.business.process.service.builder;
import com.topdraw.business.process.domian.TempCoupon;
public class TempCouponBuilder {
public TempCoupon build(){
TempCoupon tempCoupon = new TempCoupon();
return tempCoupon;
}
}
......@@ -12,6 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import java.util.Objects;
/**
*
*/
......@@ -21,13 +23,7 @@ public class ExpOperationServiceImpl implements ExpOperationService {
@Autowired
private ExpDetailService expDetailService;
@Autowired
private MemberOperationService memberOperationService;
@Autowired
private MemberLevelService memberLevelService;
@Autowired
private MemberService memberService;
@Autowired
ThreadPoolTaskExecutor threadPoolTaskExecutor;
public void asyncMemberExpAndLevel(Member member) {
String code = member.getCode();
......@@ -40,8 +36,10 @@ public class ExpOperationServiceImpl implements ExpOperationService {
public void asyncExpDetail(ExpDetail expDetail) {
String code = expDetail.getMemberCode();
MemberDTO memberDTO = this.memberService.findByCode(code);
if (Objects.nonNull(memberDTO.getId())) {
expDetail.setMemberId(memberDTO.getId());
this.expDetailService.create(expDetail);
}
}
}
......
......@@ -7,29 +7,18 @@ import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.points.available.domain.PointsAvailable;
import com.topdraw.business.module.points.available.service.PointsAvailableService;
import com.topdraw.business.module.points.available.service.dto.PointsAvailableDTO;
import com.topdraw.business.module.points.detail.detailhistory.service.PointsDetailHistoryService;
import com.topdraw.business.module.points.detail.domain.PointsDetail;
import com.topdraw.business.module.points.detail.service.PointsDetailService;
import com.topdraw.business.module.points.service.PointsService;
import com.topdraw.business.process.domian.TempPoints;
import com.topdraw.business.process.service.PointsOperationService;
import com.topdraw.business.process.service.member.MemberOperationService;
import com.topdraw.util.IdWorker;
import com.topdraw.util.TimestampUtil;
import com.topdraw.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
/**
*
......@@ -49,25 +38,36 @@ public class PointsOperationServiceImpl implements PointsOperationService {
ThreadPoolTaskExecutor threadPoolTaskExecutor;
public void asyncMemberPoint(Member member) {
log.info("修改会员积分,参数 =>> {}", member);
String code = member.getCode();
if (StringUtils.isBlank(code)) {
log.error("修改会员积分失败,参数错误,会员code为空");
return;
}
MemberDTO memberDTO = this.memberService.findByCode(code);
if (Objects.nonNull(memberDTO.getId())) {
member.setId(memberDTO.getId());
this.memberService.doUpdateMemberPoints(member);
}
}
public void asyncPointsAvailable(PointsAvailable pointsAvailable) {
String memberCode = pointsAvailable.getMemberCode();
MemberDTO memberDTO = this.memberService.findByCode(memberCode);
if (Objects.nonNull(memberDTO.getId())) {
pointsAvailable.setMemberId(memberDTO.getId());
this.pointsAvailableService.create4Custom(pointsAvailable);
}
}
public void asyncPointsDetail(PointsDetail pointsDetail) {
String memberCode = pointsDetail.getMemberCode();
MemberDTO memberDTO = this.memberService.findByCode(memberCode);
if (Objects.nonNull(memberDTO.getId())) {
pointsDetail.setMemberId(memberDTO.getId());
this.pointsDetailService.create4Custom(pointsDetail);
}
}
public void asyncDeletePointsAvailable(PointsAvailable pointsAvailable) {
String code = pointsAvailable.getCode();
......
package com.topdraw.business.process.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.topdraw.business.module.task.attribute.domain.TaskAttr;
import com.topdraw.business.module.task.attribute.service.TaskAttrService;
import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO;
......@@ -50,10 +51,10 @@ public class TaskOperationServiceImpl implements TaskOperationService {
TaskDTO taskDTO = this.findByCode(code);
if (Objects.isNull(taskDTO.getId())) {
TaskDTO taskDTO_ = this.taskService.create(task);
if (Objects.nonNull(taskDTO_.getId())) {
/*if (Objects.nonNull(taskDTO_.getId())) {
task.setId(taskDTO_.getId());
this.createTaskAttr(task);
}
}*/
}
}
......@@ -72,17 +73,23 @@ public class TaskOperationServiceImpl implements TaskOperationService {
String code = task.getCode();
TaskDTO taskDTO = this.findByCode(code);
if (Objects.nonNull(taskDTO.getId())) {
Long id = taskDTO.getId();
task.setId(id);
Task task1 = new Task();
BeanUtils.copyProperties(taskDTO, task1);
Long id = taskDTO.getId();
task1.setId(id);
String taskTemplateCode = task.getTaskTemplateCode();
if (StringUtils.isNotBlank(taskTemplateCode)) {
TaskTemplateDTO taskTemplateDTO = this.taskTemplateOperationService.findByCode(taskTemplateCode);
Long templateId = taskTemplateDTO.getId();
task.setTaskTemplateId(templateId);
TaskDTO update = this.update(task);
if (Objects.nonNull(update)) {
this.updateTaskAttr(task);
task1.setTaskTemplateId(templateId);
}
task1.copy(task);
TaskDTO update = this.update(task1);
/*if (Objects.nonNull(update)) {
this.updateTaskAttr(task);
}*/
}
}
......@@ -129,8 +136,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
}
private TaskDTO findByCode(String code){
TaskDTO taskDTO = this.taskService.findByCode(code);
return taskDTO;
return this.taskService.findByCode(code);
}
}
......
......@@ -2,9 +2,27 @@ package com.topdraw.business.process.service.impl;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.domain.MemberBuilder;
import com.topdraw.business.module.member.domain.MemberTypeConstant;
import com.topdraw.business.module.member.profile.domain.MemberProfile;
import com.topdraw.business.module.member.profile.service.MemberProfileService;
import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.user.app.domain.UserApp;
import com.topdraw.business.module.user.app.domain.UserAppBind;
import com.topdraw.business.module.user.app.domain.UserAppBindBuilder;
import com.topdraw.business.module.user.app.domain.UserAppBuilder;
import com.topdraw.business.module.user.app.service.UserAppBindService;
import com.topdraw.business.module.user.app.service.UserAppService;
import com.topdraw.business.module.user.app.service.dto.AppRegisterDTO;
import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO;
import com.topdraw.business.module.user.app.service.dto.UserAppDTO;
import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO;
import com.topdraw.business.module.user.iptv.domain.UserTv;
import com.topdraw.business.module.user.iptv.growreport.domain.GrowthReport;
import com.topdraw.business.module.user.iptv.growreport.service.GrowthReportService;
import com.topdraw.business.module.user.iptv.growreport.service.dto.GrowthReportDTO;
import com.topdraw.business.module.user.iptv.service.UserTvService;
import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.module.user.weixin.domain.UserWeixin;
......@@ -15,8 +33,10 @@ import com.topdraw.business.process.service.dto.MemberAndUserTvDTO;
import com.topdraw.business.process.service.dto.MemberAndWeixinUserDTO;
import com.topdraw.exception.EntityNotFoundException;
import com.topdraw.exception.GlobeExceptionMsg;
import com.topdraw.util.TimestampUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -37,34 +57,160 @@ public class UserOperationServiceImpl implements UserOperationService {
private UserTvService userTvService;
@Autowired
private UserWeixinService userWeixinService;
@Autowired
private MemberProfileService memberProfileService;
@Autowired
private GrowthReportService growthReportService;
@Autowired
private UserAppService userAppService;
@Autowired
private UserAppBindService userAppBindService;
public void asyncUpdateAppLastActiveTimeAndNicknameAndHeadImg(UserAppDTO resources) {
UserAppDTO userAppDTO = this.userAppService.findByUsername(resources.getUsername());
if (Objects.isNull(userAppDTO.getId())) {
UserApp userApp = new UserApp();
userApp.setId(userAppDTO.getId());
userApp.setUsername(userAppDTO.getUsername());
userApp.setNickname(resources.getNickname());
userApp.setHeadimgurl(resources.getHeadimgurl());
this.userAppService.updateAppLastActiveTimeAndNicknameAndHeadImg(userApp);
}
}
public void asyncCancelUserAppBind(UserAppBindDTO resources) {
}
public void asyncUpdatePasswordByUsername(UserAppDTO resources) {
UserAppDTO userAppDTO = this.userAppService.findByUsername(resources.getUsername());
if (Objects.isNull(userAppDTO.getId())) {
UserApp userApp = new UserApp();
userApp.setId(userAppDTO.getId());
userApp.setPassword(resources.getPassword());
this.userAppService.updatePasswordById(userApp);
}
}
public void asyncUpdateAppInfo(UserAppDTO resources) {
UserAppDTO userAppDTO = this.userAppService.findByUsername(resources.getUsername());
if (Objects.nonNull(userAppDTO.getId())) {
UserApp userApp = new UserApp();
BeanUtils.copyProperties(resources, userApp);
userApp.setId(userAppDTO.getId());
this.userAppService.updateAppInfo(userApp);
}
}
public void asyncAppCancellation(UserAppDTO resources) {
UserAppDTO userAppDTO = this.userAppService.findByUsername(resources.getUsername());
if (Objects.nonNull(userAppDTO.getId())) {
this.userAppService.appCancellation(userAppDTO.getId());
}
}
public void asyncAppRegister(AppRegisterDTO appRegisterDTO) {
UserAppDTO userAppDTOResources = appRegisterDTO.getUserAppDTO();
MemberDTO memberDTOResources = appRegisterDTO.getMemberDTO();
UserAppDTO userAppDTO = this.userAppService.findByUsername(userAppDTOResources.getUsername());
if (Objects.isNull(userAppDTO.getId())) {
// 先创建会员
// Member member = MemberBuilder.build(MemberTypeConstant.app, userAppDTOResources.getHeadimgurl(), userAppDTOResources.getNickname(), 0);
Member member = new Member();
BeanUtils.copyProperties(memberDTOResources, member);
member.setId(null);
MemberDTO _memberDTO = this.memberService.create(member);
if (Objects.nonNull(_memberDTO.getId())) {
UserApp userApp = new UserApp();
BeanUtils.copyProperties(userAppDTOResources, userApp);
userApp.setId(null);
// 保存app账号
UserAppDTO _userAppDTO = this.userAppService.create(UserAppBuilder.build(_memberDTO.getId(), userApp));
if (Objects.nonNull(_userAppDTO.getId()) && StringUtils.isNotBlank(userAppDTO.getAccount())) {
UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccount(userAppDTO.getAccount());
if (Objects.isNull(userAppBindDTO.getId())) {
// 保存绑定关系
UserAppBind userAppBind = UserAppBindBuilder.build(_userAppDTO.getId(), userAppDTO.getAccount(), userAppDTO.getAccountType());
this.userAppBindService.create(userAppBind);
}
}
}
}
}
public void asyncsaveGrowthReport(GrowthReport growthReport) {
String platformAccount = growthReport.getPlatformAccount();
UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
if (Objects.isNull(userTvDTO.getId())){
log.error("保存成长报告失败,大屏信息不存在[asyncsaveGrowthReport#]");
return;
}
String weekFirstDay = com.topdraw.util.DateUtil.getWeekFirstDay();
String weekLastDay = com.topdraw.util.DateUtil.getWeekLastDay();
GrowthReportDTO growthReportDTO = this.growthReportService.findByPlatformAccountAndStartDateAndEndDate(platformAccount, weekFirstDay, weekLastDay);
if (Objects.isNull(growthReportDTO.getId())) {
Long id = userTvDTO.getId();
Long memberId = userTvDTO.getMemberId();
growthReport.setUserId(id);
growthReport.setMemberId(memberId);
growthReport.setStartDate(weekFirstDay);
growthReport.setEndDate(weekLastDay);
this.growthReportService.create(growthReport);
} else {
this.growthReportService.updateGrowthReportData(growthReportDTO.getId(), growthReport.getData());
}
}
@Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class)
public void asyncMemberAndUserWeixin4Iptv(MemberAndWeixinUserDTO memberAndWeixinUserDTO) {
log.info("保存微信账号并同时创建会员信息 ==>> {}", memberAndWeixinUserDTO);
UserWeixinDTO userWeixinDTO = memberAndWeixinUserDTO.getUserWeixinDTO();
String openid = userWeixinDTO.getOpenid();
String unionid = userWeixinDTO.getUnionid();
String appid = userWeixinDTO.getAppid();
UserWeixinDTO _userWeixinDTO = this.userWeixinService.findFirstByAppIdAndOpenId(appid, openid);
log.info("通过appid ==>> {} 和openId ==>> {},检查微信账号是否存在 ==>> {}",appid, openid, _userWeixinDTO);
// 无账号
if (Objects.isNull(_userWeixinDTO.getId())) {
// 是否存在会员
// 其他账号
UserWeixinDTO userWeixinDTO1 = this.userWeixinService.findFirstByUnionId(unionid);
log.info("账号不存在通过unionid ==>> {},检查其他微信账号是否存在 ==>> {}",unionid, userWeixinDTO1);
if (Objects.nonNull(userWeixinDTO1.getId())) {
Long memberId = userWeixinDTO1.getMemberId();
if (Objects.nonNull(memberId)) {
userWeixinDTO.setMemberId(memberId);
MemberDTO memberDTO = this.memberService.findById(memberId);
log.info("其他账号的会员信息 ==>> {},memberId ==>> {}",memberDTO, memberId);
if (Objects.nonNull(memberDTO.getId())) {
MemberDTO memberDTO1 = memberAndWeixinUserDTO.getMemberDTO();
this.updateMember(memberDTO, memberDTO1);
}
} else {
MemberDTO memberDTO1 = memberAndWeixinUserDTO.getMemberDTO();
log.info("其他账号的无会员信息,创建会员 memberDTO1 ==>> {}",memberDTO1);
String memberCode = memberDTO1.getCode();
if (StringUtils.isNotBlank(memberCode)) {
Member member = new Member();
......@@ -75,10 +221,11 @@ public class UserOperationServiceImpl implements UserOperationService {
}
// 无会员
// 无其他账号
} else {
MemberDTO memberDTO = memberAndWeixinUserDTO.getMemberDTO();
log.info("无其他账号的无会员信息,创建会员 memberDTO ==>> {}",memberDTO);
Member member = new Member();
BeanUtils.copyProperties(memberDTO, member);
member.setId(null);
......@@ -87,19 +234,20 @@ public class UserOperationServiceImpl implements UserOperationService {
}
userWeixinDTO.setId(null);
log.info("保存微信账号,userWeixinDTO ==>> {}",userWeixinDTO);
this.createWeixin(userWeixinDTO);
} else {
// 账号存在,会员也存在
// 会员存在
if(Objects.nonNull(_userWeixinDTO.getMemberId())) {
// 账号存在,修改账号和会员
this.updateWeixin(_userWeixinDTO, userWeixinDTO);
MemberDTO _memberDTO = this.memberService.findById(_userWeixinDTO.getMemberId());
if (Objects.nonNull(_memberDTO.getId())){
MemberDTO memberDTO = memberAndWeixinUserDTO.getMemberDTO();
this.updateMember(_memberDTO, memberDTO);
}
// 有账号无会员
} else {
......@@ -139,13 +287,18 @@ public class UserOperationServiceImpl implements UserOperationService {
@Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class)
public void asyncMemberAndUserTv4Iptv(MemberAndUserTvDTO memberAndUserTvDTO) {
log.info("同步小屏侧过来的大屏账号和会员, memberAndUserTvDTO ==>> {}", memberAndUserTvDTO);
UserTvDTO userTvDTO = memberAndUserTvDTO.getUserTvDTO();
MemberDTO memberDTO = memberAndUserTvDTO.getMemberDTO();
String platformAccount = userTvDTO.getPlatformAccount();
log.info("同步小屏侧过来的大屏账号, platformAccount ==>> {}", platformAccount);
UserTvDTO _userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
if (Objects.isNull(_userTvDTO)) {
// log.info("查询数据对应的大屏账号信息, _userTvDTO ==>> {}", _userTvDTO);
if (Objects.isNull(_userTvDTO)) {
log.info("大屏账号不存在, 创建会员并新增账号");
memberDTO.setId(null);
// 创建大屏会员
MemberDTO _memberDTO = this.createMember(memberDTO);
......@@ -155,46 +308,72 @@ public class UserOperationServiceImpl implements UserOperationService {
} else {
String code = memberDTO.getCode();
MemberDTO _memberDTO = this.memberService.findByCode(code);
if (Objects.nonNull(_memberDTO.getId())) {
this.updateMember(_memberDTO, memberDTO);
} else {
Long memberId = _userTvDTO.getMemberId();
if (Objects.isNull(memberId)) {
memberDTO.setId(null);
MemberDTO _memberDTO0 = this.createMember(memberDTO);
userTvDTO.setMemberId(_memberDTO0.getId());
// 创建大屏会员
MemberDTO _memberDTO = this.createMember(memberDTO);
userTvDTO.setMemberId(_memberDTO.getId());
log.info("大屏账号存在, 但无会员信息,新增会员信息并修改大屏账号");
// this.userTvService.updateMemberId(platformAccount, _memberDTO.getId());
} else {
MemberProfileDTO memberProfileDTO = this.memberProfileService.findByMemberId(memberId);
if (Objects.isNull(memberProfileDTO)) {
MemberDTO memberDTO1 = this.memberService.findById(memberId);
Member member = new Member();
BeanUtils.copyProperties(memberDTO1, member);
this.memberProfileService.createDefault(member);
}
}
this.updateUserTv(_userTvDTO, userTvDTO);
UserTv userTv = new UserTv();
BeanUtils.copyProperties(_userTvDTO, userTv);
this.userTvService.updateUserTvByPlatformAccount(userTv);
}
}
@Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class)
public void asyncAppletBind(MemberAndUserTvDTO memberAndUserTvDTO) {
public void asyncMinaBind(MemberAndUserTvDTO memberAndUserTvDTO) {
log.info("asyncAppletBind ==>> 小程序绑定大屏,参数 memberAndUserTvDTO ==>> {}", memberAndUserTvDTO);
UserTvDTO userTvDTO = memberAndUserTvDTO.getUserTvDTO();
MemberDTO memberDTO = memberAndUserTvDTO.getMemberDTO();
String platformAccount = userTvDTO.getPlatformAccount();
UserTvDTO _userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
if (Objects.nonNull(_userTvDTO)) {
if (Objects.nonNull(_userTvDTO.getId())) {
//
this.updateUserTv(_userTvDTO, userTvDTO);
// userTvDTO.getPriorityMemberCode();
// this.updateUserTv(_userTvDTO, userTvDTO);
// 修改大屏账号的主会员
String priorityMemberCode = userTvDTO.getPriorityMemberCode();
log.info("修改大屏账号的主会员, 主会员priorityMemberCode ==>> {}", priorityMemberCode);
if (StringUtils.isNotBlank(priorityMemberCode)) {
this.userTvService.updatePriorityMemberCode(platformAccount, priorityMemberCode);
}
String code = memberDTO.getCode();
MemberDTO _memberDTO = this.memberService.findByCode(code);
memberDTO.setUserIptvId(_userTvDTO.getId());
log.info("修改会员对应绑定的大屏账号id, memberId ==>> {} || userTvId ==>> {}", _memberDTO.getId(), _userTvDTO.getId());
this.memberService.updateUserIptvIdById(_memberDTO.getId(), _userTvDTO.getId(), LocalDateTime.now());
//this.updateMember(_memberDTO, memberDTO);
} else {
throw new EntityNotFoundException(UserTvDTO.class, "id", GlobeExceptionMsg.IPTV_IS_NULL);
log.error("asyncAppletBind ==>> 小程序绑定大屏异常,大屏账号不存在, platformAccount ==>> {}", platformAccount);
}
}
@Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class)
public void asyncUnbind(MemberAndUserTvDTO memberAndUserTvDTO) {
UserTvDTO userTvDTO = memberAndUserTvDTO.getUserTvDTO();
......@@ -202,30 +381,26 @@ public class UserOperationServiceImpl implements UserOperationService {
String platformAccount = userTvDTO.getPlatformAccount();
UserTvDTO _userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
_userTvDTO.setPriorityMemberCode(null);
if (Objects.nonNull(_userTvDTO.getId())) {
//
this.unbindPriorityMemberCode(_userTvDTO);
UserTv userTv = new UserTv();
userTv.setPriorityMemberCode(userTvDTO.getPriorityMemberCode());
userTv.setId(_userTvDTO.getId());
userTv.setPlatformAccount(_userTvDTO.getPlatformAccount());
this.userTvService.doUpdatePriorityMemberCode(userTv);
}
String code = memberDTO.getCode();
MemberDTO _memberDTO = this.memberService.findByCode(code);
this.unbindUserIpTv(_memberDTO);
}
private void unbindUserIpTv(MemberDTO memberDTO) {
memberDTO.setUserIptvId(null);
memberDTO.setBindIptvPlatformType(null);
memberDTO.setBindIptvTime(null);
if (Objects.nonNull(_memberDTO.getId())) {
Member member = new Member();
BeanUtils.copyProperties(memberDTO, member);
this.memberService.unbindUserIpTv(member);
member.setId(_memberDTO.getId());
member.setUserIptvId(null);
member.setBindIptvPlatformType(null);
member.setBindIptvTime(null);
this.memberService.doUpdateMemberUserIptvIdAndBindPlatformTypeAndBingTime(member);
}
private void unbindPriorityMemberCode(UserTvDTO userTvDTO) {
UserTv userTv = new UserTv();
BeanUtils.copyProperties(userTvDTO, userTv);
this.userTvService.unbindPriorityMemberCode(userTv);
}
@Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class)
......@@ -313,12 +488,42 @@ public class UserOperationServiceImpl implements UserOperationService {
}
@Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class)
public void asyncUserTvChangeMainAccount(UserTvDTO userTvDTO) {
log.info("asyncUserTv ==>> userTvDTO ==>> {}", userTvDTO);
String priorityMemberCode = userTvDTO.getPriorityMemberCode();
if (StringUtils.isBlank(priorityMemberCode)) {
log.error("大屏账号设置主会员异常,主会员code不存在");
return;
}
String platformAccount = userTvDTO.getPlatformAccount();
UserTvDTO _userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
log.info("从数据库中获取大屏信息, _userTvDTO ==>> {}", _userTvDTO);
if (Objects.isNull(_userTvDTO.getId())) {
log.error("大屏账号设置主会员异常,大屏账号不存在");
return;
}
UserTv userTv = new UserTv();
userTv.setId(_userTvDTO.getId());
userTv.setPlatformAccount(platformAccount);
userTv.setPriorityMemberCode(priorityMemberCode);
log.info("开始修改大屏数据,userTv ==>>{}", userTv);
this.userTvService.doUpdatePriorityMemberCode(userTv);
}
@Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class)
public void asyncUserTv(UserTvDTO userTvDTO) {
log.info("asyncUserTv ==>> userTvDTO ==>> {}", userTvDTO);
String platformAccount = userTvDTO.getPlatformAccount();
UserTvDTO _userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
log.info("db result ==>> _userTvDTO ==>> {}", _userTvDTO);
this.updateUserTv(_userTvDTO, userTvDTO);
// this.updateUserTv(_userTvDTO, userTvDTO);
UserTv userTv = new UserTv();
BeanUtils.copyProperties(userTvDTO, userTv);
this.userTvService.updateUserTvByPlatformAccount(userTv);
}
@Transactional(propagation = Propagation.SUPPORTS, rollbackFor = Exception.class)
......@@ -546,27 +751,4 @@ public class UserOperationServiceImpl implements UserOperationService {
BeanUtils.copyProperties(userTvDTO, userTv);
this.userTvService.create(userTv);
}
private void updateUserTv(UserTvDTO _userTvDTO, UserTvDTO userTvDTO){
userTvDTO.setId(_userTvDTO.getId());
Long memberId = _userTvDTO.getMemberId();
if (Objects.isNull(memberId)){
String memberCode = userTvDTO.getMemberCode();
if (StringUtils.isNotBlank(memberCode)) {
MemberDTO memberDTO = this.memberService.findByCode(memberCode);
userTvDTO.setMemberId(memberDTO.getId());
}
} else {
userTvDTO.setMemberId(memberId);
}
userTvDTO.setPlatformAccount(_userTvDTO.getPlatformAccount());
userTvDTO.setCreateTime(_userTvDTO.getCreateTime());
UserTv userTv = new UserTv();
BeanUtils.copyProperties(userTvDTO, userTv);
log.info("updateUserTv ==>> userTv ==>> {}" , userTv);
this.userTvService.update(userTv);
}
}
......
......@@ -8,9 +8,12 @@ import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService;
import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryDTO;
import com.topdraw.business.module.user.weixin.service.UserWeixinService;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
import com.topdraw.business.process.service.member.MemberOperationService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
......@@ -19,10 +22,12 @@ import org.springframework.util.Assert;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.List;
import java.util.Objects;
@Service
//@CacheConfig(cacheNames = "member")
@Slf4j
public class MemberOperationServiceImpl implements MemberOperationService {
@Autowired
......@@ -36,14 +41,37 @@ public class MemberOperationServiceImpl implements MemberOperationService {
@Autowired
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
public void asyncUpdateMemberVip(MemberDTO memberDTO) {
String code = memberDTO.getCode();
MemberDTO memberDTO1 = this.findByCode(code);
memberDTO1.setVip(memberDTO.getVip());
memberDTO1.setVipExpireTime(memberDTO.getVipExpireTime());
public void asyncDoUpdateGroupsBatch(List<Member> resources) {
this.memberService.asyncDoUpdateGroupsBatch(resources);
}
public void asyncUpdateMemberVipAndVipExpireTime(MemberDTO resource) {
log.info("修改会员vip,参数==>>{}", resource);
String code = resource.getCode();
if (StringUtils.isBlank(code)) {
log.error("修改会员vip失败,参数错误,会员code为空");
return;
}
MemberDTO memberDTO = this.findByCode(code);
Member member = new Member();
BeanUtils.copyProperties(memberDTO1, member);
this.update(member);
member.setId(memberDTO.getId());
member.setVip(resource.getVip());
member.setVipExpireTime(resource.getVipExpireTime());
this.memberService.doUpdateMemberVipAndVipExpireTime(member);
}
public void asyncCreateMemberVipHistory(MemberVipHistoryDTO memberVipHistoryDTO) {
String memberCode = memberVipHistoryDTO.getMemberCode();
MemberDTO memberDTO = this.findByCode(memberCode);
memberVipHistoryDTO.setMemberId(memberDTO.getId());
MemberVipHistory memberVipHistory = new MemberVipHistory();
BeanUtils.copyProperties(memberVipHistoryDTO, MemberVipHistory.class);
memberVipHistory.setId(null);
this.memberVipHistoryService.create(memberVipHistory);
}
// @Cacheable(key = "#memberId")
......@@ -94,8 +122,8 @@ public class MemberOperationServiceImpl implements MemberOperationService {
// @CachePut(key = "#resources.id")
@Override
public MemberDTO doUpdateMemberPoints(Member resources) {
// return this.memberService.doUpdateMemberPoints(resources);
MemberDTO memberDTO = this.findByCode(resources.getCode());
Member member = new Member();
member.setId(memberDTO.getId());
member.setPoints(resources.getPoints());
......
......@@ -7,12 +7,12 @@ import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.process.service.dto.MemberProfileAndMemberDTO;
import com.topdraw.business.process.service.member.MemberOperationService;
import com.topdraw.business.process.service.member.MemberProfileOperationService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.Objects;
......@@ -26,83 +26,100 @@ import java.util.Objects;
* @since : modified in 2022/3/20 17:34
*/
@Service
@Slf4j
public class MemberProfileOperationServiceImpl implements MemberProfileOperationService {
@Autowired
private MemberProfileService memberProfileService;
@Autowired
private MemberOperationService memberOperationService;
@Autowired
private MemberService memberService;
@Autowired
private MemberProfileService memberProfileService;
public void asyncCreateMemberProfile(MemberProfileDTO memberProfileDTO) {
String memberCode = memberProfileDTO.getMemberCode();
MemberDTO memberDTO = this.memberService.findByCode(memberCode);
Long memberId = memberDTO.getId();
MemberProfileDTO _memberProfileDTO = this.memberProfileService.findByMemberId(memberId);
if (Objects.isNull(_memberProfileDTO.getId())) {
memberProfileDTO.setMemberId(memberId);
this.createMemberProfileAndSyncMember(memberProfileDTO, memberDTO);
/**
*
* @param resource
*/
public void asyncCreateMemberProfileAndSyncMember(MemberProfileDTO resource) {
log.info("创建会员属性,参数 ==>> {}", resource);
String memberCode = resource.getMemberCode();
if (StringUtils.isBlank(memberCode)) {
log.error("创建会员属性失败,会员code不存在");
return;
}
MemberDTO memberDTO = this.memberService.findByCode(memberCode);
if (Objects.isNull(memberDTO.getId())) {
log.error("创建会员属性失败,会员信息不存在 ==>> memberCode ==>> {}", memberCode);
return;
}
private void createMemberProfileAndSyncMember(MemberProfileDTO memberProfileDTO, MemberDTO memberDTO) {
this.createMemberProfile(memberProfileDTO);
this.syncMember(memberProfileDTO, memberDTO);
}
Long memberId = memberDTO.getId();
MemberProfileDTO _memberProfileDTO = this.memberProfileService.findByMemberId(memberId);
private void syncMember(MemberProfileDTO memberProfileDTO, MemberDTO memberDTO) {
memberDTO.setAvatarUrl(memberProfileDTO.getAvatarUrl());
memberDTO.setNickname(memberProfileDTO.getRealname());
memberDTO.setGender(memberProfileDTO.getGender());
Member member = new Member();
BeanUtils.copyProperties(memberDTO, member);
this.memberService.update(member);
}
if (Objects.isNull(_memberProfileDTO.getId())) {
private void createMemberProfile(MemberProfileDTO memberProfileDTO) {
MemberProfile memberProfile = new MemberProfile();
BeanUtils.copyProperties(memberProfileDTO, memberProfile);
BeanUtils.copyProperties(resource, memberProfile);
memberProfile.setId(null);
memberProfile.setMemberId(memberId);
this.memberProfileService.createDefault(memberProfile);
}
public MemberProfileDTO asyncMemberProfile(MemberProfileDTO memberProfileDTO){
String memberCode = memberProfileDTO.getMemberCode();
MemberDTO memberDTO = this.memberService.findByCode(memberCode);
Long memberId = memberDTO.getId();
MemberProfileDTO _memberProfileDTO = this.memberProfileService.findByMemberId(memberId);
memberProfileDTO.setId(_memberProfileDTO.getId());
memberProfileDTO.setMemberId(memberId);
return this.updateMemberProfile(memberProfileDTO);
Member member = new Member();
member.setId(memberDTO.getId());
member.setCode(memberDTO.getCode());
member.setAvatarUrl(memberProfile.getAvatarUrl());
member.setNickname(memberProfile.getRealname());
member.setGender(memberProfile.getGender());
this.memberService.doUpdateMemberAvatarUrlAndNicknameAndGender(member);
}
private MemberProfileDTO updateMemberProfile(MemberProfileDTO memberProfileDTO) {
MemberProfile memberProfile = new MemberProfile();
BeanUtils.copyProperties(memberProfileDTO, memberProfile);
return this.memberProfileService.update(memberProfile);
}
public void asyncMemberProfileAndMember(MemberProfileAndMemberDTO resources) {
/**
*
* @param resources
*/
public void asyncUpdateMemberProfileAndSyncMember(MemberProfileAndMemberDTO resources) {
log.info("修改会员属性,参数 ==>> {}", resources);
MemberProfileDTO memberProfileDTO = resources.getMemberProfileDTO();
MemberProfileDTO _memberProfileDTO = this.asyncMemberProfile(memberProfileDTO);
if (Objects.isNull(memberProfileDTO)) {
log.error("修改会员属性异常, 会员属性参数为空");
return;
}
MemberDTO memberDTO = resources.getMemberDTO();
if (Objects.isNull(memberDTO)) {
log.error("修改会员属性异常, 会员信息为空");
return;
}
MemberProfileDTO _memberProfileDTO = this.asyncMemberProfile(memberProfileDTO);
String code = memberDTO.getCode();
if (!StringUtils.isEmpty(code)) {
MemberDTO memberDTO1 = this.memberService.findByCode(code);
Member member = new Member();
BeanUtils.copyProperties(memberDTO1, member);
member.setId(memberDTO1.getId());
member.setNickname(_memberProfileDTO.getRealname());
member.setBirthday(_memberProfileDTO.getBirthday());
member.setGender(_memberProfileDTO.getGender());
this.memberService.update(member);
this.memberService.doUpdateMemberAvatarUrlAndNicknameAndGender(member);
}
}
public MemberProfileDTO asyncMemberProfile(MemberProfileDTO memberProfileDTO){
String memberCode = memberProfileDTO.getMemberCode();
MemberDTO memberDTO = this.memberService.findByCode(memberCode);
Long memberId = memberDTO.getId();
MemberProfileDTO _memberProfileDTO = this.memberProfileService.findByMemberId(memberId);
memberProfileDTO.setId(_memberProfileDTO.getId());
memberProfileDTO.setMemberId(memberId);
MemberProfile memberProfile = new MemberProfile();
BeanUtils.copyProperties(memberProfileDTO, memberProfile);
return this.memberProfileService.update(memberProfile);
}
}
......
......@@ -13,12 +13,12 @@ import javax.naming.ConfigurationException;
import java.util.List;
import java.util.Map;
@Component
//@Component
public class RabbitMqBindingConfig {
/**************************************************数据源选择*************************************************************/
@Autowired
/*@Autowired
private RabbitMqSourceConfig rabbitMqSourceConfig;
@Autowired
private RabbitMqCustomConfig rabbitMqCustomConfig;
......@@ -33,8 +33,6 @@ public class RabbitMqBindingConfig {
@PostConstruct
public void initBinding() throws ConfigurationException {
// String source = rabbitMqSourceConfig.getActiveSource();
List<Map<String, String>> list = rabbitMqCustomConfig.getList();
if (CollectionUtils.isNotEmpty(list)) {
......@@ -86,15 +84,7 @@ public class RabbitMqBindingConfig {
this.serviceRabbitAdmin.declareQueue(queue_);
this.serviceRabbitAdmin.declareBinding(binding_);
break;
/* case "service,management":
this.serviceRabbitAdmin.declareExchange(exchange_);
this.serviceRabbitAdmin.declareQueue(queue_);
this.serviceRabbitAdmin.declareBinding(binding_);
this.managementRabbitAdmin.declareExchange(exchange_);
this.managementRabbitAdmin.declareQueue(queue_);
this.managementRabbitAdmin.declareBinding(binding_);
break;*/
default:
break;
......@@ -104,6 +94,6 @@ public class RabbitMqBindingConfig {
}
}
}*/
}
......
package com.topdraw.config;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import java.util.Map;
import java.util.Objects;
/**
* @author :
* @description:
* @function :
* @date :Created in 2022/5/12 12:37
* @version: :
* @modified By:
* @since : modified in 2022/5/12 12:37
*/
@Data
@Configuration
@ConfigurationProperties(prefix = "spring.rabbitmq", ignoreInvalidFields = true)
public class RabbitMqConfig {
@Lazy
private Map<String, String> uce;
@Lazy
private Map<String, String> memberInfo;
@Lazy
private Map<String, String> eventBus;
@Lazy
private Map<String, String> event;
@Lazy
private Map<String, String> viewRecord;
@Lazy
private Map<String, String> addCollction;
@Lazy
private Map<String, String> deleteCollction;
@Lazy
private Map<String, String> deleteAllCollction;
@Lazy
private Map<String, String> ucgCollection;
@Lazy
private Map<String, String> wechat;
@Lazy
private Map<String, String> growthReport;
/**
* uce
* @return
*/
public String getGrowthReportQueue() {
if (Objects.isNull(growthReport)) {
return "growthReport.queue";
}
String queue = this.growthReport.get("queue");
return StringUtils.isBlank(queue) ? "growthReport.queue" : queue;
}
/**
* uce
* @return
*/
public String getUceQueue() {
if (Objects.isNull(uce)) {
return "uce.queue";
}
String queue = this.uce.get("queue");
return StringUtils.isBlank(queue) ? "uce.queue" : queue;
}
/**
* memberInfo
* @return
*/
public String getMemberInfoQueue() {
if (Objects.isNull(memberInfo)) {
return "queue.MemberInfoSync";
}
String queue = this.memberInfo.get("queue");
return StringUtils.isBlank(queue) ? "queue.MemberInfoSync" : queue;
}
/**
* uce
* @return
*/
public String getEventBusQueue() {
if (Objects.isNull(eventBus)) {
return "uc.eventbus";
}
String queue = this.eventBus.get("queue");
return StringUtils.isBlank(queue) ? "uc.eventbus" : queue;
}
/**
* uce
* @return
*/
public String getUcgEventQueue() {
if (event != null) {
String queue = this.event.get("queue");
return StringUtils.isBlank(queue) ? "event.queue" : queue;
}
return "event.queue";
}
/**
* memberInfo
* @return
*/
public String getViewRecordQueue() {
if (viewRecord != null) {
String queue = this.viewRecord.get("queue");
return StringUtils.isBlank(queue) ? "viewRecord.queue" : queue;
}
return "viewRecord.queue";
}
/**
* uce
* @return
*/
public String getUcgCollectionQueueAdd() {
if (addCollction != null) {
String queue = this.addCollction.get("queue");
return StringUtils.isBlank(queue) ? "queue.collection.add" : queue;
}
return "queue.collection.add";
}
/**
* memberInfo
* @return
*/
public String getUcgCollectionQueueDelete() {
if (deleteCollction != null) {
String queue = this.deleteCollction.get("queue");
return StringUtils.isBlank(queue) ? "queue.collection.delete" : queue;
}
return "queue.collection.delete";
}
/**
* uce
* @return
*/
public String getUcgCollectionQueueDeleteAll() {
if (deleteAllCollction != null) {
String queue = this.deleteAllCollction.get("queue");
return StringUtils.isBlank(queue) ? "queue.collection.deleteall" : queue;
}
return "queue.collection.deleteall";
}
public String getUcgCollectionQueue() {
if (ucgCollection != null) {
String queue = this.ucgCollection.get("queue");
return StringUtils.isBlank(queue) ? "collection.queue" : queue;
}
return "collection.queue";
}
/**
* memberInfo
* @return
*/
public String getWechatQueue() {
if (wechat != null) {
String queue = this.wechat.get("queue");
return StringUtils.isBlank(queue) ? "weixin.subOrUnSub.queue" : queue;
}
return "weixin.subOrUnSub.queue";
}
}
......@@ -9,13 +9,33 @@ import java.util.List;
import java.util.Map;
@Data
@Configuration
@ConfigurationProperties(prefix = "service.mq")
//@Configuration
//@ConfigurationProperties(prefix = "service.mq")
public class RabbitMqCustomConfig {
private List<Map<String, String>> list;
/**
* growthReport
* @return
*/
public Map<String, String> ucgGrowthReportInfo() {
if (CollectionUtils.isNotEmpty(list)) {
for (Map<String, String> map : list) {
String type = map.get("source");
if (type.equalsIgnoreCase("growthReport")) {
return map;
}
}
}
return null;
}
/**
* viewRecord
* @return
*/
......
......@@ -18,8 +18,8 @@ import java.util.Map;
* @since : modified in 2022/5/12 12:37
*/
@Data
@Configuration
@ConfigurationProperties(prefix = "service.mq.error.logs")
//@Configuration
//@ConfigurationProperties(prefix = "service.mq.error.logs")
public class RabbitMqErrorLogConfig {
private List<Map<String, String>> list;
......
......@@ -21,10 +21,10 @@ import java.util.Map;
import java.util.Objects;
@Data
@Configuration
//@Configuration
public class RabbitMqSourceConfig {
@Value("${mutil-mq.service.host}")
/*@Value("${mutil-mq.service.host}")
private String serviceHost;
@Value("${mutil-mq.service.port}")
private Integer servicePort;
......@@ -119,13 +119,13 @@ public class RabbitMqSourceConfig {
RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory);
rabbitAdmin.setAutoStartup(true);
return rabbitAdmin;
}
}*/
/**************************************************数据源*************************************************************/
/*@Value("${service.platform}")
/* @Value("${service.platform}")
private String platform;
@Value("${service.active}")
private String active;
......@@ -143,7 +143,7 @@ public class RabbitMqSourceConfig {
}
return active;
}*/
}
private String chargeSource(String active) {
......@@ -156,10 +156,57 @@ public class RabbitMqSourceConfig {
}
return null;
}
}*/
/**************************************************uc-getaway 2 uc-consumer*************************************************************/
/*@Value("#{rabbitMqCustomConfig.ucgGrowthReportInfo()}")
private Map<String, String> ucgGrowthReportInfo;
public static final String GROWTH_REPORT_EXCHANGE = "growthReport.exchange";
public static final String GROWTH_REPORT_QUEUE = "growthReport.queue";
public String getGrowthReportQueue(){
if (Objects.nonNull(ucgGrowthReportInfo)) {
if (MapUtils.isNotEmpty(ucgGrowthReportInfo)) {
String queue = ucgGrowthReportInfo.get("queue");
return queue;
}
}
return GROWTH_REPORT_QUEUE;
}
public String getGrowthReportSource(){
if (Objects.nonNull(ucgGrowthReportInfo)) {
if (MapUtils.isNotEmpty(ucgGrowthReportInfo)) {
String source = ucgGrowthReportInfo.get("active");
if (StringUtils.isNotBlank(source)) {
return this.chargeSource(source);
} else {
return SERVICE_;
}
}
}
return SERVICE_;
}
public String getGrowthReportStartUp(){
if (Objects.nonNull(ucgGrowthReportInfo)) {
if (MapUtils.isNotEmpty(ucgGrowthReportInfo)) {
String source = ucgGrowthReportInfo.get("active");
if (StringUtils.isNotBlank(source)) {
return "true";
}
}
}
return "false";
}
public static final String EVENT_EXCHANGE = "event.exchange";
public static final String EVENT_QUEUE = "event.queue";
......@@ -205,10 +252,6 @@ public class RabbitMqSourceConfig {
return "false";
}
/* public static final String COLLECTION_DELETE_ALL_QUEUE = "queue.collection.deleteall";
public static final String COLLECTION_ADD_QUEUE = "queue.collection.add";
public static final String COLLECTION_DELETE_QUEUE = "queue.collection.delete";*/
public static final String COLLECTION_EXCHANGE = "collection.exchange";
public static final String COLLECTION_QUEUE = "collection.queue";
......@@ -309,11 +352,11 @@ public class RabbitMqSourceConfig {
}
return "false";
}
}*/
/**************************************************uc-engine 2 uc-consumer*************************************************************/
public static final String UCE_EXCHANGE = "uce.exchange";
/*public static final String UCE_EXCHANGE = "uce.exchange";
public static final String UCE_QUEUE = "uce.queue";
@Value("#{rabbitMqCustomConfig.getUceInfo()}")
......@@ -360,12 +403,13 @@ public class RabbitMqSourceConfig {
public String getMemberInfoAsyncQueue(){
return "queue.MemberInfoSync";
}
}*/
/**************************************************eventBus*************************************************************/
public static final String UC_EVENTBUS_EXCHANGE = "uc.eventbus";
/*public static final String UC_EVENTBUS_EXCHANGE = "uc.eventbus";
public static final String UC_EVENTBUS_KEY = "uc.eventbus.*.topic";
public static final String UC_EVENTBUS_QUEUE = "uc.eventbus";
......@@ -407,11 +451,11 @@ public class RabbitMqSourceConfig {
}
}
return "false";
}
}*/
/**************************************************wechat*************************************************************/
public static final String WEIXIN_EXCHANGE = "weixin.subOrUnSub.direct";
/*public static final String WEIXIN_EXCHANGE = "weixin.subOrUnSub.direct";
public static final String WEIXIN_SUBORUNSUB_QUEUE = "weixin.subOrUnSub.queue";
@Value("#{rabbitMqCustomConfig.getWechatInfo()}")
......@@ -453,5 +497,5 @@ public class RabbitMqSourceConfig {
}
return "false";
}
}*/
}
......
......@@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
......@@ -28,18 +29,25 @@ public class UcEngineManagement2IptvConsumer {
@Autowired
RestTemplateClient restTemplateClient;
@Value("#{rabbitMqErrorLogConfig.getUceError()}")
private Map<String, String> error;
@Autowired
private RabbitTemplate rabbitTemplate;
@RabbitHandler
// @Value("#{rabbitMqErrorLogConfig.getUceError()}")
// private Map<String, String> error;
/*@RabbitHandler
@RabbitListener(queues = "#{rabbitMqSourceConfig.getMemberInfoAsyncQueue()}",
containerFactory = "#{rabbitMqSourceConfig.getUceSource()}",
autoStartup = "#{rabbitMqSourceConfig.getUceStartUp()}",
//containerFactory = "#{rabbitMqSourceConfig.getUceSource()}",
// autoStartup = "#{rabbitMqSourceConfig.getUceStartUp()}",
ackMode = "AUTO")*/
@RabbitHandler
@RabbitListener(queues = "#{rabbitMqConfig.getMemberInfoQueue()}",
ackMode = "AUTO")
public void ucEventConsumer2(Channel channel, Message message, String content) throws IOException {
public void memberInfoConsumer(Channel channel, Message message, String content) throws IOException {
log.info(" receive MemberInfoAsync msg , content is : {} ", content);
try {
TableOperationMsg tableOperationMsg = this.parseContent(content);
autoUser.route(tableOperationMsg);
......@@ -47,10 +55,10 @@ public class UcEngineManagement2IptvConsumer {
// channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (Exception e) {
log.error("消费uc-engine消息失败, cause ==>> [memberInfoConsumer#{}]", e.getMessage());
// channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);
channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);
if (MapUtils.isNotEmpty(error)) {
/*if (MapUtils.isNotEmpty(error)) {
String errorStart = this.error.get("start");
if (errorStart.equalsIgnoreCase("true")) {
......@@ -60,9 +68,9 @@ public class UcEngineManagement2IptvConsumer {
FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
}
}
}*/
e.printStackTrace();
}
log.info("ucEventConsumer ====>>>> end");
......@@ -75,26 +83,28 @@ public class UcEngineManagement2IptvConsumer {
* @author Hongyan Wang
* @date 2021/9/7 11:26 上午
*/
@RabbitHandler
/*@RabbitHandler
@RabbitListener(queues = "#{rabbitMqSourceConfig.getUceQueue()}",
containerFactory = "#{rabbitMqSourceConfig.getUceSource()}",
autoStartup = "#{rabbitMqSourceConfig.getUceStartUp()}",
ackMode = "MANUAL")
public void ucEventConsumer(Channel channel, Message message, String content) throws IOException {
log.info(" receive ucEventConsumer msg , content is : {} ", content);
ackMode = "MANUAL")*/
@RabbitHandler
@RabbitListener(queues = "#{rabbitMqConfig.getUceQueue()}", ackMode = "AUTO")
public void ucEngineConsumer(Channel channel, Message message, String content) throws IOException {
log.info(" receive ucEngineConsumer msg , content is : {} ", content);
try {
TableOperationMsg tableOperationMsg = this.parseContent(content);
autoUser.route(tableOperationMsg);
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
// channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (Exception e) {
log.error("消费uc-engine消息失败, cause ==>> [ucEngineConsumer#{}]", e.getMessage());
channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);
if (MapUtils.isNotEmpty(error)) {
/*if (MapUtils.isNotEmpty(error)) {
String errorStart = this.error.get("start");
if (errorStart.equalsIgnoreCase("true")) {
......@@ -104,7 +114,7 @@ public class UcEngineManagement2IptvConsumer {
FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
}
}
}*/
e.printStackTrace();
}
......
package com.topdraw.mq.consumer;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.rabbitmq.client.Channel;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.task.attribute.service.TaskAttrService;
import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO;
import com.topdraw.business.module.task.domain.Task;
import com.topdraw.business.module.task.service.TaskService;
import com.topdraw.business.module.task.template.service.TaskTemplateService;
import com.topdraw.business.module.task.template.service.dto.TaskTemplateDTO;
import com.topdraw.business.module.user.iptv.service.UserTvService;
import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
import com.topdraw.exception.EntityNotFoundException;
import com.topdraw.business.module.task.template.constant.TaskEventName;
import com.topdraw.business.module.task.template.constant.TaskEventType;
import com.topdraw.exception.BadRequestException;
import com.topdraw.mq.domain.DataSyncMsg;
import com.topdraw.resttemplate.RestTemplateClient;
import com.topdraw.util.DateUtil;
import com.topdraw.util.FileUtil;
import com.topdraw.util.JSONUtil;
import com.topdraw.util.TimestampUtil;
import com.topdraw.utils.RedisUtils;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.amqp.core.Message;
......@@ -33,7 +20,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.text.ParseException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
......@@ -43,23 +29,10 @@ import java.util.*;
public class UcEventBusIptv2ManagementUcEngine {
@Autowired
private TaskService taskService;
@Autowired
private UserTvService userTvService;
@Autowired
private MemberService memberService;
@Autowired
private TaskAttrService taskAttrService;
@Autowired
private TaskTemplateService taskTemplateService;
@Autowired
private RestTemplateClient restTemplateClient;
@Autowired
private RedisUtils redisUtils;
@Value("#{rabbitMqErrorLogConfig.getEventBusError()}")
private Map<String, String> error;
/*@Value("#{rabbitMqErrorLogConfig.getEventBusError()}")
private Map<String, String> error;*/
/**
* 事件
......@@ -68,287 +41,97 @@ public class UcEventBusIptv2ManagementUcEngine {
* @author Hongyan Wang
* @date 2021/9/7 11:26 上午
*/
@RabbitHandler
/*@RabbitHandler
@RabbitListener(queues = "#{rabbitMqSourceConfig.getEventBusQueue()}",
containerFactory = "#{rabbitMqSourceConfig.getEventBusSource()}",
autoStartup = "#{rabbitMqSourceConfig.getEventBusStartUp()}",
ackMode = "AUTO")*/
@RabbitHandler
@RabbitListener(queues = "#{rabbitMqConfig.getEventBusQueue()}",
ackMode = "AUTO")
public void eventBusConsumer(Channel channel, Message message, String content) throws ParseException, IOException {
log.info(" receive dataSync msg , content is : {} ", content);
public void eventBusConsumer(Channel channel, Message message, String content) throws Exception {
log.info(" receive dataSync msg , content is ==>> {} ", content);
try {
this.parseContent(content);
DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content, DataSyncMsg.class);
log.info("解析后的参数 , playContent ==>> {} ", dataSyncMsg);
// channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (Exception e) {
channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);
if (MapUtils.isNotEmpty(error)) {
String errorStart = this.error.get("start");
if (Objects.nonNull(dataSyncMsg)) {
if (errorStart.equalsIgnoreCase("true")) {
String fileName = this.error.get("fileName")+"_"+LocalDate.now() +".log";
String filePath = this.error.get("filePath");
String filePath1 = filePath+fileName;
FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
String evt = dataSyncMsg.getEvt();
if (StringUtils.isBlank(evt)) {
log.error("eventBus事件类型(evt)为空");
throw new BadRequestException("参数错误,事件类型 evt不存在");
}
LocalDateTime time = dataSyncMsg.getTime();
if (Objects.isNull(time)) {
log.error("参数错误,事件发送时间(time)不存在");
throw new BadRequestException("参数错误,事件发送时间(time)不存在");
} /*else {
if (time.isAfter(LocalDateTime.now()) || time.toLocalDate().compareTo(LocalDate.now()) != 0) {
log.error("参数错误,事件发送时间(time)非法 ==>> {}", time);
throw new BadRequestException("参数错误,事件发送时间非法 ");
}
}*/
e.printStackTrace();
}
log.info("ucEventConsumer ====>>>> end");
String msgData = dataSyncMsg.getMsgData();
if (StringUtils.isBlank(msgData)) {
log.error("eventBus事件消息体(msgData)为空");
throw new BadRequestException("参数错误,事件类型 evt不存在");
}
switch (dataSyncMsg.getEvt().toUpperCase()) {
/**
* 数据解析
* @param content
* @return
*/
private void parseContent(String content) throws ParseException {
PlayContent commonMsg = JSONUtil.parseMsg2Object(content, PlayContent.class);
String evt = commonMsg.getEvt();
switch (evt.toUpperCase()) {
case "PLAY":
PlayContent playContent = JSONUtil.parseMsg2Object(content, PlayContent.class);
PlayContent.MsgData msgData = playContent.getMsgData();
if (Objects.nonNull(msgData)) {
String time = playContent.getTime();
String formatDate = DateUtil.formatDate(time);
Integer deviceType = playContent.getDeviceType();
String platformAccount = msgData.getPlatformAccount();
String mediaCode = msgData.getMediaCode();
Long mediaId = msgData.getMediaId();
String mediaName = msgData.getMediaName();
Integer playDuration = msgData.getPlayDuration();
if (Objects.isNull(playDuration) || playDuration == 0) {
return;
}
log.info("playDuration ==>> {}", playDuration);
DataSyncMsg dataSyncMsg = new DataSyncMsg();
dataSyncMsg.setEvt(evt);
DataSyncMsg.MsgData msg = new DataSyncMsg.MsgData();
Integer playDurationValueTotal = 0;
if (StringUtils.isNotBlank(platformAccount)) {
UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
if(Objects.nonNull(userTvDTO)) {
// 用大屏账号+日期做为key,并判断这个key是否存在 ,数据类型为hash eg:<total,1>,<1,playDuration>,<2,playDuration>
String key = platformAccount+"|"+formatDate;
Map<Object, Object> hmget =
this.redisUtils.hmget(key);
if (MapUtils.isEmpty(hmget)) {
// 初始化播放总时长<total>和第一个播放时间
playDurationValueTotal = playDuration;
Map<String, Object> map = new HashMap<>();
map.put("total", playDurationValueTotal);
map.put("1", playDuration);
this.redisUtils.hmset(key, map, 129600);
} else {
// 计算播放总时长 total = 播放总时长+当前播放时长
Integer total = this.getRedisTotal(hmget);
playDurationValueTotal = total + playDuration;
}
Integer totalKey = this.getRedisTotalKey(hmget);
Integer maxSize = totalKey + 1;
Map<String, Object> map = new HashMap<>();
map.put(String.valueOf(maxSize), playDuration);
map.put("total", playDurationValueTotal);
this.redisUtils.hmset(key, map);
this.checkTask(playDurationValueTotal, time, deviceType,
mediaCode, mediaId, mediaName, dataSyncMsg, msg, userTvDTO);
}
}
}
// 播放记录
case TaskEventName.PLAY:
this.doPlayEvent(dataSyncMsg);
break;
default:
log.info("无可处理的任务");
break;
}
//return null;
}
private DataSyncMsg checkTask(Integer playDurationValueTotal, String time, Integer deviceType, String mediaCode,
Long mediaId, String mediaName, DataSyncMsg dataSyncMsg,
DataSyncMsg.MsgData msgData, UserTvDTO userTvDTO) {
// 检查播放记录任务
List<TaskAttrDTO> taskAttrDTOList = new ArrayList<>();
TaskTemplateDTO taskTemplateDTO = this.taskTemplateService.findByType(8);
if (Objects.nonNull(taskTemplateDTO.getId())) {
List<Task> taskList = this.taskService.findByTemplateId(taskTemplateDTO.getId());
if (CollectionUtils.isNotEmpty(taskList)) {
for (Task task : taskList) {
TaskAttrDTO taskAttrDTO = this.taskAttrService.findByTaskId(task.getId());
taskAttrDTOList.add(taskAttrDTO);
}
} else {
return null;
}
} else {
return null;
}
List<List<Integer>> attrList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(taskAttrDTOList)) {
for (TaskAttrDTO taskAttrDTO : taskAttrDTOList) {
String attrStr = taskAttrDTO.getAttrStr();
if (StringUtils.isNotBlank(attrStr)) {
JSONObject parse = JSONObject.parseObject(attrStr, JSONObject.class);
List<Integer> value = (List<Integer>) parse.get("value");
attrList.add(value);
}
}
} else {
return null;
}
int size = attrList.size();
DataSyncMsg dataSyncMsg1 = null;
if (size > 0) {
for (int i = size-1; i >= 0; i--) {
Integer integer = attrList.get(i).get(0);
if (playDurationValueTotal >= integer) {
dataSyncMsg1 = getDataSyncMsg(time, mediaCode, mediaId, mediaName, integer, dataSyncMsg,
msgData, userTvDTO);
dataSyncMsg1.setEvt("PLAY");
dataSyncMsg1.setEvent(8);
dataSyncMsg1.setTime(LocalDateTime.now());
dataSyncMsg1.setDeviceType(deviceType);
this.taskDeal(dataSyncMsg1);
}
}
}
return dataSyncMsg1;
}
private Integer getRedisTotalKey(Map<Object, Object> hmget) {
Set<Object> objects = hmget.keySet();
return objects.size();
}
private Integer getRedisTotal(Map<Object, Object> hmget) {
Set<Object> objects = hmget.keySet();
Integer playDurationValueTotal_ = 0;
for (Object key_ : objects) {
if (key_.toString().equalsIgnoreCase("total")) {
playDurationValueTotal_ = Integer.valueOf(hmget.get(key_).toString());
return playDurationValueTotal_;
} else {
} catch (Exception e) {
continue;
log.error("eventBus 消费异常 ==>> {}",e.getMessage());
}
// TODO使用slf4j记录日志
/*if (MapUtils.isNotEmpty(error)) {
String errorStart = this.error.get("start");
if (errorStart.equalsIgnoreCase("true")) {
String fileName = this.error.get("fileName")+"_"+LocalDate.now() +".log";
String filePath = this.error.get("filePath");
String filePath1 = filePath+fileName;
FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
}
return playDurationValueTotal_;
}*/
}
private DataSyncMsg getDataSyncMsg(String time, String mediaCode, Long mediaId, String mediaName,
Integer playDuration, DataSyncMsg dataSyncMsg, DataSyncMsg.MsgData msgData1, UserTvDTO userTvDTO) {
String priorityMemberCode = userTvDTO.getPriorityMemberCode();
String memberCode = "";
if (StringUtils.isNotBlank(priorityMemberCode)) {
memberCode = priorityMemberCode;
} else {
memberCode = this.memberService.findById(userTvDTO.getMemberId()).getCode();
}
if (StringUtils.isBlank(memberCode))
throw new EntityNotFoundException(MemberDTO.class, "memberCode", "memberCode is null");
msgData1.setMemberCode(memberCode);
msgData1.setMediaId(mediaId);
JSONObject param = new JSONObject();
// 增量
param.put("playDuration", playDuration);
msgData1.setParam(JSON.toJSONString(param));
JSONObject description = new JSONObject();
description.put("mediaId", mediaId);
description.put("mediaName", mediaName);
description.put("playDuration", playDuration);
description.put("mediaCode", mediaCode);
description.put("time", time);
msgData1.setDescription(JSON.toJSONString(description));
dataSyncMsg.setMsgData(JSONObject.toJSONString(msgData1));
return dataSyncMsg;
log.info("eventBusConsumer ====>>>> end");
}
/**
* 任务处理
* @param dataSyncMsg
*
* @param playContent
*/
private void taskDeal(DataSyncMsg dataSyncMsg) {
this.restTemplateClient.dealTask(dataSyncMsg);
private void doPlayEvent(DataSyncMsg playContent) {
playContent.setEvent(TaskEventType.PLAY);
String msgData = playContent.getMsgData();
JSONObject jsonObject = JSONObject.parseObject(msgData, JSONObject.class);
Object platformAccount = jsonObject.get("platformAccount");
if (Objects.nonNull(platformAccount)) {
boolean response = this.restTemplateClient.dealTask(playContent);
if (!response) {
log.error("uc-engine响应超时,请检查uc-engine服务");
throw new BadRequestException("uc-engine响应超时");
}
@Data
static class PlayContent {
private String evt;
private Integer event;
private Integer deviceType;
private String time;
private MsgData msgData;
@Data
static class MsgData {
private String platformAccount;
private Integer playDuration;
private Long mediaId;
private String mediaCode;
private String mediaName;
}
}
}
......
......@@ -3,10 +3,7 @@ package com.topdraw.mq.consumer;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.rabbitmq.client.Channel;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.user.iptv.service.UserTvService;
import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
import com.topdraw.exception.BadRequestException;
import com.topdraw.mq.domain.DataSyncMsg;
import com.topdraw.resttemplate.RestTemplateClient;
import com.topdraw.util.FileUtil;
......@@ -19,9 +16,7 @@ import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.time.LocalDate;
import java.util.Map;
......@@ -34,44 +29,41 @@ public class UcGatewayIptv2IptvConsumer {
@Autowired
RestTemplateClient restTemplateClient;
@Autowired
AutoRoute autoUser;
@Autowired
private MemberService memberService;
@Autowired
private UserTvService userTvService;
@Value("#{rabbitMqErrorLogConfig.getUcgError()}")
private Map<String, String> error;
/*@Value("#{rabbitMqErrorLogConfig.getUcgError()}")
private Map<String, String> error;*/
/**
* 事件
* @param content
* @description 基础数据同步
* @description 普通权益事件
* @author Hongyan Wang
* @date 2021/9/7 11:26 上午
*/
@RabbitHandler
/*@RabbitHandler
@RabbitListener(queues = "#{rabbitMqSourceConfig.getUcgEventQueue()}",
containerFactory = "#{rabbitMqSourceConfig.getUcgEventSource()}",
autoStartup = "#{rabbitMqSourceConfig.getUcgEventStartUp()}",
ackMode = "MANUAL")
ackMode = "AUTO")*/
@RabbitHandler
@RabbitListener(queues = "#{rabbitMqConfig.getUcgEventQueue()}",
ackMode = "AUTO")
public void eventConsumer(Channel channel, Message message, String content) throws IOException {
log.info(" receive dataSync msg , content is : {} ", content);
log.info(" eventConsumer receive dataSync msg , content is : {} ", content);
try {
DataSyncMsg dataSyncMsg = this.parseContent(content);
DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content, DataSyncMsg.class);
if (Objects.nonNull(dataSyncMsg)) {
this.taskDeal(dataSyncMsg);
boolean jsonObject = this.restTemplateClient.dealTask(dataSyncMsg);
if (!jsonObject) {
throw new BadRequestException("uce处理任务响应超时");
}
}
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (Exception e) {
channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);
log.error("普通权益事件处理异常, ==>> {}", e.getMessage());
if (MapUtils.isNotEmpty(error)) {
/*if (MapUtils.isNotEmpty(error)) {
String errorStart = this.error.get("start");
if (StringUtils.isEmpty(errorStart) || errorStart.equalsIgnoreCase("true")) {
......@@ -81,77 +73,62 @@ public class UcGatewayIptv2IptvConsumer {
FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
}
}
e.printStackTrace();
}*/
}
log.info("ucEventConsumer ====>>>> end");
}
/**
* 数据解析
* @param content
* @return
* @description 删除全部收藏记录
* @param content 消息内容
*/
private DataSyncMsg parseContent(String content) {
DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content,DataSyncMsg.class);
Assert.notNull(dataSyncMsg,"ERROR -->> operationConsumer -->> parseContent -->> 【dataSyncMsg】 not be null !!");
String msgDataStr = dataSyncMsg.getMsgData();
DataSyncMsg.MsgData msgData = null;
if (StringUtils.isNotBlank(msgDataStr)) {
msgData = JSONObject.parseObject(msgDataStr, DataSyncMsg.MsgData.class);
}else {
return null;
}
Long memberId = msgData.getMemberId();
String memberCode = msgData.getMemberCode();
if (Objects.nonNull(memberId) && StringUtils.isBlank(memberCode)) {
MemberDTO memberDTO = this.memberService.findById(memberId);
String code = memberDTO.getCode();
msgData.setMemberCode(code);
}
/*@RabbitHandler
@RabbitListener(queues = "#{rabbitMqSourceConfig.getGrowthReportQueue()}",
containerFactory = "#{rabbitMqSourceConfig.getGrowthReportSource()}",
autoStartup = "#{rabbitMqSourceConfig.getGrowthReportStartUp()}",
ackMode = "AUTO")*/
@RabbitHandler
@RabbitListener(queues = "#{rabbitMqConfig.getGrowthReportQueue()}",
ackMode = "AUTO")
public void dealGrowthReport(Channel channel, Message message, String content) throws IOException {
log.info("receive dealGrowthReport add message, content {}", content);
String platformAccount = msgData.getPlatformAccount();
if (StringUtils.isNotBlank(platformAccount)) {
UserTvDTO userTvDTO = userTvService.findByPlatformAccount(platformAccount);
if (Objects.nonNull(userTvDTO)) {
String priorityMemberCode = userTvDTO.getPriorityMemberCode();
if (StringUtils.isNotBlank(priorityMemberCode)) {
msgData.setMemberCode(priorityMemberCode);
} else {
MemberDTO memberDTO = this.memberService.findById(userTvDTO.getMemberId());
msgData.setMemberCode(memberDTO.getCode());
}
try {
JSONObject jsonObject = JSON.parseObject(content, JSONObject.class);
if (Objects.nonNull(content)) {
Object msgData = jsonObject.get("msgData");
Boolean response = this.restTemplateClient.saveGrowthReport(JSON.toJSONString(msgData));
if (!response) {
log.error("同步大屏成长报告失败,uce接口响应超时");
}
}
if(Objects.isNull(msgData.getMemberCode()) && Objects.isNull(msgData.getMemberId())) {
log.error("会员信息不存在,msgData =>> {}", msgData);
return null;
}
} catch (Exception e) {
log.error("同步大屏成长报告失败,cause ==>> {}", e.getMessage());
dataSyncMsg.setMsgData(JSONObject.toJSONString(msgData));
return dataSyncMsg;
}
/*if (MapUtils.isNotEmpty(error)) {
String errorStart = this.error.get("start");
/**
* 任务处理
* @param dataSyncMsg
*/
private void taskDeal(DataSyncMsg dataSyncMsg) {
this.restTemplateClient.dealTask(dataSyncMsg);
if (errorStart.equalsIgnoreCase("true")) {
String fileName = this.error.get("fileName")+"_"+ LocalDate.now() +".log";
String filePath = this.error.get("filePath");
String filePath1 = filePath+fileName;
FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
}
}*/
}
}
/**
* @description 添加收藏记录
* @param content 消息内容
*/
@RabbitHandler
@RabbitListener(queues = "#{rabbitMqSourceConfig.getUcgCollectionQueue()}",
containerFactory = "#{rabbitMqSourceConfig.getUcgCollectionSource()}",
autoStartup = "#{rabbitMqSourceConfig.getUcgCollectionStartUp()}",
ackMode = "MANUAL")
@RabbitListener(queues = "#{rabbitMqConfig.getUcgCollectionQueue()}", ackMode = "AUTO")
public void collectionConsumer(Channel channel, Message message, String content) throws IOException {
log.info("receive UserCollection add message, content {}", content);
......@@ -180,13 +157,11 @@ public class UcGatewayIptv2IptvConsumer {
}
}
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (Exception e) {
channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);
log.error("收藏事件处理异常,cause ==>> {}", e.getMessage());
if (MapUtils.isNotEmpty(error)) {
/*if (MapUtils.isNotEmpty(error)) {
String errorStart = this.error.get("start");
if (errorStart.equalsIgnoreCase("true")) {
......@@ -196,9 +171,8 @@ public class UcGatewayIptv2IptvConsumer {
FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
}
}
}*/
e.printStackTrace();
}
}
......@@ -206,13 +180,15 @@ public class UcGatewayIptv2IptvConsumer {
* @description 处理观影记录
* @param content 消息内容
*/
@RabbitHandler
/*@RabbitHandler
@RabbitListener(queues = "#{rabbitMqSourceConfig.getViewRecordQueue()}",
containerFactory = "#{rabbitMqSourceConfig.getViewRecordSource()}",
autoStartup = "#{rabbitMqSourceConfig.getViewRecordStartUp()}",
ackMode = "MANUAL")
ackMode = "AUTO")*/
@RabbitHandler
@RabbitListener(queues = "#{rabbitMqConfig.getViewRecordQueue()}", ackMode = "AUTO")
public void viewRecordConsumer(Channel channel, Message message, String content) throws IOException {
log.info("receive ViewRecord add message, content {}", content);
log.info("viewRecordConsumer receive ViewRecord add message, content {}", content);
try {
......@@ -227,17 +203,13 @@ public class UcGatewayIptv2IptvConsumer {
break;
default:
break;
}
}
channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (Exception e) {
log.error("观影事件处理异常,cause ==>> {}", e.getMessage());
channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);
if (MapUtils.isNotEmpty(error)) {
/*if (MapUtils.isNotEmpty(error)) {
String errorStart = this.error.get("start");
if (errorStart.equalsIgnoreCase("true")) {
......@@ -247,25 +219,25 @@ public class UcGatewayIptv2IptvConsumer {
FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
}
}
}*/
e.printStackTrace();
}
}
/**
* @description 添加收藏记录
* @param content 消息内容
*/
@RabbitHandler
/*@RabbitHandler
@RabbitListener(queues = "#{rabbitMqSourceConfig.getUcgCollectionQueueAdd()}",
containerFactory = "#{rabbitMqSourceConfig.getUcgCollectionSource()}",
autoStartup = "#{rabbitMqSourceConfig.getUcgCollectionStartUp()}",
ackMode = "MANUAL")
ackMode = "AUTO")*/
@RabbitHandler
@RabbitListener(queues = "#{rabbitMqConfig.getUcgCollectionQueueAdd()}",
ackMode = "AUTO")
public void collectionConsumerAdd(Channel channel, Message message, String content) throws IOException {
log.info("receive collectionConsumerAdd add message, content {}", content);
......@@ -294,13 +266,12 @@ public class UcGatewayIptv2IptvConsumer {
}
}
// channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (Exception e) {
channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);
log.error("添加收藏记录事件处理异常,cause ==>> {}", e.getMessage());
if (MapUtils.isNotEmpty(error)) {
/*if (MapUtils.isNotEmpty(error)) {
String errorStart = this.error.get("start");
if (errorStart.equalsIgnoreCase("true")) {
......@@ -310,26 +281,26 @@ public class UcGatewayIptv2IptvConsumer {
FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
}
}
}*/
e.printStackTrace();
}
}
/**
* @description 添加收藏记录
* @description 删除收藏记录
* @param content 消息内容
*/
@RabbitHandler
/* @RabbitHandler
@RabbitListener(queues = "#{rabbitMqSourceConfig.getUcgCollectionQueueDelete()}",
containerFactory = "#{rabbitMqSourceConfig.getUcgCollectionSource()}",
autoStartup = "#{rabbitMqSourceConfig.getUcgCollectionStartUp()}",
ackMode = "MANUAL")
ackMode = "AUTO")*/
@RabbitHandler
@RabbitListener(queues = "#{rabbitMqConfig.getUcgCollectionQueueDelete()}", ackMode = "AUTO")
public void collectionConsumerDelete(Channel channel, Message message, String content) throws IOException {
log.info("receive collectionConsumerDelete add message, content {}", content);
try {
JSONObject jsonObject = JSON.parseObject(content, JSONObject.class);
if (Objects.nonNull(content)) {
String evt = jsonObject.get("evt").toString();
......@@ -353,13 +324,11 @@ public class UcGatewayIptv2IptvConsumer {
}
}
// channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (Exception e) {
channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);
log.error("删除收藏记录事件处理异常,cause ==>> {}", e.getMessage());
if (MapUtils.isNotEmpty(error)) {
/* if (MapUtils.isNotEmpty(error)) {
String errorStart = this.error.get("start");
if (errorStart.equalsIgnoreCase("true")) {
......@@ -369,21 +338,24 @@ public class UcGatewayIptv2IptvConsumer {
FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
}
}
}*/
e.printStackTrace();
}
}
/**
* @description 添加收藏记录
* @description 删除全部收藏记录
* @param content 消息内容
*/
@RabbitHandler
/*@RabbitHandler
@RabbitListener(queues = "#{rabbitMqSourceConfig.getUcgCollectionQueueDeleteAll()}",
containerFactory = "#{rabbitMqSourceConfig.getUcgCollectionSource()}",
autoStartup = "#{rabbitMqSourceConfig.getUcgCollectionStartUp()}",
ackMode = "MANUAL")
ackMode = "MANUAL")*/
@RabbitHandler
@RabbitListener(queues = "#{rabbitMqConfig.getUcgCollectionQueueDeleteAll()}",
ackMode = "AUTO")
public void collectionConsumerDeleteAll(Channel channel, Message message, String content) throws IOException {
log.info("receive collectionConsumerDeleteAll add message, content {}", content);
......@@ -412,13 +384,10 @@ public class UcGatewayIptv2IptvConsumer {
}
}
// channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
} catch (Exception e) {
log.error("删除全部收藏记录事件处理异常,cause ==>> {}", e.getMessage());
channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);
if (MapUtils.isNotEmpty(error)) {
/*if (MapUtils.isNotEmpty(error)) {
String errorStart = this.error.get("start");
if (errorStart.equalsIgnoreCase("true")) {
......@@ -428,9 +397,13 @@ public class UcGatewayIptv2IptvConsumer {
FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
}
}
e.printStackTrace();
}*/
}
}
}
......
......@@ -29,10 +29,8 @@ public class WeiXinEventConsumer {
@Autowired
private RestTemplateClient restTemplateClient;
private static final String QR_CODE_URL = "QR_CODE_URL_";
@Value("#{rabbitMqErrorLogConfig.getWechatError()}")
private Map<String, String> error;
/*@Value("#{rabbitMqErrorLogConfig.getWechatError()}")
private Map<String, String> error;*/
/**
......@@ -44,11 +42,12 @@ public class WeiXinEventConsumer {
* }
* @param content
*/
@RabbitHandler
/*@RabbitHandler
@RabbitListener(queues = "#{rabbitMqSourceConfig.getWechatQueue()}",
containerFactory = "#{rabbitMqSourceConfig.getWechatSource()}",
autoStartup = "#{rabbitMqSourceConfig.getWechatStartUp()}", ackMode = "AUTO")
@Transactional
autoStartup = "#{rabbitMqSourceConfig.getWechatStartUp()}", ackMode = "AUTO")*/
@RabbitHandler
@RabbitListener(queues = "#{rabbitMqConfig.getWechatQueue()}", ackMode = "AUTO")
public void subOrUnSubEvent(Channel channel, Message message, String content) throws IOException {
try {
log.info("receive wxu subOrUnSub message, content {}", content);
......@@ -92,7 +91,7 @@ public class WeiXinEventConsumer {
} catch (Exception e) {
log.error("WXSubscribeConsumer || subOrUnSub msg error || {} || {}", content, e.getMessage());
channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);
/*channel.basicReject(message.getMessageProperties().getDeliveryTag(), false);
if (MapUtils.isNotEmpty(error)) {
String errorStart = this.error.get("start");
......@@ -104,9 +103,8 @@ public class WeiXinEventConsumer {
FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
}
}
}*/
e.printStackTrace();
log.info("ucEventConsumer ====>>>> end");
}
......
......@@ -28,23 +28,4 @@ public class DataSyncMsg implements Serializable {
// 消息体
private String msgData;
/**
* 消息体
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class MsgData {
private Long memberId; // 会员id
private String memberCode;
private Long orderId;
private Long activityId;
private Long mediaId;
private Long itemId;
private String description;
private String param;
private String platformAccount;
}
}
......
......@@ -2,16 +2,16 @@ package com.topdraw.resttemplate;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.topdraw.business.module.member.address.domain.MemberAddress;
import com.topdraw.business.ResponseStatus;
import com.topdraw.mq.domain.DataSyncMsg;
import com.topdraw.mq.domain.SubscribeBean;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.stereotype.Component;
import org.springframework.util.Base64Utils;
import org.springframework.web.client.RestTemplate;
import javax.annotation.PostConstruct;
......@@ -41,158 +41,194 @@ public class RestTemplateClient {
restTemplate = new RestTemplate(factory);
}
public JSONObject dealTask(DataSyncMsg dataSyncMsg) {
public boolean dealTask(DataSyncMsg dataSyncMsg) {
try {
String url = BASE_URL + "/uce/taskOperation/dealTask";
log.info("request uc : url is " + url + ", dataSyncMsg is " + dataSyncMsg);
String content = JSON.toJSONString(dataSyncMsg);
HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
objectObjectHashMap.put("content", content);
log.info("===>>>" + content);
restTemplate.postForEntity(url, objectObjectHashMap, String.class);
/* ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, objectObjectHashMap, String.class);
if (responseEntity.getStatusCode().is2xxSuccessful()) {
String entityBody = responseEntity.getBody();444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444被44444444444444 444444 44444 44444 44444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444
JSONObject jsonObject = JSONObject.parseObject(entityBody);
if (jsonObject.getInteger("businessCode").equals(200)) {
resultSet = jsonObject.getJSONArray("resultSet").getJSONObject(0);
}
}
log.info("uc response: " + resultSet.toJSONString());
return resultSet;*/
return null;
}
objectObjectHashMap.put("content", JSON.toJSONString(dataSyncMsg));
log.info("request url is ==>> {} || param is ==>> {} ", url, objectObjectHashMap);
ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, objectObjectHashMap, String.class);
log.info("response ==>> {}", responseEntity);
public JSONObject getMemberInfo(Long memberId) {
JSONObject resultSet = null;
String url = BASE_URL + "/uce/member/findById/" + memberId;
log.info("request uc : url is " + url + ", memberId is " + memberId);
ResponseEntity<String> responseEntity = restTemplate.getForEntity(url, String.class);
if (responseEntity.getStatusCode().is2xxSuccessful()) {
String entityBody = responseEntity.getBody();
JSONObject jsonObject = JSONObject.parseObject(entityBody);
if (jsonObject.getInteger("businessCode").equals(200)) {
resultSet = jsonObject.getJSONArray("resultSet").getJSONObject(0);
if (jsonObject.getInteger("businessCode").equals(ResponseStatus.OK)) {
return true;
}
}
log.info("uc response: " + resultSet.toJSONString());
return resultSet;
}
public String createMemberAddress(MemberAddress member) {
String url = BASE_URL + "/uce/memberAddress/create";
log.info("request uc : url is " + url + ", memberId is " + JSONObject.toJSONString(member));
restTemplate.postForEntity(url, member, String.class);
/* ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, member, String.class);
String entityBody = "";
if (responseEntity.getStatusCode().is2xxSuccessful()) {
entityBody = responseEntity.getBody();
} catch (Exception e) {
log.error("处理普通权益任务(ApiUti.dealTask)信息时出现异常,cause ==>> {}", e.getMessage());
}
log.info("uc response: " + entityBody);*/
return null;
return false;
}
public String unsubscribe(SubscribeBean subscribeBean) {
public Boolean unsubscribe(SubscribeBean subscribeBean) {
try {
String url = BASE_URL + "/uce/userOperation/unsubscribe";
String content = JSON.toJSONString(subscribeBean);
HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
objectObjectHashMap.put("content", content);
log.info("reobjectObjectHashMap ===>> [{}]",objectObjectHashMap);
restTemplate.postForEntity(url, objectObjectHashMap, String.class);
log.info("unsubscribe ===>> success");
/*ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, subscribeBean, String.class);
String entityBody = "";
if (responseEntity.getStatusCode().is2xxSuccessful()) {
entityBody = responseEntity.getBody();
log.info("request url is ==>> {} || param is ==>> {} ", url, objectObjectHashMap);
ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, objectObjectHashMap, String.class);
log.info("response ==>> {}", responseEntity);
return getParseResponseResultBoolean(responseEntity);
} catch (Exception e) {
log.error("处理微信取关(ApiUti.unsubscribe)信息时出现异常,cause ==>> {}", e.getMessage());
}
log.info("uc response: " + entityBody);*/
return null;
}
public String subscribe(SubscribeBean subscribeBean) {
public Boolean subscribe(SubscribeBean subscribeBean) {
try {
String url = BASE_URL + "/uce/userOperation/subscribe";
String content = JSON.toJSONString(subscribeBean);
HashMap<String, String> objectObjectHashMap = new HashMap<>();
objectObjectHashMap.put("content", content);
log.info("reobjectObjectHashMap ===>> [{}]",objectObjectHashMap);
restTemplate.postForEntity(url, objectObjectHashMap, String.class);
log.info("send subscribe request ===>> success");
/*ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, subscribeBean, String.class);
String entityBody = "";
if (responseEntity.getStatusCode().is2xxSuccessful()) {
entityBody = responseEntity.getBody();
}
log.info("uc response: " + entityBody);*/
return null;
}
public String sendQrCodeMessage(String content) {
String url = BASE_URL + "/uce/userOperation/sendQrCodeMessage";
restTemplate.postForEntity(url, content, String.class);
/* ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, content, String.class);
String entityBody = "";
if (responseEntity.getStatusCode().is2xxSuccessful()) {
entityBody = responseEntity.getBody();
log.info("request url is ==>> {} || param is ==>> {} ", url, objectObjectHashMap);
ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, objectObjectHashMap, String.class);
log.info("response ==>> {}", responseEntity);
return getParseResponseResultBoolean(responseEntity);
} catch (Exception e) {
log.error("处理微信关注(ApiUti.subscribe)信息时出现异常,cause ==>> {}", e.getMessage());
}
log.info("uc response: " + entityBody);*/
return null;
}
public String addCollection(String content) {
public JSONObject addCollection(String content) {
try {
String url = BASE_URL + "/uce/userOperation/addCollection";
//处理接口调用 中文不显示问题
content = new String(Base64.getEncoder().encode(content.getBytes(StandardCharsets.UTF_8)));
restTemplate.postForEntity(url, content, String.class);
/* ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, content, String.class);
String entityBody = "";
if (responseEntity.getStatusCode().is2xxSuccessful()) {
entityBody = responseEntity.getBody();
ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, content, String.class);
log.info("response ==>> {}", responseEntity);
return getParseResponseResult(responseEntity);
} catch (Exception e) {
log.error("添加观影记录(ApiUti.addCollection)信息时出现异常,cause ==>> {}", e.getMessage());
}
log.info("uc response: " + entityBody);*/
return null;
}
public String deleteCollection(String content) {
public JSONObject deleteCollection(String content) {
try {
String url = BASE_URL + "/uce/userOperation/deleteCollection";
//处理接口调用 中文不显示问题
content = new String(Base64.getEncoder().encode(content.getBytes(StandardCharsets.UTF_8)));
restTemplate.postForEntity(url, content, String.class);
/* ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, content, String.class);
String entityBody = "";
if (responseEntity.getStatusCode().is2xxSuccessful()) {
entityBody = responseEntity.getBody();
ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, content, String.class);
log.info("response ==>> {}", responseEntity);
return getParseResponseResult(responseEntity);
} catch (Exception e) {
log.error("删除一条观影记录(ApiUti.deleteCollection)信息时出现异常,cause ==>> {}", e.getMessage());
}
log.info("uc response: " + entityBody);*/
return null;
}
public String deleteAllCollection(String content) {
public JSONObject deleteAllCollection(String content) {
try {
String url = BASE_URL + "/uce/userOperation/deleteAllCollection";
restTemplate.postForEntity(url, content, String.class);
/*ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, content, String.class);
String entityBody = "";
if (responseEntity.getStatusCode().is2xxSuccessful()) {
entityBody = responseEntity.getBody();
log.info("request url is ==>> {} || param is ==>> {} ", url, content);
ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, content, String.class);
log.info("response ==>> {}", responseEntity);
return getParseResponseResult(responseEntity);
} catch (Exception e) {
log.error("删除所有观影记录(ApiUti.deleteAllCollection)信息时出现异常,cause ==>> {}", e.getMessage());
}
log.info("uc response: " + entityBody);*/
return null;
}
public String dealViewRecord(String content) {
public boolean saveGrowthReport(String content) {
try {
String url = BASE_URL + "/uce/userOperation/saveGrowthReport";
String encode = Base64Utils.encodeToString(content.getBytes());
log.info("request url is ==>> {} || param is ==>> {} ", url, encode);
ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, encode, String.class);
log.info("response ==>> {}", responseEntity);
return getParseResponseResultBoolean(responseEntity);
} catch (Exception e) {
log.error("保存成长报告(ApiUti.saveGrowthReport)信息时出现异常,cause ==>> {}", e.getMessage());
}
return false;
}
public JSONObject dealViewRecord(String content) {
try {
String url = BASE_URL + "/uce/userOperation/addCollection";
//处理接口调用 中文不显示问题
content = new String(Base64.getEncoder().encode(content.getBytes(StandardCharsets.UTF_8)));
ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, content, String.class);
log.info("response ==>> {}", responseEntity);
restTemplate.postForEntity(url, content, String.class);
/* ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, content, String.class);
String entityBody = "";
if (responseEntity.getStatusCode().is2xxSuccessful()) {
entityBody = responseEntity.getBody();
return getParseResponseResult(responseEntity);
} catch (Exception e) {
log.error("处理观影记录(ApiUti.dealViewRecord)信息时出现异常,cause ==>> {}", e.getMessage());
}
log.info("uc response: " + entityBody);*/
return null;
}
/**
*
* @param responseEntity
* @return
*/
private static Boolean getParseResponseResultBoolean(ResponseEntity<String> responseEntity) {
Boolean resultSet = null;
if (responseEntity.getStatusCode().is2xxSuccessful()) {
String entityBody = responseEntity.getBody();
JSONObject jsonObject = JSONObject.parseObject(entityBody);
if (jsonObject.getInteger("businessCode").equals(ResponseStatus.OK)) {
resultSet = jsonObject.getJSONArray("resultSet").getBoolean(0);
}
}
log.info("result ==>> {}", resultSet);
return resultSet;
}
/**
*
* @param responseEntity
* @return
*/
private static JSONObject getParseResponseResult(ResponseEntity<String> responseEntity) {
JSONObject resultSet = null;
if (responseEntity.getStatusCode().is2xxSuccessful()) {
String entityBody = responseEntity.getBody();
JSONObject jsonObject = JSONObject.parseObject(entityBody);
if (jsonObject.getInteger("businessCode").equals(ResponseStatus.OK)) {
resultSet = jsonObject.getJSONArray("resultSet").getJSONObject(0);
}
}
log.info("result ==>> {}", resultSet);
return resultSet;
}
}
......
......@@ -2,6 +2,7 @@ package com.topdraw.util;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class DateUtil {
......@@ -27,4 +28,28 @@ public class DateUtil {
return null;
}
public static String getWeekFirstDay() {
SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar1=Calendar.getInstance();
calendar1.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
System.out.println("本周日: "+sdf.format(calendar1.getTime()));
return sdf.format(calendar1.getTime());
}
public static String getWeekLastDay() {
SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar1=Calendar.getInstance();
calendar1.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
System.out.println("本周六: "+sdf.format(calendar1.getTime()));
return sdf.format(calendar1.getTime());
}
}
......
package com.topdraw.util;
public class WeChatConstants {
public static String HTTPS_AUTHORIZE_WITH_SNSAPI_USERINFO = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
public static final String HTTPS_TOKEN = "https://api.weixin.qq.com/cgi-bin/token";
public static final String HTTPS_TICKET_GETTICKET = "https://api.weixin.qq.com/cgi-bin/ticket/getticket";
public static final String HTTPS_SNS_OAUTH2_ACCESS_TOKEN = "https://api.weixin.qq.com/sns/oauth2/access_token";
public static final String HTTPS_SNS_USERINFO = "https://api.weixin.qq.com/sns/userinfo";
public static final String CODE2SESSION = "https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code";
/**
* 把媒体文件上传到微信服务器。目前仅支持图片。用于发送客服消息或被动回复用户消息。
*/
public static String UPLOAD_URL = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token={0}&type=image";
/**
* 获取客服消息内的临时素材。即下载临时的多媒体文件。
*/
public static String GET_MEDIA = "https://api.weixin.qq.com/cgi-bin/media/get?access_token={0}&media_id={1}";
/**
* 用于向微信服务端申请二维码的url
*/
public static String URL_QR_CODE = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={0}";
/**
* 用于聊天时向用户发送消息的url
*/
public static String CUSTOM_SEND_URL = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}";
/**
* 发送小程序订阅消息
*/
public static final String SUBSCRIBE_SEND_URL = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token={0}";
/**
* 生成带参数二维码
*/
public static final String QR_CODE_URL = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token={0}";
/**
* 获取用户基本信息
*/
public static final String GET_USER_INFO = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={0}&openid={1}&lang=zh_CN";
// 批量获取关注者列表
public static final String GET_USER_LIST = "https://api.weixin.qq.com/cgi-bin/user/get?access_token={0}&next_openid={1}";
/**
* 成功
*/
public static String SUCCESS = "SUCCESS";
/**
* 微信系统错误
*/
public static String SYSTEMERROR = "SYSTEMERROR";
/**
* 失败 (注意:微信有的接口返回的失败用FAIL字符串表示,有的接口用FAILED表示)
*/
public static String FAIL = "FAIL";
/**
* 微信企业付款到个人失败 (注意:微信有的接口返回的失败用FAIL字符串表示,有的接口用FAILED表示)
*/
public static String FAILED = "FAILED";
public static String ACCESS_TOKEN = "access_token";
public static String ERR_CODE = "errcode";
/**
* 微信请求时,返回ACCESS_TOKEN错误码
*/
public static final String ACCESS_TOKEN_INVALID_CODE = "40001";
/**
* 文本消息
*/
public static String MSG_TYPE_TEXT = "text";
public static String MSG_TYPE_MINIPROGRAMPAGE = "miniprogrampage";
public static String MSG_TYPE_LINK = "link";
public static String MSG_TYPE_IMAGE = "image";
/**
* 事件消息
*/
public static String MSG_TYPE_EVENT = "event";
/**
* 二维码类型,临时的整型参数值
*/
public static String QR_SCENE = "QR_SCENE";
/**
* 二维码类型,临时的字符串参数值
*/
public static String QR_STR_SCENE = "QR_STR_SCENE";
/**
* 二维码类型,永久的整型参数值
*/
public static String QR_LIMIT_SCENE = "QR_LIMIT_SCENE";
/**
* 二维码类型,永久的字符串参数值
*/
public static String QR_LIMIT_STR_SCENE = "QR_LIMIT_STR_SCENE";
/******** 事件推送事件类型BEGIN********/
/**
* 取消订阅
*/
public static final String EVENT_UNSUBSCRIBE = "unsubscribe";
/**
* 订阅
*/
public static final String EVENT_SUBSCRIBE = "subscribe";
/**
* 扫描带参数二维码事件,用户已关注时的事件推送
*/
public static final String EVENT_SCAN = "SCAN";
/**
* 上报地理位置事件
*/
public static final String EVENT_LOCATION = "LOCATION";
/**
* 自定义菜单事件
*/
public static final String EVENT_CLICK = "CLICK";
/******** 事件推送事件类型END********/
/**
* 微信ACCESS_TOKEN缓存KEY
*/
public static final String TOKEN_KEY = "GLOBAL_WX_ACCESS_TOKEN_";
/**
* 微信临时素材缓存KEY
*/
public static final String WEIXIN_MEDIA_KEY = "WEIXIN_MEDIA_KEY_";
// 微信应用类型 小程序 服务号 订阅号
// 小程序
public static final String WX_APPLET = "applet";
// 服务号
public static final String WX_SERVICE = "service";
// 订阅号
public static final String WX_SUBSCRIPTION = "subscription";
}
spring:
# 数据源
datasource:
url: jdbc:log4jdbc:mysql://122.112.214.149:3306/tj_user_iptv?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
username: root
password: root
# 驱动程序
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
# Druid
type: com.alibaba.druid.pool.DruidDataSource
druid:
# 初始化配置
initial-size: 3
# 最小连接数
min-idle: 3
# 最大连接数
max-active: 15
# 获取连接超时时间
max-wait: 5000
# 连接有效性检测时间
time-between-eviction-runs-millis: 90000
# 最大空闲时间
min-evictable-idle-time-millis: 1800000
test-while-idle: true
test-on-borrow: false
test-on-return: false
validation-query: select 1
# 配置监控统计拦截的filters
filters: stat
stat-view-servlet:
url-pattern: /druid/*
reset-enable: false
# 过滤器
web-stat-filter:
url-pattern: /*
exclusions: "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*"
# jpa
jpa:
properties:
hibernate:
# 数据库类型
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
hibernate:
# 生产环境设置成 none,避免程序运行时自动更新数据库结构
ddl-auto: none
open-in-view: true
# redis
redis:
#数据库索引
database: 0
host: 122.112.214.149
port: 6379
password: redis123
#连接超时时间
timeout: 5000
###########################################自定义属性#################################################################
# 多mq配置
mutil-mq:
# 服务侧
service:
# ip
host: 122.112.214.149
# host: 139.196.145.150
# 端口
port: 5672
# 用户名
username: guest
# username: admin
# 密码
password: guest
# password: Topdraw1qaz
# 虚拟空间
virtual-host: member_center_chongshu
publisher-confirms: true #如果对异步消息需要回调必须设置为true
# 管理侧
management:
# host: 122.112.214.149 # rabbitmq的连接地址
host: 122.112.214.149 # rabbitmq的连接地址
port: 5672 # rabbitmq的连接端口号
virtual-host: member_center # rabbitmq的虚拟host
username: guest # rabbitmq的用户名
password: guest # rabbitmq的密码
# username: admin # rabbitmq的用户名
# password: Topdraw1qaz # rabbitmq的密码
publisher-confirms: true #如果对异步消息需要回调必须设置为true
# 服务属性
service:
mq:
list:
- source: event
exchange: event.exchange
queue: event.queue
exchange-type: direct
routing-key:
active: service
- source: collection
exchange: collection.exchange
queue: collection.queue
exchange-type: direct
routing-key:
active: service
- source: viewRecord
exchange: viewRecord.exchange
queue: viewRecord.queue
exchange-type: direct
routing-key:
active: service
- source: eventBus
exchange: uc.eventbus
queue: uc.eventbus
exchange-type: topic
routing-key: uc.eventbus.*.topic
active: service
- source: uce
exchange: uce.exchange
queue: uce.queue
exchange-type: direct
routing-key:
active: management
- source: wechat
exchange: weixin.exchange.direct
queue: weixin.subOrUnSub.queue
exchange-type: direct
routing-key:
active:
error:
logs:
list:
- type: eventBus
filePath: /logs/mq/eventBus/
fileName: error
start: on
- type: ucg
filePath: /logs/mq/ucg/
fileName: error
start: on
- type: uce
filePath: /logs/mq/uce/
fileName: error
start: on
- type: wechat
filePath: /logs/mq/wechat/
fileName: error
start: on
api:
baseUrl: http://127.0.0.1:8447
\ No newline at end of file
spring:
# 数据源
datasource:
url: jdbc:log4jdbc:mysql://122.112.214.149:3306/tj_user_iptv?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
username: root
password: root
# url: jdbc:log4jdbc:mysql://139.196.145.150:3306/ucs_iptv_sichuan?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
# url: jdbc:log4jdbc:mysql://122.112.214.149:3306/tj_user_iptv?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
# username: root
# password: Tjlh@2021
# password: root
url: jdbc:log4jdbc:mysql://139.196.145.150:3306/ucs_stage_vis?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
username: root
password: Tjlh@2021
# 驱动程序
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
# Druid
......@@ -48,6 +48,7 @@ spring:
# 生产环境设置成 none,避免程序运行时自动更新数据库结构
ddl-auto: none
open-in-view: true
# 不打印sql语句
show-sql: false
# redis
......@@ -60,125 +61,13 @@ spring:
#连接超时时间
timeout: 5000
###########################################自定义属性#################################################################
# 多mq配置
mutil-mq:
# 服务侧
service:
# ip
rabbitmq:
host: 122.112.214.149
# host: 139.196.145.150
# 端口
port: 5672
# 用户名
virtual-host: member_center_iptv_sichuan
username: guest
# username: admin
# 密码
password: guest
# password: Topdraw1qaz
# 虚拟空间
virtual-host: member_center_iptv_sichuan
# virtual-host: member_center_small_sichuan
publisher-confirms: true #如果对异步消息需要回调必须设置为true
# 管理侧
management:
# host: 122.112.214.149 # rabbitmq的连接地址
host: 122.112.214.149 # rabbitmq的连接地址
port: 5672 # rabbitmq的连接端口号
virtual-host: member_center_small_sichuan # rabbitmq的虚拟host
# virtual-host: member_center_small_chongshu # rabbitmq的虚拟host
username: guest # rabbitmq的用户名
password: guest # rabbitmq的密码
# username: admin # rabbitmq的用户名
# password: Topdraw1qaz # rabbitmq的密码
publisher-confirms: true #如果对异步消息需要回调必须设置为true
# 服务属性
service:
mq:
list:
- source: event
exchange: event.exchange
queue: event.queue
exchange-type: direct
routing-key:
active: service
- source: collection
exchange: exchange.collection
queue: collection.queue
exchange-type: direct
routing-key:
active: service
- source: collection
exchange: userCenter_exchange
queue: queue.collection.add
exchange-type: direct
routing-key: route.UserCollection.add
active: service
- source: collection
exchange: userCenter_exchange
queue: queue.collection.delete
exchange-type: direct
routing-key: route.UserCollection.delete
active: service
- source: collection
exchange: userCenter_exchange
queue: queue.collection.deleteall
exchange-type: direct
routing-key: route.UserCollection.deleteall
active: service
# - source: viewRecord
# exchange: viewRecord.exchange
# queue: viewRecord.queue
# exchange-type: direct
# routing-key:
# active: service
- source: eventBus
exchange: uc.eventbus
queue: uc.eventbus
exchange-type: topic
routing-key: uc.eventbus.*.topic
active: service
- source: uce
exchange: uc.direct
queue: uc.route.key.direct.event.bbb
exchange-type: direct
routing-key:
active: management
- source: uce
exchange: exchange.MemberInfoSync
queue: queue.MemberInfoSync
exchange-type: direct
routing-key:
active: management
# - source: wechat
# exchange: weixin.subOrUnSub.direct
# queue: weixin.subOrUnSub.queue
# exchange-type: direct
# routing-key:
# active: active
error:
logs:
list:
- type: eventBus
filePath: /logs/mq/eventBus/
fileName: error
start: on
- type: ucg
filePath: /logs/mq/ucg/
fileName: error
start: on
- type: uce
filePath: /logs/mq/uce/
fileName: error
start: on
- type: wechat
filePath: /logs/mq/wechat/
fileName: error
start: on
api:
baseUrl: http://127.0.0.1:8447
\ No newline at end of file
publisher-confirms: true
listener:
direct:
auto-startup: false
\ No newline at end of file
......
# 服务器
server:
# 服务端口号
# >>>
port: 8448
spring:
# 服务
application:
# 服务名
name: uc-consumer
# 配置文件
profiles:
# 启动具体的配置文件
active: dev
# 第三方接口
api:
baseUrl: http://127.0.0.1:8447
......
......@@ -64,12 +64,12 @@
<!--监控sql日志输出 -->
<logger name="jdbc.sqlonly" level="INFO" additivity="false">
<logger name="jdbc.sqlonly" level="OFF" additivity="false">
<appender-ref ref="console" />
<appender-ref ref="info" />
</logger>
<logger name="jdbc.resultset" level="ERROR" additivity="false">
<logger name="jdbc.resultset" level="OFF" additivity="false">
<appender-ref ref="console" />
<appender-ref ref="info" />
</logger>
......
......@@ -18,11 +18,6 @@ public class RestTemplateTest extends BaseTest {
@Autowired
RestTemplateClient apiUtil;
@Test
public void t(){
JSONObject memberInfo = this.apiUtil.getMemberInfo(5L);
System.out.println(memberInfo);
}
@Test
public void error(){
......