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 3756 additions and 541 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);
return this.memberMapper.toDto(member);
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);
}
return this.memberMapper.toDto(resource);
}
@Override
public MemberDTO findByCode(String code) {
Member member = this.memberRepository.findFirstByCode(code).orElseGet(Member::new);
return this.memberMapper.toDto(member);
}
private MemberDTO findByIdOrCode(Long id, String code) {
Member member = this.memberRepository.findByIdOrCode(id,code).orElseGet(Member::new);
ValidationUtil.isNull(member.getId(),"Member","param",code);
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);
expDetail.setMemberId(memberDTO.getId());
if (Objects.nonNull(memberDTO.getId())) {
expDetail.setMemberId(memberDTO.getId());
this.expDetailService.create(expDetail);
}
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,24 +38,35 @@ 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);
member.setId(memberDTO.getId());
this.memberService.doUpdateMemberPoints(member);
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);
pointsAvailable.setMemberId(memberDTO.getId());
this.pointsAvailableService.create4Custom(pointsAvailable);
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);
pointsDetail.setMemberId(memberDTO.getId());
this.pointsDetailService.create4Custom(pointsDetail);
if (Objects.nonNull(memberDTO.getId())) {
pointsDetail.setMemberId(memberDTO.getId());
this.pointsDetailService.create4Custom(pointsDetail);
}
}
public void asyncDeletePointsAvailable(PointsAvailable pointsAvailable) {
......
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();
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);
if (StringUtils.isNotBlank(taskTemplateCode)) {
TaskTemplateDTO taskTemplateDTO = this.taskTemplateOperationService.findByCode(taskTemplateCode);
Long templateId = taskTemplateDTO.getId();
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);
}
}
......
......@@ -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;
/**
*
* @param resource
*/
public void asyncCreateMemberProfileAndSyncMember(MemberProfileDTO resource) {
log.info("创建会员属性,参数 ==>> {}", resource);
String memberCode = resource.getMemberCode();
if (StringUtils.isBlank(memberCode)) {
log.error("创建会员属性失败,会员code不存在");
return;
}
public void asyncCreateMemberProfile(MemberProfileDTO memberProfileDTO) {
String memberCode = memberProfileDTO.getMemberCode();
MemberDTO memberDTO = this.memberService.findByCode(memberCode);
if (Objects.isNull(memberDTO.getId())) {
log.error("创建会员属性失败,会员信息不存在 ==>> memberCode ==>> {}", memberCode);
return;
}
Long memberId = memberDTO.getId();
MemberProfileDTO _memberProfileDTO = this.memberProfileService.findByMemberId(memberId);
if (Objects.isNull(_memberProfileDTO.getId())) {
memberProfileDTO.setMemberId(memberId);
this.createMemberProfileAndSyncMember(memberProfileDTO, memberDTO);
}
}
MemberProfile memberProfile = new MemberProfile();
BeanUtils.copyProperties(resource, memberProfile);
memberProfile.setId(null);
memberProfile.setMemberId(memberId);
this.memberProfileService.createDefault(memberProfile);
private void createMemberProfileAndSyncMember(MemberProfileDTO memberProfileDTO, MemberDTO memberDTO) {
this.createMemberProfile(memberProfileDTO);
this.syncMember(memberProfileDTO, memberDTO);
}
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 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);
}
private void createMemberProfile(MemberProfileDTO memberProfileDTO) {
MemberProfile memberProfile = new MemberProfile();
BeanUtils.copyProperties(memberProfileDTO, memberProfile);
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);
}
private MemberProfileDTO updateMemberProfile(MemberProfileDTO memberProfileDTO) {
MemberProfile memberProfile = new MemberProfile();
BeanUtils.copyProperties(memberProfileDTO, memberProfile);
return this.memberProfileService.update(memberProfile);
}
/**
*
* @param resources
*/
public void asyncUpdateMemberProfileAndSyncMember(MemberProfileAndMemberDTO resources) {
log.info("修改会员属性,参数 ==>> {}", resources);
public void asyncMemberProfileAndMember(MemberProfileAndMemberDTO 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 {
}
}
}*/
}
......