init
This commit is contained in:
@@ -16,7 +16,6 @@
|
|||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- spring-boot-devtools -->
|
<!-- spring-boot-devtools -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ springdoc:
|
|||||||
api-docs:
|
api-docs:
|
||||||
# 是否开启接口文档
|
# 是否开启接口文档
|
||||||
enabled: true
|
enabled: true
|
||||||
# swagger-ui:
|
# swagger-ui:
|
||||||
# # 持久化认证数据
|
# # 持久化认证数据
|
||||||
# persistAuthorization: true
|
# persistAuthorization: true
|
||||||
info:
|
info:
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package com.ruoyi.cai.controller.app;
|
||||||
|
|
||||||
|
import com.ruoyi.cai.dto.app.query.*;
|
||||||
|
import com.ruoyi.cai.dto.app.vo.*;
|
||||||
|
import com.ruoyi.cai.manager.CurrentUserManager;
|
||||||
|
import com.ruoyi.cai.service.CaiUserAlbumService;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.common.helper.LoginHelper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/current")
|
||||||
|
public class CaiCurrentUserAppController {
|
||||||
|
@Autowired
|
||||||
|
private CurrentUserManager currentUserManager;
|
||||||
|
@Autowired
|
||||||
|
private CaiUserAlbumService userAlbumService;
|
||||||
|
@GetMapping("/user/info")
|
||||||
|
public R<CurrentUserInfoVo> currentInfo(){
|
||||||
|
return R.ok(currentUserManager.currentInfo());
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/user/account")
|
||||||
|
public R<UserAccountVo> currentAccount(){
|
||||||
|
return R.ok(currentUserManager.currentAccount());
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/anchor/info")
|
||||||
|
public R<AnchorVo> anchorInfo(){
|
||||||
|
return R.ok(currentUserManager.anchorInfo());
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/anchor/update")
|
||||||
|
public R<Boolean> anchorUpdate(AnchorUpdateRes anchorUpdate){
|
||||||
|
return R.ok(currentUserManager.anchorUpdate(anchorUpdate));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/user/update")
|
||||||
|
public R<Boolean> userUpdate(UserUpdateRes res){
|
||||||
|
return R.ok(currentUserManager.userUpdate(res));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/user/album/del")
|
||||||
|
public R<Boolean> userAlbumDel(IdRes res){
|
||||||
|
return R.ok(userAlbumService.removeAlbum(res.getId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/user/album/add")
|
||||||
|
public R<Boolean> userAlbumAdd(AlbumAddRes res){
|
||||||
|
res.setUserId(LoginHelper.getUserId());
|
||||||
|
return R.ok(userAlbumService.addAlbum(res));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/user/album/reset")
|
||||||
|
public R<Boolean> userAlbumAdd(List<AlbumResetRes> res){
|
||||||
|
return R.ok(userAlbumService.resetAlbum(res,LoginHelper.getUserId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,12 +22,6 @@ public class CaiUserAppController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CaiUserService caiUserService;
|
private CaiUserService caiUserService;
|
||||||
|
|
||||||
@GetMapping("/current/info")
|
|
||||||
public R<LoginUser> currentInfo(){
|
|
||||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
|
||||||
return R.ok(loginUser);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
public TableDataInfo<UserListVo> page(PageQuery page, UserQuery query){
|
public TableDataInfo<UserListVo> page(PageQuery page, UserQuery query){
|
||||||
Page<UserListVo> res = caiUserService.pageApp(page,query);
|
Page<UserListVo> res = caiUserService.pageApp(page,query);
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public class CaiAccount implements Serializable {
|
|||||||
* 收益的彩币数量
|
* 收益的彩币数量
|
||||||
*/
|
*/
|
||||||
private Long incomeCoin;
|
private Long incomeCoin;
|
||||||
|
private Long totalCoin;
|
||||||
/**
|
/**
|
||||||
* 当前魅力值
|
* 当前魅力值
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import java.time.LocalDateTime;
|
|||||||
/**
|
/**
|
||||||
* 主播集锦对象 cai_user_album
|
* 主播集锦对象 cai_user_album
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author 77
|
||||||
* @date 2023-12-23
|
* @date 2023-12-23
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@@ -49,6 +49,8 @@ public class CaiUserAlbum implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Integer isAnchor;
|
private Integer isAnchor;
|
||||||
|
|
||||||
|
private Integer orderBy;
|
||||||
|
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.ruoyi.cai.dto.app.query;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AlbumAddRes {
|
||||||
|
private Long userId;
|
||||||
|
private String url;
|
||||||
|
private Integer orderBy;
|
||||||
|
// private boolean first;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.ruoyi.cai.dto.app.query;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AlbumResetRes {
|
||||||
|
private Long id;
|
||||||
|
private Integer orderBy;
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.ruoyi.cai.dto.app.query;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AnchorUpdateRes {
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 价格,默认50彩币
|
||||||
|
*/
|
||||||
|
private Long price;
|
||||||
|
/**
|
||||||
|
* 开启视频接听 0 未开启 1 已开启
|
||||||
|
*/
|
||||||
|
private Integer openVideoStatus;
|
||||||
|
/**
|
||||||
|
* 是否隐藏接单次数 1隐藏 2不隐藏
|
||||||
|
*/
|
||||||
|
private Integer orderSwitch;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.ruoyi.cai.dto.app.query;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class IdRes {
|
||||||
|
private Long id;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.ruoyi.cai.dto.app.query;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UserUpdateRes {
|
||||||
|
private Long userId;
|
||||||
|
private String city;
|
||||||
|
private String nickname;
|
||||||
|
private LocalDateTime birthday;
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.ruoyi.cai.dto.app.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AnchorVo {
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 技能ID
|
||||||
|
*/
|
||||||
|
private Integer skillId;
|
||||||
|
/**
|
||||||
|
* 价格,默认50彩币
|
||||||
|
*/
|
||||||
|
private Long price;
|
||||||
|
/**
|
||||||
|
* 是否隐藏接单次数 1隐藏 2不隐藏
|
||||||
|
*/
|
||||||
|
private Integer orderSwitch;
|
||||||
|
/**
|
||||||
|
* 开启视频接听 0 未开启 1 已开启
|
||||||
|
*/
|
||||||
|
private Integer openVideoStatus;
|
||||||
|
/**
|
||||||
|
* 用户评分
|
||||||
|
*/
|
||||||
|
private BigDecimal giveScore;
|
||||||
|
/**
|
||||||
|
* 服务总次数
|
||||||
|
*/
|
||||||
|
private Long serviceCount;
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package com.ruoyi.cai.dto.app.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CurrentUserInfoVo {
|
||||||
|
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户号/ID号
|
||||||
|
*/
|
||||||
|
private String usercode;
|
||||||
|
/**
|
||||||
|
* 昵称
|
||||||
|
*/
|
||||||
|
private String nickname;
|
||||||
|
/**
|
||||||
|
* 手机号
|
||||||
|
*/
|
||||||
|
private String mobile;
|
||||||
|
/**
|
||||||
|
* 头像
|
||||||
|
*/
|
||||||
|
private String avatar;
|
||||||
|
/**
|
||||||
|
* 头像状态,0 系统默认头像,1 用户自定义头像
|
||||||
|
*/
|
||||||
|
private Integer avatarState;
|
||||||
|
/**
|
||||||
|
* 性别 0 未知 1 女 2 男
|
||||||
|
*/
|
||||||
|
private Integer gender;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private LocalDateTime birthday;
|
||||||
|
/**
|
||||||
|
* 城市
|
||||||
|
*/
|
||||||
|
private Long city;
|
||||||
|
/**
|
||||||
|
* 是否是播主 0 否 1 是
|
||||||
|
*/
|
||||||
|
private Integer isAnchor;
|
||||||
|
/**
|
||||||
|
* 开启视频接听 0 未开启 1 已开启
|
||||||
|
*/
|
||||||
|
private Integer openVideoStatus;
|
||||||
|
/**
|
||||||
|
* 状态 0 可用 1 不可用
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 相册
|
||||||
|
*/
|
||||||
|
private List<UserAlbumDTO> userAlbumList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户账户
|
||||||
|
*/
|
||||||
|
private UserAccountVo userAccount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户统计
|
||||||
|
*/
|
||||||
|
private UserCountVo userCount;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.ruoyi.cai.dto.app.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UserAccountVo {
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 当前彩币数量
|
||||||
|
*/
|
||||||
|
private Long coin;
|
||||||
|
/**
|
||||||
|
* 收益的彩币数量
|
||||||
|
*/
|
||||||
|
private Long incomeCoin;
|
||||||
|
|
||||||
|
private Long totalCoin;
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package com.ruoyi.cai.dto.app.vo;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UserAlbumDTO {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@TableId(value = "id")
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private String url;
|
||||||
|
/**
|
||||||
|
* 状态 0 未审核 1 审核通过 2 审核未通过
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
/**
|
||||||
|
* 审核时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime auditTime;
|
||||||
|
/**
|
||||||
|
* 审核备注
|
||||||
|
*/
|
||||||
|
private String auditRemark;
|
||||||
|
|
||||||
|
private Integer orderBy;
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.ruoyi.cai.dto.app.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UserCountVo {
|
||||||
|
private Long userId;
|
||||||
|
/**
|
||||||
|
* 粉丝总数
|
||||||
|
*/
|
||||||
|
private Long fansCount;
|
||||||
|
/**
|
||||||
|
* 关注数
|
||||||
|
*/
|
||||||
|
private Long followCount;
|
||||||
|
/**
|
||||||
|
* 足迹数
|
||||||
|
*/
|
||||||
|
private Long footCount;
|
||||||
|
/**
|
||||||
|
* 访客数
|
||||||
|
*/
|
||||||
|
private Long visitorCount;
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
package com.ruoyi.cai.manager;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.ruoyi.cai.domain.*;
|
||||||
|
import com.ruoyi.cai.dto.app.query.AnchorUpdateRes;
|
||||||
|
import com.ruoyi.cai.dto.app.query.UserUpdateRes;
|
||||||
|
import com.ruoyi.cai.dto.app.vo.*;
|
||||||
|
import com.ruoyi.cai.service.*;
|
||||||
|
import com.ruoyi.common.helper.LoginHelper;
|
||||||
|
import com.ruoyi.common.utils.BeanConvertUtil;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class CurrentUserManager {
|
||||||
|
@Autowired
|
||||||
|
private CaiUserService userService;
|
||||||
|
@Autowired
|
||||||
|
private CaiAnchorService anchorService;
|
||||||
|
@Autowired
|
||||||
|
private CaiUserCountService userCountService;
|
||||||
|
@Autowired
|
||||||
|
private CaiUserAlbumService userAlbumService;
|
||||||
|
@Autowired
|
||||||
|
private CaiAccountService accountService;
|
||||||
|
|
||||||
|
public CurrentUserInfoVo currentInfo() {
|
||||||
|
Long userId = LoginHelper.getUserId();
|
||||||
|
CaiUser user = userService.getById(userId);
|
||||||
|
CurrentUserInfoVo res = BeanConvertUtil.convertTo(user, CurrentUserInfoVo::new);
|
||||||
|
CaiAnchor anchor = anchorService.getByUserId(userId);
|
||||||
|
res.setOpenVideoStatus(anchor.getOpenVideoStatus());
|
||||||
|
CaiUserCount userCount = userCountService.getByUserId(userId);
|
||||||
|
res.setUserCount(BeanConvertUtil.convertTo(userCount, UserCountVo::new));
|
||||||
|
CaiAccount account = accountService.getByUserId(userId);
|
||||||
|
res.setUserAccount(BeanConvertUtil.convertTo(account,UserAccountVo::new));
|
||||||
|
List<CaiUserAlbum> userAlbums = userAlbumService.listByUserId(userId);
|
||||||
|
res.setUserAlbumList(BeanConvertUtil.convertListTo(userAlbums, UserAlbumDTO::new));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserAccountVo currentAccount(){
|
||||||
|
Long userId = LoginHelper.getUserId();
|
||||||
|
CaiAccount account = accountService.getByUserId(userId);
|
||||||
|
return BeanConvertUtil.convertTo(account,UserAccountVo::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AnchorVo anchorInfo() {
|
||||||
|
Long userId = LoginHelper.getUserId();
|
||||||
|
CaiAnchor anchor = anchorService.getByUserId(userId);
|
||||||
|
return BeanConvertUtil.convertTo(anchor,AnchorVo::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean anchorUpdate(AnchorUpdateRes anchorUpdate) {
|
||||||
|
anchorUpdate.setUserId(LoginHelper.getUserId());
|
||||||
|
boolean updateFlag = false;
|
||||||
|
LambdaUpdateWrapper<CaiAnchor> update =
|
||||||
|
Wrappers.lambdaUpdate(CaiAnchor.class).eq(CaiAnchor::getUserId, anchorUpdate.getUserId());
|
||||||
|
if(anchorUpdate.getPrice() != null){
|
||||||
|
update.set(CaiAnchor::getPrice,anchorUpdate.getPrice());
|
||||||
|
updateFlag=true;
|
||||||
|
}
|
||||||
|
if(anchorUpdate.getOrderSwitch() != null){
|
||||||
|
update.set(CaiAnchor::getOrderSwitch,anchorUpdate.getOrderSwitch());
|
||||||
|
updateFlag=true;
|
||||||
|
}
|
||||||
|
if(anchorUpdate.getOpenVideoStatus() != null){
|
||||||
|
update.set(CaiAnchor::getOpenVideoStatus,anchorUpdate.getOpenVideoStatus());
|
||||||
|
updateFlag=true;
|
||||||
|
}
|
||||||
|
if(updateFlag){
|
||||||
|
return anchorService.update(update);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean userUpdate(UserUpdateRes res) {
|
||||||
|
res.setUserId(LoginHelper.getUserId());
|
||||||
|
boolean updateFlag = false;
|
||||||
|
LambdaUpdateWrapper<CaiUser> update =
|
||||||
|
Wrappers.lambdaUpdate(CaiUser.class).eq(CaiUser::getId, res.getUserId());
|
||||||
|
if(StringUtils.isNotEmpty(res.getNickname())){
|
||||||
|
update.set(CaiUser::getNickname,res.getNickname());
|
||||||
|
updateFlag=true;
|
||||||
|
}
|
||||||
|
if(res.getBirthday() != null){
|
||||||
|
update.set(CaiUser::getBirthday,res.getBirthday());
|
||||||
|
updateFlag=true;
|
||||||
|
}
|
||||||
|
if(StringUtils.isNotEmpty(res.getCity())){
|
||||||
|
update.set(CaiUser::getCity,res.getCity());
|
||||||
|
updateFlag=true;
|
||||||
|
}
|
||||||
|
if(updateFlag){
|
||||||
|
return userService.update(update);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,4 +13,6 @@ import org.apache.ibatis.annotations.Param;
|
|||||||
public interface CaiAccountMapper extends BaseMapper<CaiAccount> {
|
public interface CaiAccountMapper extends BaseMapper<CaiAccount> {
|
||||||
|
|
||||||
boolean incs(@Param("userId") Long userId, @Param("value") Long value);
|
boolean incs(@Param("userId") Long userId, @Param("value") Long value);
|
||||||
|
|
||||||
|
void incsCoin(@Param("userId") Long userId, @Param("coin") Long coin, @Param("incomeCoin") Long incomeCoin);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,4 +14,6 @@ public interface CaiAccountService extends IService<CaiAccount> {
|
|||||||
CaiAccount getByUserId(Long userId);
|
CaiAccount getByUserId(Long userId);
|
||||||
|
|
||||||
boolean incs(Long userId, Long value);
|
boolean incs(Long userId, Long value);
|
||||||
|
|
||||||
|
boolean decr(Long userId, Long value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,17 +2,27 @@ package com.ruoyi.cai.service;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.ruoyi.cai.domain.CaiUserAlbum;
|
import com.ruoyi.cai.domain.CaiUserAlbum;
|
||||||
|
import com.ruoyi.cai.dto.app.query.AlbumAddRes;
|
||||||
|
import com.ruoyi.cai.dto.app.query.AlbumResetRes;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主播集锦Service接口
|
* 主播集锦Service接口
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author 77
|
||||||
* @date 2023-12-23
|
* @date 2023-12-23
|
||||||
*/
|
*/
|
||||||
public interface CaiUserAlbumService extends IService<CaiUserAlbum> {
|
public interface CaiUserAlbumService extends IService<CaiUserAlbum> {
|
||||||
|
|
||||||
|
|
||||||
List<String> getUserAlbum(Long userId, Integer anchor);
|
List<String> getUserAlbum(Long userId, Integer anchor);
|
||||||
|
|
||||||
|
List<CaiUserAlbum> listByUserId(Long userId);
|
||||||
|
|
||||||
|
boolean addAlbum(AlbumAddRes res);
|
||||||
|
|
||||||
|
boolean removeAlbum(Long id);
|
||||||
|
|
||||||
|
boolean resetAlbum(List<AlbumResetRes> res, Long userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,4 +15,6 @@ public interface CaiUserCountService extends IService<CaiUserCount> {
|
|||||||
void visitor(Long fromUserId,Long toUserId);
|
void visitor(Long fromUserId,Long toUserId);
|
||||||
void reset(Long userId);
|
void reset(Long userId);
|
||||||
void resetAsync(Long userId);
|
void resetAsync(Long userId);
|
||||||
|
|
||||||
|
CaiUserCount getByUserId(Long userId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import com.ruoyi.cai.domain.CaiAccount;
|
import com.ruoyi.cai.domain.CaiAccount;
|
||||||
import com.ruoyi.cai.mapper.CaiAccountMapper;
|
import com.ruoyi.cai.mapper.CaiAccountMapper;
|
||||||
import com.ruoyi.cai.service.CaiAccountService;
|
import com.ruoyi.cai.service.CaiAccountService;
|
||||||
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户账户Service业务层处理
|
* 用户账户Service业务层处理
|
||||||
@@ -16,6 +18,7 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class CaiAccountServiceImpl extends ServiceImpl<CaiAccountMapper,CaiAccount> implements CaiAccountService {
|
public class CaiAccountServiceImpl extends ServiceImpl<CaiAccountMapper,CaiAccount> implements CaiAccountService {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CaiAccount getByUserId(Long userId) {
|
public CaiAccount getByUserId(Long userId) {
|
||||||
return this.getOne(Wrappers.lambdaQuery(CaiAccount.class).eq(CaiAccount::getUserId,userId).last("limit 1"));
|
return this.getOne(Wrappers.lambdaQuery(CaiAccount.class).eq(CaiAccount::getUserId,userId).last("limit 1"));
|
||||||
@@ -25,4 +28,25 @@ public class CaiAccountServiceImpl extends ServiceImpl<CaiAccountMapper,CaiAccou
|
|||||||
public boolean incs(Long userId, Long value) {
|
public boolean incs(Long userId, Long value) {
|
||||||
return baseMapper.incs(userId,value);
|
return baseMapper.incs(userId,value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public boolean decr(Long userId, Long value) {
|
||||||
|
CaiAccount account = this.getByUserId(userId);
|
||||||
|
if(account.getTotalCoin() < value){
|
||||||
|
throw new ServiceException("余额不足");
|
||||||
|
}
|
||||||
|
boolean incs = baseMapper.incs(userId, -value);
|
||||||
|
if(!incs){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
CaiAccount newAccount = this.getByUserId(userId);
|
||||||
|
Long decrCoinFlag = newAccount.getCoin() - value;
|
||||||
|
if(decrCoinFlag >= 0){
|
||||||
|
baseMapper.incsCoin(userId, -value,0L);
|
||||||
|
}else{
|
||||||
|
baseMapper.incsCoin(userId, -newAccount.getCoin(), decrCoinFlag);
|
||||||
|
}
|
||||||
|
return incs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,11 +51,7 @@ public class CaiGuardTotalServiceImpl extends ServiceImpl<CaiGuardTotalMapper,Ca
|
|||||||
throw new ServiceException("只能给女神送守护");
|
throw new ServiceException("只能给女神送守护");
|
||||||
}
|
}
|
||||||
Long guardValue = query.getGuardNum() * GUARD_UNIT_PRICE;
|
Long guardValue = query.getGuardNum() * GUARD_UNIT_PRICE;
|
||||||
CaiAccount account = accountService.getByUserId(fromUserId);
|
boolean boo = accountService.decr(fromUserId, -guardValue);
|
||||||
if(account.getCoin() < guardValue){
|
|
||||||
throw new ServiceException("余额不足");
|
|
||||||
}
|
|
||||||
boolean boo = accountService.incs(fromUserId, -guardValue);
|
|
||||||
if(!boo){
|
if(!boo){
|
||||||
throw new ServiceException("余额不足");
|
throw new ServiceException("余额不足");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,25 +3,32 @@ package com.ruoyi.cai.service.impl;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.ruoyi.cai.domain.CaiUser;
|
||||||
import com.ruoyi.cai.domain.CaiUserAlbum;
|
import com.ruoyi.cai.domain.CaiUserAlbum;
|
||||||
|
import com.ruoyi.cai.dto.app.query.AlbumAddRes;
|
||||||
|
import com.ruoyi.cai.dto.app.query.AlbumResetRes;
|
||||||
import com.ruoyi.cai.mapper.CaiUserAlbumMapper;
|
import com.ruoyi.cai.mapper.CaiUserAlbumMapper;
|
||||||
import com.ruoyi.cai.service.CaiUserAlbumService;
|
import com.ruoyi.cai.service.CaiUserAlbumService;
|
||||||
|
import com.ruoyi.cai.service.CaiUserService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主播集锦Service业务层处理
|
* 主播集锦Service业务层处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author 77
|
||||||
* @date 2023-12-23
|
* @date 2023-12-23
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class CaiUserAlbumServiceImpl extends ServiceImpl<CaiUserAlbumMapper, CaiUserAlbum> implements CaiUserAlbumService {
|
public class CaiUserAlbumServiceImpl extends ServiceImpl<CaiUserAlbumMapper, CaiUserAlbum> implements CaiUserAlbumService {
|
||||||
|
@Autowired
|
||||||
|
private CaiUserService userService;
|
||||||
@Override
|
@Override
|
||||||
public List<String> getUserAlbum(Long userId,Integer anchor){
|
public List<String> getUserAlbum(Long userId,Integer anchor){
|
||||||
LambdaQueryWrapper<CaiUserAlbum> eq = Wrappers.lambdaQuery(CaiUserAlbum.class)
|
LambdaQueryWrapper<CaiUserAlbum> eq = Wrappers.lambdaQuery(CaiUserAlbum.class)
|
||||||
@@ -35,4 +42,57 @@ public class CaiUserAlbumServiceImpl extends ServiceImpl<CaiUserAlbumMapper, Cai
|
|||||||
List<CaiUserAlbum> list = this.list(eq);
|
List<CaiUserAlbum> list = this.list(eq);
|
||||||
return list.stream().map(CaiUserAlbum::getUrl).collect(Collectors.toList());
|
return list.stream().map(CaiUserAlbum::getUrl).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CaiUserAlbum> listByUserId(Long userId) {
|
||||||
|
return this.list(Wrappers.lambdaQuery(CaiUserAlbum.class).eq(CaiUserAlbum::getUserId,userId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addAlbum(AlbumAddRes res) {
|
||||||
|
CaiUser user = userService.getById(res.getUserId());
|
||||||
|
CaiUserAlbum album = new CaiUserAlbum();
|
||||||
|
album.setUserId(res.getUserId());
|
||||||
|
album.setUrl(res.getUrl());
|
||||||
|
album.setIsAnchor(user.getIsAnchor());
|
||||||
|
album.setOrderBy(res.getOrderBy());
|
||||||
|
this.save(album);
|
||||||
|
if(user.getIsAnchor() == 1 && res.getOrderBy() == 0){
|
||||||
|
userService.update(Wrappers.lambdaUpdate(CaiUser.class)
|
||||||
|
.eq(CaiUser::getId,res.getUserId())
|
||||||
|
.set(CaiUser::getAvatar,res.getUrl()));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean removeAlbum(Long id){
|
||||||
|
return this.removeById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean resetAlbum(List<AlbumResetRes> res, Long userId) {
|
||||||
|
CaiUser user = userService.getById(userId);
|
||||||
|
List<CaiUserAlbum> update = new ArrayList<>();
|
||||||
|
Long id = null;
|
||||||
|
for (AlbumResetRes re : res) {
|
||||||
|
CaiUserAlbum album = new CaiUserAlbum();
|
||||||
|
album.setId(re.getId());
|
||||||
|
album.setOrderBy(re.getOrderBy());
|
||||||
|
update.add(album);
|
||||||
|
if(re.getOrderBy() == 0){
|
||||||
|
id = re.getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.updateBatchById(update);
|
||||||
|
if(id != null){
|
||||||
|
CaiUserAlbum album = this.getById(id);
|
||||||
|
if(album != null && (album.getIsAnchor() == 1 || album.getStatus() == 1)){
|
||||||
|
userService.update(Wrappers.lambdaUpdate(CaiUser.class)
|
||||||
|
.eq(CaiUser::getId,album.getUserId())
|
||||||
|
.set(CaiUser::getAvatar,album.getUrl()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,4 +87,9 @@ public class CaiUserCountServiceImpl extends ServiceImpl<CaiUserCountMapper,CaiU
|
|||||||
public void resetAsync(Long userId) {
|
public void resetAsync(Long userId) {
|
||||||
ExecutorConstant.SYNC_EXECUTOR.execute(() -> reset(userId));
|
ExecutorConstant.SYNC_EXECUTOR.execute(() -> reset(userId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CaiUserCount getByUserId(Long userId) {
|
||||||
|
return this.getOne(Wrappers.lambdaQuery(CaiUserCount.class).eq(CaiUserCount::getUserId,userId).last("limit 1"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,11 +47,7 @@ public class CaiUserGiftServiceImpl extends ServiceImpl<CaiUserGiftMapper,CaiUse
|
|||||||
}
|
}
|
||||||
Long price = gift.getPrice();
|
Long price = gift.getPrice();
|
||||||
Long giftAmount = query.getGiftCount() * price;
|
Long giftAmount = query.getGiftCount() * price;
|
||||||
CaiAccount account = accountService.getByUserId(fromUserId);
|
boolean boo = accountService.decr(fromUserId, -giftAmount);
|
||||||
if(account.getCoin() < giftAmount){
|
|
||||||
throw new ServiceException("余额不足");
|
|
||||||
}
|
|
||||||
boolean boo = accountService.incs(fromUserId, -giftAmount);
|
|
||||||
if(!boo){
|
if(!boo){
|
||||||
throw new ServiceException("余额不足");
|
throw new ServiceException("余额不足");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
<update id="incs">
|
<update id="incs">
|
||||||
update cai_account
|
update cai_account
|
||||||
set coin = coin + #{value}
|
set total_coin = total_coin + #{value}
|
||||||
|
where user_id = #{userId} and (total_coin + #{value}) > 0
|
||||||
|
</update>
|
||||||
|
<update id="incsCoin">
|
||||||
|
update cai_account
|
||||||
|
set coin = coin + #{coin}, income_coin = income_coin + #{incomeCoin}
|
||||||
where user_id = #{userId}
|
where user_id = #{userId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user