Commit 06370947 06370947156ff752f1642230eee1da7b8de4fd70 by xianghan

1.按照规范修改配置文件,去除列表

1 parent 95065426
Showing 50 changed files with 1589 additions and 960 deletions
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;
}
......@@ -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());
}
}
......
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.resttemplate;
package com.topdraw.business.module.user.app.domain;
/**
* @author :
* @description:
* @function :
* @date :Created in 2022/6/18 17:45
* @date :Created in 2022/6/30 11:42
* @version: :
* @modified By:
* @since : modified in 2022/6/18 17:45
* @since : modified in 2022/6/30 11:42
*/
public interface ResponseStatusConstant {
String OK = "00000";
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.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 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);
}
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.service.dto.UserAppDTO;
import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO;
/**
* @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);
boolean appCancellation(Long id);
boolean updateAppLastActiveTimeAndNicknameAndHeadImg(UserApp 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.user.app.domain.UserApp;
import com.topdraw.business.module.user.app.domain.UserAppBind;
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.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;
@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;
}
@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.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 com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 微信账户信息
* @author XiangHan
* @date 2021-01-18
*/
@Data
public class BuyVipBean extends WeiXinUserBean {
private Integer vip;
@JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime vipExpireTime;
}
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;
}
}
......@@ -2,11 +2,23 @@ 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;
......@@ -24,6 +36,7 @@ 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;
......@@ -48,7 +61,90 @@ public class UserOperationServiceImpl implements UserOperationService {
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();
......
......@@ -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,8 +9,8 @@ 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;
......
......@@ -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,13 +156,13 @@ public class RabbitMqSourceConfig {
}
return null;
}
}*/
/**************************************************uc-getaway 2 uc-consumer*************************************************************/
@Value("#{rabbitMqCustomConfig.ucgGrowthReportInfo()}")
/*@Value("#{rabbitMqCustomConfig.ucgGrowthReportInfo()}")
private Map<String, String> ucgGrowthReportInfo;
public static final String GROWTH_REPORT_EXCHANGE = "growthReport.exchange";
......@@ -252,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";
......@@ -356,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()}")
......@@ -407,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";
......@@ -454,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()}")
......@@ -500,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();
}
......
......@@ -31,8 +31,8 @@ public class UcEventBusIptv2ManagementUcEngine {
@Autowired
private RestTemplateClient restTemplateClient;
@Value("#{rabbitMqErrorLogConfig.getEventBusError()}")
private Map<String, String> error;
/*@Value("#{rabbitMqErrorLogConfig.getEventBusError()}")
private Map<String, String> error;*/
/**
* 事件
......@@ -41,10 +41,13 @@ 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 Exception {
log.info(" receive dataSync msg , content is ==>> {} ", content);
......@@ -97,7 +100,7 @@ public class UcEventBusIptv2ManagementUcEngine {
log.error("eventBus 消费异常 ==>> {}",e.getMessage());
// TODO使用slf4j记录日志
if (MapUtils.isNotEmpty(error)) {
/*if (MapUtils.isNotEmpty(error)) {
String errorStart = this.error.get("start");
if (errorStart.equalsIgnoreCase("true")) {
......@@ -107,7 +110,7 @@ public class UcEventBusIptv2ManagementUcEngine {
FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
}
}
}*/
}
log.info("eventBusConsumer ====>>>> end");
......
......@@ -29,8 +29,8 @@ public class UcGatewayIptv2IptvConsumer {
@Autowired
RestTemplateClient restTemplateClient;
@Value("#{rabbitMqErrorLogConfig.getUcgError()}")
private Map<String, String> error;
/*@Value("#{rabbitMqErrorLogConfig.getUcgError()}")
private Map<String, String> error;*/
/**
* 事件
......@@ -39,10 +39,13 @@ public class UcGatewayIptv2IptvConsumer {
* @author Hongyan Wang
* @date 2021/9/7 11:26 上午
*/
@RabbitHandler
/*@RabbitHandler
@RabbitListener(queues = "#{rabbitMqSourceConfig.getUcgEventQueue()}",
containerFactory = "#{rabbitMqSourceConfig.getUcgEventSource()}",
autoStartup = "#{rabbitMqSourceConfig.getUcgEventStartUp()}",
ackMode = "AUTO")*/
@RabbitHandler
@RabbitListener(queues = "#{rabbitMqConfig.getUcgEventQueue()}",
ackMode = "AUTO")
public void eventConsumer(Channel channel, Message message, String content) throws IOException {
log.info(" eventConsumer receive dataSync msg , content is : {} ", content);
......@@ -60,7 +63,7 @@ public class UcGatewayIptv2IptvConsumer {
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")) {
......@@ -70,9 +73,7 @@ public class UcGatewayIptv2IptvConsumer {
FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
}
}
}*/
}
log.info("ucEventConsumer ====>>>> end");
}
......@@ -83,10 +84,13 @@ public class UcGatewayIptv2IptvConsumer {
* @description 删除全部收藏记录
* @param content 消息内容
*/
@RabbitHandler
/*@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);
......@@ -96,8 +100,8 @@ public class UcGatewayIptv2IptvConsumer {
JSONObject jsonObject = JSON.parseObject(content, JSONObject.class);
if (Objects.nonNull(content)) {
Object msgData = jsonObject.get("msgData");
JSONObject response = this.restTemplateClient.saveGrowthReport(JSON.toJSONString(msgData));
if (Objects.isNull(response)) {
Boolean response = this.restTemplateClient.saveGrowthReport(JSON.toJSONString(msgData));
if (!response) {
log.error("同步大屏成长报告失败,uce接口响应超时");
}
}
......@@ -105,7 +109,7 @@ public class UcGatewayIptv2IptvConsumer {
} catch (Exception e) {
log.error("同步大屏成长报告失败,cause ==>> {}", e.getMessage());
if (MapUtils.isNotEmpty(error)) {
/*if (MapUtils.isNotEmpty(error)) {
String errorStart = this.error.get("start");
if (errorStart.equalsIgnoreCase("true")) {
......@@ -115,7 +119,7 @@ public class UcGatewayIptv2IptvConsumer {
FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
}
}
}*/
}
}
......@@ -124,10 +128,7 @@ public class UcGatewayIptv2IptvConsumer {
* @param content 消息内容
*/
@RabbitHandler
@RabbitListener(queues = "#{rabbitMqSourceConfig.getUcgCollectionQueue()}",
containerFactory = "#{rabbitMqSourceConfig.getUcgCollectionSource()}",
autoStartup = "#{rabbitMqSourceConfig.getUcgCollectionStartUp()}",
ackMode = "AUTO")
@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);
......@@ -160,7 +161,7 @@ public class UcGatewayIptv2IptvConsumer {
log.error("收藏事件处理异常,cause ==>> {}", e.getMessage());
if (MapUtils.isNotEmpty(error)) {
/*if (MapUtils.isNotEmpty(error)) {
String errorStart = this.error.get("start");
if (errorStart.equalsIgnoreCase("true")) {
......@@ -170,7 +171,7 @@ public class UcGatewayIptv2IptvConsumer {
FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
}
}
}*/
}
}
......@@ -179,11 +180,13 @@ public class UcGatewayIptv2IptvConsumer {
* @description 处理观影记录
* @param content 消息内容
*/
@RabbitHandler
/*@RabbitHandler
@RabbitListener(queues = "#{rabbitMqSourceConfig.getViewRecordQueue()}",
containerFactory = "#{rabbitMqSourceConfig.getViewRecordSource()}",
autoStartup = "#{rabbitMqSourceConfig.getViewRecordStartUp()}",
ackMode = "AUTO")
ackMode = "AUTO")*/
@RabbitHandler
@RabbitListener(queues = "#{rabbitMqConfig.getViewRecordQueue()}", ackMode = "AUTO")
public void viewRecordConsumer(Channel channel, Message message, String content) throws IOException {
log.info("viewRecordConsumer receive ViewRecord add message, content {}", content);
......@@ -206,7 +209,7 @@ public class UcGatewayIptv2IptvConsumer {
} catch (Exception e) {
log.error("观影事件处理异常,cause ==>> {}", e.getMessage());
if (MapUtils.isNotEmpty(error)) {
/*if (MapUtils.isNotEmpty(error)) {
String errorStart = this.error.get("start");
if (errorStart.equalsIgnoreCase("true")) {
......@@ -216,7 +219,7 @@ public class UcGatewayIptv2IptvConsumer {
FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
}
}
}*/
}
......@@ -227,10 +230,13 @@ public class UcGatewayIptv2IptvConsumer {
* @description 添加收藏记录
* @param content 消息内容
*/
@RabbitHandler
/*@RabbitHandler
@RabbitListener(queues = "#{rabbitMqSourceConfig.getUcgCollectionQueueAdd()}",
containerFactory = "#{rabbitMqSourceConfig.getUcgCollectionSource()}",
autoStartup = "#{rabbitMqSourceConfig.getUcgCollectionStartUp()}",
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);
......@@ -265,7 +271,7 @@ public class UcGatewayIptv2IptvConsumer {
log.error("添加收藏记录事件处理异常,cause ==>> {}", e.getMessage());
if (MapUtils.isNotEmpty(error)) {
/*if (MapUtils.isNotEmpty(error)) {
String errorStart = this.error.get("start");
if (errorStart.equalsIgnoreCase("true")) {
......@@ -275,7 +281,7 @@ public class UcGatewayIptv2IptvConsumer {
FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
}
}
}*/
}
}
......@@ -284,11 +290,13 @@ public class UcGatewayIptv2IptvConsumer {
* @description 删除收藏记录
* @param content 消息内容
*/
@RabbitHandler
/* @RabbitHandler
@RabbitListener(queues = "#{rabbitMqSourceConfig.getUcgCollectionQueueDelete()}",
containerFactory = "#{rabbitMqSourceConfig.getUcgCollectionSource()}",
autoStartup = "#{rabbitMqSourceConfig.getUcgCollectionStartUp()}",
ackMode = "AUTO")
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);
......@@ -320,7 +328,7 @@ public class UcGatewayIptv2IptvConsumer {
log.error("删除收藏记录事件处理异常,cause ==>> {}", e.getMessage());
if (MapUtils.isNotEmpty(error)) {
/* if (MapUtils.isNotEmpty(error)) {
String errorStart = this.error.get("start");
if (errorStart.equalsIgnoreCase("true")) {
......@@ -330,7 +338,7 @@ public class UcGatewayIptv2IptvConsumer {
FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
}
}
}*/
}
......@@ -340,11 +348,14 @@ public class UcGatewayIptv2IptvConsumer {
* @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);
......@@ -376,7 +387,7 @@ public class UcGatewayIptv2IptvConsumer {
} catch (Exception e) {
log.error("删除全部收藏记录事件处理异常,cause ==>> {}", e.getMessage());
if (MapUtils.isNotEmpty(error)) {
/*if (MapUtils.isNotEmpty(error)) {
String errorStart = this.error.get("start");
if (errorStart.equalsIgnoreCase("true")) {
......@@ -386,7 +397,7 @@ public class UcGatewayIptv2IptvConsumer {
FileUtil.writeStringToFile2(filePath1, content, e.getMessage());
}
}
}*/
}
}
......
......@@ -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");
}
......
......@@ -2,11 +2,9 @@ package com.topdraw.resttemplate;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.topdraw.config.ResponseStatus;
import com.topdraw.mq.consumer.UcEventBusIptv2ManagementUcEngine;
import com.topdraw.business.ResponseStatus;
import com.topdraw.mq.domain.DataSyncMsg;
import com.topdraw.mq.domain.SubscribeBean;
import com.topdraw.util.Base64Util;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
......@@ -155,7 +153,7 @@ public class RestTemplateClient {
return null;
}
public JSONObject saveGrowthReport(String content) {
public boolean saveGrowthReport(String content) {
try {
String url = BASE_URL + "/uce/userOperation/saveGrowthReport";
String encode = Base64Utils.encodeToString(content.getBytes());
......@@ -163,13 +161,13 @@ public class RestTemplateClient {
ResponseEntity<String> responseEntity = restTemplate.postForEntity(url, encode, String.class);
log.info("response ==>> {}", responseEntity);
return getParseResponseResult(responseEntity);
return getParseResponseResultBoolean(responseEntity);
} catch (Exception e) {
log.error("删除所有观影记录(ApiUti.deleteAllCollection)信息时出现异常,cause ==>> {}", e.getMessage());
log.error("保存成长报告(ApiUti.saveGrowthReport)信息时出现异常,cause ==>> {}", e.getMessage());
}
return null;
return false;
}
public JSONObject dealViewRecord(String content) {
......@@ -194,6 +192,25 @@ public class RestTemplateClient {
* @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;
......
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
......@@ -60,131 +60,35 @@ 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_small_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: growthReport
exchange: growthReport.exchange
queue: growthReport.queue
exchange-type: direct
routing-key:
active: service
- 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: uce.exchange
queue: uce.queue
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
uce:
queue: uce.queue
memberInfo:
queue: queue.MemberInfoSync
event:
queue: event.queue
collection:
queue: collection.queue
addCollection:
queue: collection.queue
deleteCollection:
queue: collection.queue
deleteAllCollection:
queue: collection.queue
viewRecord:
queue: viewRecord.queue
eventBus:
queue: uc.eventbus
wechat:
queue: weixin.subOrUnSub.queue
growthReport:
queue: growthReport.queue
\ 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
......