Commit 7bfe629e 7bfe629ea6301abccc904cb9fd8276d0ef82019f by xianghan

1.添加app绑定第三方账号的接口

1 parent d90e60eb
......@@ -45,6 +45,10 @@ public class UserAppBind implements Serializable {
@Column(name = "status", nullable = false)
private Integer status;
// 昵称
@Column(name = "nickname", nullable = false)
private String nickname;
// 创建时间
@CreatedDate
@Column(name = "create_time")
......
......@@ -5,6 +5,8 @@ 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 org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
......@@ -19,4 +21,16 @@ public interface UserAppBindRepository extends JpaRepository<UserAppBind, Long>,
@Modifying
@Query(value = "UPDATE `uc_user_app_bind` SET `status` = 0 , `update_time` = now() WHERE `account` = ?1 ", nativeQuery = true)
Integer cancelUserAppBind(String account);
Optional<UserAppBind> findFirstByAccountAndAccountType(String account, Integer accountType);
@Modifying
@Transactional(rollbackFor = Exception.class)
@Query(value = "UPDATE `uc_user_app_bind` SET `status` = 1, `update_time` = now() WHERE `account` = ?1, accountType = ?2", nativeQuery = true)
Integer updateUserAppBindStatus2Valid(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` = ?1, accountType = ?2", nativeQuery = true)
Integer updateUserAppBind(@Param("resources") UserAppBind userAppBind);
}
......
......@@ -47,4 +47,18 @@ public interface UserAppBindService {
* @return
*/
Integer cancelUserAppBind(String account);
/**
*
* @param account
* @param accountType
* @return
*/
UserAppBindDTO findFirstByAccountAndAccountType(String account, Integer accountType);
/**
*
* @return
*/
Integer updateUserAppBind(UserAppBind userAppBind);
}
......
......@@ -27,6 +27,9 @@ public class UserAppBindDTO implements Serializable {
// 绑定状态 0:解绑;1 绑定
private Integer status;
// 昵称
private String nickname;
// 创建时间
private Timestamp createTime;
......
......@@ -70,5 +70,18 @@ public class UserAppBindServiceImpl implements UserAppBindService {
return this.userAppBindRepository.cancelUserAppBind(account);
}
@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 Integer updateUserAppBind(UserAppBind userAppBind) {
return this.userAppBindRepository.updateUserAppBind(userAppBind);
}
}
......
......@@ -107,6 +107,38 @@ public class UserOperationController {
}
@Log
@PostMapping(value = "/appBindUserAccount")
@ApiOperation("app账号绑定第三方账号")
@AnonymousAccess
public ResultInfo appBindUserAccount(@Validated @RequestBody UserApp resources) {
log.info("app账号绑定第三方账号,参数 ==>> [appBindUserAccount#{}]", resources);
String username = resources.getUsername();
if (StringUtils.isBlank(username)) {
log.error("app账号绑定第三方账号,参数错误,账号不得为空 ");
return ResultInfo.failure("app账号绑定第三方账号,参数错误,账号不得为空");
}
String account = resources.getAccount();
if (StringUtils.isNotBlank(account)) {
if (Objects.isNull(resources.getAccountType())) {
log.error("app账号绑定第三方账号,参数错误,第三方账号不得为空");
return ResultInfo.failure("app账号绑定第三方账号,参数错误,第三方账号不得为空");
}
}
// 第三方账号类型 3:微信;4:QQ;5:微博;6:苹果账号
Integer accountType = resources.getAccountType();
if (Objects.isNull(accountType)) {
log.error("app账号绑定第三方账号,参数错误,第三方账号类型不得为空");
return ResultInfo.failure("app账号绑定第三方账号,参数错误,第三方账号类型不得为空");
}
boolean result = this.userOperationService.appBindUserAccount(resources);
return ResultInfo.success(result);
}
@Log
@PostMapping(value = "/updateUserApp")
@ApiOperation("修改app账号信息")
@AnonymousAccess
......@@ -136,7 +168,7 @@ public class UserOperationController {
@PostMapping("/appBind")
@ApiOperation("微信小程序绑定大屏")
@ApiOperation("app绑定大屏")
@AnonymousAccess
public ResultInfo appBind(@Validated(value = {BindGroup.class}) @RequestBody BindBean resources) {
log.info("UserOperationController ==> appletBind ==>> param ==> [{}]",resources);
......@@ -156,7 +188,7 @@ public class UserOperationController {
}
@PostMapping("/appUnbind")
@ApiOperation("小屏解绑")
@ApiOperation("app解绑")
@AnonymousAccess
public ResultInfo appUnbind(@Validated(value = {UnbindGroup.class}) @RequestBody WeixinUnBindBean weixinUnBindBean) {
log.info("UserOperationController ==> minaUnbind ==>> param ==> [{}]", weixinUnBindBean);
......
......@@ -183,4 +183,12 @@ public interface UserOperationService {
* @return
*/
boolean cancelUserAppBind(UserApp resources);
/**
*
* @param resources
* @return
*/
boolean appBindUserAccount(UserApp resources);
}
......
......@@ -12,10 +12,7 @@ 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.member.service.dto.MemberSimpleDTO;
import com.topdraw.business.module.user.app.domain.UserApp;
import com.topdraw.business.module.user.app.domain.UserAppBind;
import com.topdraw.business.module.user.app.domain.UserAppBindBuilder;
import com.topdraw.business.module.user.app.domain.UserAppBuilder;
import com.topdraw.business.module.user.app.domain.*;
import com.topdraw.business.module.user.app.service.UserAppBindService;
import com.topdraw.business.module.user.app.service.UserAppService;
import com.topdraw.business.module.user.app.service.dto.UserAppBindDTO;
......@@ -167,6 +164,19 @@ public class UserOperationServiceImpl implements UserOperationService {
return false;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean appBindUserAccount(UserApp resources) {
String account = resources.getAccount();
Integer accountType = resources.getAccountType();
UserAppBindDTO userAppBindDTO = this.userAppBindService.findFirstByAccountAndAccountType(account, accountType);
if (Objects.nonNull(userAppBindDTO.getId())){
Integer count = null;//this.userAppBindService.update(account, accountType, UserAppStatusConstant.VALID_STATUS);
return count > 0;
}
return false;
}
/**
* 创建大屏账户同时创建会员
*
......@@ -174,7 +184,7 @@ public class UserOperationServiceImpl implements UserOperationService {
* @return UserTvDTO
*/
@Override
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
@Transactional(rollbackFor = Exception.class)
public UserTvDTO createTvUserAndMember(UserTv resources) {
// 大屏账户
......@@ -1130,7 +1140,7 @@ public class UserOperationServiceImpl implements UserOperationService {
userTv.setId(userTvDTO.getId());
userTv.setPriorityMemberCode(memberDTO.getCode());
userTvDTO = this.userTvService.doUpdatePriorityMemberCode(userTv);
this.userTvService.doUpdatePriorityMemberCode(userTv);
}
Member member = new Member();
......@@ -1156,7 +1166,7 @@ public class UserOperationServiceImpl implements UserOperationService {
member.setPlatformAccount(platformAccount);
// 修改会员
memberDTO = this.memberService.doUpdateMemberUserIptvIdAndBindIptvPlatformAndBindIptvTime(member);
this.memberService.doUpdateMemberUserIptvIdAndBindIptvPlatformAndBindIptvTime(member);
memberDTO.setPlatformAccount(platformAccount);
......