Commit eea90473 eea904736ef3a4661ab55e9d014647728190d13f by xianghan

1.修改app登录时app账号和第三方账号同时存在时头像和昵称无法同步的问题

1 parent c88db290
Showing 27 changed files with 681 additions and 11 deletions
......@@ -3,6 +3,7 @@ package com.topdraw.business.module.member.address.repository;
import com.topdraw.business.module.member.address.domain.MemberAddress;
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;
/**
......@@ -14,4 +15,12 @@ public interface MemberAddressRepository extends JpaRepository<MemberAddress, Lo
@Query(value = "select IFNULL(max(sequence),0) from uc_member_address where member_id = ?1" , nativeQuery = true)
int findMaxSequenceByMemberId(Long memberId);
@Modifying
@Query(value = "UPDATE `uc_member_address` SET `is_default` = 1, `update_time` = now() WHERE `id` = ?1", nativeQuery = true)
Integer updateDefaultMemberAddressById(Long id);
@Modifying
@Query(value = "UPDATE `uc_member_address` SET `is_default` = 0, `update_time` = now() WHERE `member_id` = ?1", nativeQuery = true)
Integer updateUnDefaultMemberAddressByMemberId(Long memberId);
}
......
......@@ -40,4 +40,8 @@ public interface MemberAddressService {
* @return
*/
int findMaxSequenceByMemberId(Long memberId);
Integer updateDefaultMemberAddressById(Long id);
Integer updateUnDefaultMemberAddressByMemberId(Long memberId);
}
......
......@@ -105,6 +105,18 @@ public class MemberAddressServiceImpl implements MemberAddressService {
return this.memberAddressRepository.findMaxSequenceByMemberId(memberId);
}
@Override
@Transactional(rollbackFor = Exception.class)
public Integer updateDefaultMemberAddressById(Long id) {
return this.memberAddressRepository.updateDefaultMemberAddressById(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public Integer updateUnDefaultMemberAddressByMemberId(Long memberId) {
return this.memberAddressRepository.updateUnDefaultMemberAddressByMemberId(memberId);
}
/**
* 检查会员
* @param memberAddress
......
......@@ -30,6 +30,7 @@ public class UserAppBuilder {
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");
......
......@@ -8,6 +8,7 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Optional;
/**
......@@ -52,5 +53,11 @@ public interface UserAppBindRepository extends JpaRepository<UserAppBind, Long>,
@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);
}
......
......@@ -15,16 +15,17 @@ import java.util.Optional;
*/
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", nativeQuery = true)
@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", nativeQuery = true)
@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
......@@ -38,4 +39,12 @@ public interface UserAppRepository extends JpaRepository<UserApp, Long>, JpaSpec
@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(), `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);
}
......
......@@ -36,6 +36,22 @@ public class UserAppController {
private UserAppBindService userAppBindService;
@Log
@PostMapping(value = "/updateAppLastActiveTimeAndNicknameAndHeadImg")
@ApiOperation("修改app账号最后登录时间、昵称和头像")
@AnonymousAccess
public ResultInfo updateAppLastActiveTimeAndNicknameAndHeadImg(@Validated @RequestBody UserApp resources) {
log.info("修改app账号密码,参数 ==>> [updatePassword#{}]", resources);
String username = resources.getUsername();
if (StringUtils.isBlank(username)) {
log.error("修改app账号密码,参数错误,app账号不得为空,[updateLastActiveTime#{}]", resources);
return ResultInfo.failure("修改app账号密码失败,参数错误,app账号不得为空");
}
boolean result = this.userAppService.updateAppLastActiveTimeAndNicknameAndHeadImg(resources);
return ResultInfo.success(result);
}
@Log
@PostMapping(value = "/updateAppPasswordByUsername")
@ApiOperation("修改app账号密码")
@AnonymousAccess
......@@ -53,11 +69,11 @@ public class UserAppController {
return ResultInfo.failure("修改app账号最新登录时间失败,参数错误,app账号不得为空");
}
boolean passwordRegexResult = RegexUtil.appPasswordRegex(password);
if (!passwordRegexResult) {
log.error("修改app账号密码失败,参数错误,密码格式不正确,[updatePassword#{}]", resources);
return ResultInfo.failure("密码必须包含大小写字母和数字的组合,不能使用特殊字符,长度在 8-25 之间");
}
// boolean passwordRegexResult = RegexUtil.appPasswordRegex(password);
// if (!passwordRegexResult) {
// log.error("修改app账号密码失败,参数错误,密码格式不正确,[updatePassword#{}]", resources);
// return ResultInfo.failure("密码必须包含大小写字母和数字的组合,不能使用特殊字符,长度在 8-25 之间");
// }
boolean result = this.userAppService.updatePasswordByUsername(resources);
return ResultInfo.success(result);
......
......@@ -3,6 +3,8 @@ 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
......@@ -76,4 +78,8 @@ public interface UserAppBindService {
* @return
*/
boolean updateValidStatusAndUserAppIdAndNickname(UserAppBind resources);
boolean appCancellation(List<Long> ids);
List<UserAppBindDTO> findByUserAppId(Long id);
}
......
......@@ -73,5 +73,8 @@ public interface UserAppService {
UserAppSimpleDTO updateAppInfo(UserApp resources);
boolean appCancellation(Long id);
boolean updateAppLastActiveTimeAndNicknameAndHeadImg(UserApp resources);
}
......
......@@ -13,6 +13,8 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.util.Assert;
import java.util.List;
/**
* @author XiangHan
* @date 2022-06-27
......@@ -96,5 +98,18 @@ public class UserAppBindServiceImpl implements UserAppBindService {
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);
}
}
......
......@@ -124,6 +124,19 @@ public class UserAppServiceImpl implements UserAppService {
@Override
@Transactional(rollbackFor = Exception.class)
public boolean appCancellation(Long id) {
return this.userAppRepository.appCancellation(id) > 0;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updateAppLastActiveTimeAndNicknameAndHeadImg(UserApp resources) {
return this.userAppRepository.updateAppLastActiveTimeAndNicknameAndHeadImg(resources.getUsername(),
resources.getNickname(), resources.getHeadimgurl()) > 0;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean updatePasswordById(UserApp resources) {
return this.userAppRepository.updatePasswordById(resources.getId(), resources.getPassword()) > 0;
}
......
package com.topdraw.business.module.user.iptv.growreport.domain;
import lombok.Data;
import lombok.experimental.Accessors;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @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 weekFirstDay, String weekLastDay);
@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.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.annotation.Log;
import com.topdraw.business.module.user.iptv.growreport.domain.GrowthReport;
import com.topdraw.business.module.user.iptv.growreport.service.GrowthReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
/**
* @author XiangHan
* @date 2022-07-07
*/
@Api(tags = "GrowthReport管理")
@RestController
@RequestMapping("/api/GrowthReport")
public class GrowthReportController {
@Autowired
private GrowthReportService GrowthReportService;
@Log
@PostMapping
@ApiOperation("新增GrowthReport")
public ResultInfo create(@Validated @RequestBody GrowthReport resources) {
GrowthReportService.create(resources);
return ResultInfo.success();
}
@Log
@PutMapping
@ApiOperation("修改GrowthReport")
public ResultInfo update(@Validated @RequestBody GrowthReport resources) {
GrowthReportService.update(resources);
return ResultInfo.success();
}
@Log
@DeleteMapping(value = "/{id}")
@ApiOperation("删除GrowthReport")
public ResultInfo delete(@PathVariable Long id) {
GrowthReportService.delete(id);
return ResultInfo.success();
}
}
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);
/**
*
* @param platformAccount
* @param weekFirstDay
* @param weekLastDay
* @return
*/
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 lombok.Data;
import java.sql.Timestamp;
import java.io.Serializable;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
/**
* @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.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;
import java.util.List;
/**
* @author XiangHan
* @date 2022-07-07
*/
@Data
public class GrowthReportRequest implements Serializable {
private String platformAccount;
private List<CategoryContent> playDurationWithCategory;
@Data
public static class CategoryContent{
private String categoryName;
private Long playDuration;
private String categoryCode;
}
}
package com.topdraw.business.module.user.iptv.growreport.service.impl;
import com.topdraw.business.module.user.iptv.growreport.domain.GrowthReport;
import com.topdraw.utils.ValidationUtil;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.dao.EmptyResultDataAccessException;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.util.Assert;
import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import java.util.List;
import java.util.Map;
/**
* @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
@Transactional(readOnly = true)
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
@Transactional(readOnly = true)
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> {
}
......@@ -2,6 +2,8 @@ package com.topdraw.business.process.rest;
import com.topdraw.annotation.AnonymousAccess;
import com.topdraw.business.module.common.validated.UpdateGroup;
import com.topdraw.business.module.member.address.domain.MemberAddress;
import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO;
import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.process.domian.member.MemberOperationBean;
......@@ -28,6 +30,21 @@ public class MemberOperationController {
@Autowired
private MemberOperationService memberOperationService;
@RequestMapping(value = "/updateDefaultMemberAddressById")
@ApiOperation("设置默认地址")
@AnonymousAccess
public ResultInfo updateDefaultMemberAddressById(@Validated(value = {UpdateGroup.class}) @RequestBody MemberAddress resources) {
log.info("设置默认地址,参数 ==>> [updateDefaultMemberAddressById#{}]",resources);
Long id = resources.getId();
if (Objects.isNull(id)) {
return ResultInfo.failure("设置默认地址失败,参数错误,id为空");
}
MemberAddressDTO memberAddressDTO = this.memberOperationService.updateDefaultMemberAddressById(id);
return ResultInfo.success(memberAddressDTO);
}
@RequestMapping(value = "/updateVipByMemberId")
@ApiOperation("手动修改vip")
@AnonymousAccess
......
......@@ -2,6 +2,8 @@ package com.topdraw.business.process.rest;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.topdraw.annotation.AnonymousAccess;
import com.topdraw.annotation.Log;
......@@ -14,6 +16,8 @@ import com.topdraw.business.module.user.app.domain.UserAppBind;
import com.topdraw.business.module.user.app.service.dto.UserAppDTO;
import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO;
import com.topdraw.business.module.user.iptv.domain.UserTv;
import com.topdraw.business.module.user.iptv.growreport.domain.GrowthReport;
import com.topdraw.business.module.user.iptv.growreport.service.dto.GrowthReportRequest;
import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.module.user.weixin.domain.UserWeixin;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
......@@ -40,6 +44,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.util.Base64Utils;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......@@ -73,6 +78,47 @@ public class UserOperationController {
/******************************************************* APP ************************************/
/**
* app账号退出登录
* @param userApp app账号
* @return ResultInfo
*/
@Log
@PostMapping(value = "/appSignOut")
@ApiOperation("app账号退出登录")
@AnonymousAccess
public ResultInfo appSignOut(@Validated @RequestBody UserApp userApp) {
log.info("app账号退出登录,参数 ==>> [appSignOut#{}]", userApp.getId());
if (Objects.isNull(userApp.getId())) {
log.error("app账号退出登录失败,参数错误,id不得为空,[appSignOut#]");
return ResultInfo.failure("app账号退出登录失败,参数错误,id不得为空");
}
return ResultInfo.success(true);
}
/**
* 注销app账号
* @param userApp app账号
* @return ResultInfo
*/
@Log
@PostMapping(value = "/appCancellation")
@ApiOperation("注销app账号")
@AnonymousAccess
public ResultInfo appCancellation(@Validated @RequestBody UserApp userApp) {
log.info("注销app账号,参数 ==>> [appCancellation#{}]", userApp.getId());
if (Objects.isNull(userApp.getId())) {
log.error("注销app账号失败,参数错误,id不得为空,[appCancellation#]");
return ResultInfo.failure("");
}
boolean result = this.userOperationService.appCancellation(userApp);
return ResultInfo.success(result);
}
@Log
@PostMapping(value = "/updateAppInfo")
@ApiOperation("修改app账号信息")
......@@ -85,6 +131,14 @@ public class UserOperationController {
return ResultInfo.failure("修改app账号密码失败,参数错误,id不得为空");
}
String headimgurl = resources.getHeadimgurl();
log.info("前端头像地址 ==>> [updateAppInfo#{}]", headimgurl);
if (StringUtils.isNotBlank(headimgurl) && (headimgurl.contains("http") || headimgurl.contains("https"))) {
String image = RestTemplateClient.netImage(headimgurl);
log.info("图片本地化后的图片地址 ==>> [updateAppInfo#{}]", image);
resources.setHeadimgurl(image);
}
UserAppSimpleDTO result = this.userOperationService.updateAppInfo(resources);
return ResultInfo.success(result);
}
......@@ -224,6 +278,27 @@ public class UserOperationController {
/******************************************************* weixin ************************************/
@Log
@PostMapping(value = "/saveGrowthReport")
@ApiOperation("同步大屏成长报告")
@AnonymousAccess
public ResultInfo saveGrowthReport(@Validated @RequestBody String resources) {
log.info("同步大屏成长报告失败,参数 ==>> [saveGrowthReport#{}]", resources);
GrowthReportRequest growthReportRequest = JSON.parseObject(new String(Base64Utils.decode(resources.getBytes())), GrowthReportRequest.class);
String platformAccount = growthReportRequest.getPlatformAccount();
List<GrowthReportRequest.CategoryContent> playDurationWithCategory = growthReportRequest.getPlayDurationWithCategory();
if (!CollectionUtils.isEmpty(playDurationWithCategory)) {
GrowthReport growthReport = new GrowthReport();
growthReport.setPlatformAccount(platformAccount);
growthReport.setData(JSONArray.toJSONString(playDurationWithCategory));
boolean result = this.userOperationService.saveGrowthReport(growthReport);
return ResultInfo.success(result);
}
return ResultInfo.failure("保存失败");
}
@PutMapping(value = "/updateWeixin")
@ApiOperation("修改UserWeixin")
@AnonymousAccess
......
......@@ -6,6 +6,7 @@ import com.topdraw.business.module.user.app.domain.UserAppBind;
import com.topdraw.business.module.user.app.service.dto.UserAppDTO;
import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO;
import com.topdraw.business.module.user.iptv.domain.UserTv;
import com.topdraw.business.module.user.iptv.growreport.domain.GrowthReport;
import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.module.user.weixin.domain.UserWeixin;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
......@@ -206,4 +207,14 @@ public interface UserOperationService {
* @return
*/
boolean updatePasswordById(UserApp resources);
/**
*
* @param growthReport
* @return
*/
boolean saveGrowthReport(GrowthReport growthReport);
boolean appCancellation(UserApp userApp);
}
......
......@@ -21,6 +21,9 @@ import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO;
import com.topdraw.business.module.user.iptv.domain.UserConstant;
import com.topdraw.business.module.user.iptv.domain.UserTv;
import com.topdraw.business.module.user.iptv.domain.UserTvBuilder;
import com.topdraw.business.module.user.iptv.growreport.domain.GrowthReport;
import com.topdraw.business.module.user.iptv.growreport.service.GrowthReportService;
import com.topdraw.business.module.user.iptv.growreport.service.dto.GrowthReportDTO;
import com.topdraw.business.module.user.iptv.service.UserTvService;
import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.module.user.iptv.service.dto.UserTvSimpleDTO;
......@@ -69,6 +72,7 @@ import org.springframework.util.CollectionUtils;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
......@@ -88,6 +92,8 @@ public class UserOperationServiceImpl implements UserOperationService {
@Autowired
private UserAppBindService userAppBindService;
@Autowired
private GrowthReportService growthReportService;
@Autowired
private UserWeixinRepository userWeixinRepository;
@Autowired
private UserCollectionService userCollectionService;
......@@ -192,6 +198,59 @@ public class UserOperationServiceImpl implements UserOperationService {
return this.userAppService.updatePasswordById(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean saveGrowthReport(GrowthReport growthReport) {
String platformAccount = growthReport.getPlatformAccount();
UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
if (Objects.isNull(userTvDTO.getId())) {
log.error("保存成长报告失败,大屏信息不存在[saveGrowthReport#]");
return false;
}
String weekFirstDay = com.topdraw.util.DateUtil.getWeekFirstDay();
String weekLastDay = com.topdraw.util.DateUtil.getWeekLastDay();
GrowthReportDTO growthReportDTO = this.growthReportService.findByPlatformAccountAndStartDateAndEndDate(platformAccount, weekFirstDay, weekLastDay);
if (Objects.isNull(growthReportDTO.getId())) {
Long id = userTvDTO.getId();
Long memberId = userTvDTO.getMemberId();
growthReport.setUserId(id);
growthReport.setMemberId(memberId);
growthReport.setStartDate(weekFirstDay);
growthReport.setEndDate(weekLastDay);
this.growthReportService.create(growthReport);
} else {
this.growthReportService.updateGrowthReportData(growthReportDTO.getId(), growthReport.getData());
}
((UserOperationServiceImpl)AopContext.currentProxy()).asyncsaveGrowthReport(growthReport);
return false;
}
@Override
public boolean appCancellation(UserApp userApp) {
UserAppDTO userAppDTO = this.userAppService.findById(userApp.getId());
if (Objects.nonNull(userAppDTO.getId())){
boolean b = this.userAppService.appCancellation(userApp.getId());
if (b) {
List<UserAppBindDTO> userAppBindDTOS = this.userAppBindService.findByUserAppId(userAppDTO.getId());
if (!CollectionUtils.isEmpty(userAppBindDTOS)) {
List<Long> ids = userAppBindDTOS.stream().map(t -> t.getId()).collect(Collectors.toList());
this.userAppBindService.appCancellation(ids);
}
}
}
return true;
}
/**
* 创建大屏账户同时创建会员
*
......@@ -1494,7 +1553,8 @@ public class UserOperationServiceImpl implements UserOperationService {
}
@AsyncMqSend
public void asyncsaveGrowthReport(GrowthReport growthReport) {}
@AsyncMqSend
public void asyncMemberAndUserWeixin4Iptv(MemberAndWeixinUserDTO memberAndWeixinUserDTO) {}
@AsyncMqSend
......
......@@ -2,6 +2,8 @@ package com.topdraw.business.process.service.impl.member;
import cn.hutool.core.util.ObjectUtil;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.module.member.address.service.MemberAddressService;
import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.profile.service.MemberProfileService;
import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
......@@ -44,6 +46,8 @@ public class MemberOperationServiceImpl implements MemberOperationService {
private MemberProfileService memberProfileService;
@Autowired
private MemberVipHistoryService memberVipHistoryService;
@Autowired
private MemberAddressService memberAddressService;
@AsyncMqSend
public void asyncUpdateMemberVipAndVipExpireTime(MemberDTO memberDTO) {}
......@@ -151,7 +155,22 @@ public class MemberOperationServiceImpl implements MemberOperationService {
return count;
}
@Override
public MemberAddressDTO updateDefaultMemberAddressById(Long id) {
MemberAddressDTO memberAddressDTO = this.memberAddressService.findById(id);
if (Objects.nonNull(memberAddressDTO.getId())) {
Long memberId = memberAddressDTO.getMemberId();
Integer _count = this.memberAddressService.updateUnDefaultMemberAddressByMemberId(memberId);
if (_count > 0) {
Integer count = this.memberAddressService.updateDefaultMemberAddressById(id);
if (count > 0 ) {
return this.memberAddressService.findById(id);
}
}
}
return null;
}
@Override
......
package com.topdraw.business.process.service.member;
import com.topdraw.business.module.member.address.service.dto.MemberAddressDTO;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
import com.topdraw.business.module.member.service.dto.MemberDTO;
......@@ -78,4 +79,5 @@ public interface MemberOperationService {
Integer doUpdateGroupsBatch(List<Member> resources);
MemberAddressDTO updateDefaultMemberAddressById(Long memberId);
}
......
package com.topdraw.util;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
......@@ -174,6 +175,29 @@ public class DateUtil {
return calendar.getTimeInMillis();
}
public static String getWeekFirstDay() {
SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar1=Calendar.getInstance();
calendar1.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
System.out.println("本周日: "+sdf.format(calendar1.getTime()));
return sdf.format(calendar1.getTime());
}
public static String getWeekLastDay() {
SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar1=Calendar.getInstance();
calendar1.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
System.out.println("本周六: "+sdf.format(calendar1.getTime()));
return sdf.format(calendar1.getTime());
}
/**
* 时间戳转字符串
*
......@@ -188,6 +212,10 @@ public class DateUtil {
}
public static void main(String[] args) {
String weekFirstDay = getWeekFirstDay();
System.out.println(weekFirstDay);
String weekLastDay = getWeekLastDay();
System.out.println(weekLastDay);
/*Long currentTime = System.currentTimeMillis();
System.out.println("Current Time : " + currentTime + " = " + timestampToStr(currentTime, "GMT+8"));
Long dailyStart = getDailyStartTime(currentTime, "GMT+8:00");
......@@ -201,7 +229,8 @@ public class DateUtil {
System.out.println("Month Start : " + monthStart + " = " + timestampToStr(monthStart, "GMT+8") + " Month End : " + monthEnd + " = " + timestampToStr(monthEnd, "GMT+8"));
System.out.println("Year Start : " + yearStart + " = " + timestampToStr(yearStart, "GMT+8") + " Year End : " + yearEnd + " = " + timestampToStr(yearEnd, "GMT+8"));
*/
LocalDateTime lastDateTimeCurrentYear = getLastDateTimeSecondYear();
// LocalDateTime lastDateTimeCurrentYear = getLastDateTimeSecondYear();
}
}
......
......@@ -39,14 +39,14 @@ public class GeneratorCode extends BaseTest {
@Rollback(value = false)
@Transactional(rollbackFor = Exception.class)
public void generator() {
var dbName = "uc_user_app_bind";
var dbName = "uc_growth_report";
// 表名称,支持多表
var tableNames = Arrays.asList(dbName);
String[] s = dbName.split("_");
var pre = s[0];
var target1 = s[s.length-1];
var preRoute = "com.topdraw.business.module.user.app";
var preRoute = "com.topdraw.business.module.user.iptv.growreport";
StringBuilder builder = new StringBuilder(preRoute);
// builder.append("wechatshare");
// builder.append(target);
......