代码优化
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
package com.starry.admin.modules.custom.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.starry.admin.modules.custom.entity.PlayCustomFollowInfoEntity;
|
||||
import com.starry.admin.modules.custom.service.IPlayCustomFollowInfoService;
|
||||
import com.starry.common.annotation.Log;
|
||||
import com.starry.common.enums.BusinessType;
|
||||
import com.starry.common.result.R;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 顾客关注陪聊信息Controller
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024-04-30
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/play/follow")
|
||||
public class PlayCustomFollowInfoController {
|
||||
@Resource
|
||||
private IPlayCustomFollowInfoService playCustomFollowInfoService;
|
||||
|
||||
/**
|
||||
* 查询顾客关注陪聊信息列表
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:info:list')")
|
||||
@GetMapping("/list")
|
||||
public R list(PlayCustomFollowInfoEntity playCustomFollowInfo) {
|
||||
IPage<PlayCustomFollowInfoEntity> list = playCustomFollowInfoService.selectPlayCustomFollowInfoByPage(playCustomFollowInfo);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取顾客关注陪聊信息详细信息
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:info:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public R getInfo(@PathVariable("id") String id) {
|
||||
return R.ok(playCustomFollowInfoService.selectPlayCustomFollowInfoById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增顾客关注陪聊信息
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:info:create')")
|
||||
@Log(title = "顾客关注陪聊信息", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/create")
|
||||
public R create(@RequestBody PlayCustomFollowInfoEntity playCustomFollowInfo) {
|
||||
boolean success = playCustomFollowInfoService.create(playCustomFollowInfo);
|
||||
if (success) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("添加失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改顾客关注陪聊信息
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:info:edit')")
|
||||
@Log(title = "顾客关注陪聊信息", businessType = BusinessType.UPDATE)
|
||||
@PostMapping(value = "/update/{id}")
|
||||
public R update(@PathVariable String id, @RequestBody PlayCustomFollowInfoEntity playCustomFollowInfo) {
|
||||
playCustomFollowInfo.setId(id);
|
||||
boolean success = playCustomFollowInfoService.update(playCustomFollowInfo);
|
||||
if (success) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.error("修改失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除顾客关注陪聊信息
|
||||
*/
|
||||
@PreAuthorize("@customSs.hasPermission('play:info:remove')")
|
||||
@Log(title = "顾客关注陪聊信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R remove(@PathVariable String[] ids) {
|
||||
return R.ok(playCustomFollowInfoService.deletePlayCustomFollowInfoByIds(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.starry.admin.modules.custom.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.starry.common.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 顾客关注陪聊信息对象 play_custom_follow_info
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024-04-30
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("play_custom_follow_info")
|
||||
public class PlayCustomFollowInfoEntity extends BaseEntity<PlayCustomFollowInfoEntity> {
|
||||
|
||||
|
||||
/**
|
||||
* UUID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 顾客ID
|
||||
*/
|
||||
private String customId;
|
||||
|
||||
/**
|
||||
* 陪聊ID
|
||||
*/
|
||||
private String clerkId;
|
||||
|
||||
/**
|
||||
* 关注时间
|
||||
*/
|
||||
private Date followTime;
|
||||
|
||||
/**
|
||||
* 取消关注时间
|
||||
*/
|
||||
private Date unfollowTime;
|
||||
|
||||
/**
|
||||
* 关注状态[0:未关注,1:已关注]
|
||||
*/
|
||||
private String followState;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.starry.admin.modules.custom.mapper;
|
||||
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.starry.admin.modules.custom.entity.PlayCustomFollowInfoEntity;
|
||||
|
||||
/**
|
||||
* 顾客关注陪聊信息Mapper接口
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024-04-30
|
||||
*/
|
||||
public interface PlayCustomFollowInfoMapper extends MPJBaseMapper<PlayCustomFollowInfoEntity> {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.starry.admin.modules.custom.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.starry.admin.modules.custom.entity.PlayCustomFollowInfoEntity;
|
||||
import com.starry.admin.modules.weichat.entity.PlayClerkFollowQueryVo;
|
||||
import com.starry.admin.modules.weichat.entity.PlayClerkFollowReturnVo;
|
||||
|
||||
/**
|
||||
* 顾客关注陪聊信息Service接口
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024-04-30
|
||||
*/
|
||||
public interface IPlayCustomFollowInfoService extends IService<PlayCustomFollowInfoEntity> {
|
||||
/**
|
||||
* 查询顾客关注陪聊信息
|
||||
*
|
||||
* @param id 顾客关注陪聊信息主键
|
||||
* @return 顾客关注陪聊信息
|
||||
*/
|
||||
PlayCustomFollowInfoEntity selectPlayCustomFollowInfoById(String id);
|
||||
|
||||
/**
|
||||
* 修改关注状态
|
||||
*
|
||||
* @param customUserId 顾客ID
|
||||
* @param clerkUserId 陪聊ID
|
||||
* @return 关注状态[0:未关注,1:已关注]
|
||||
*/
|
||||
String queryFollowState(String customUserId, String clerkUserId);
|
||||
|
||||
/**
|
||||
* 修改关注状态
|
||||
*
|
||||
* @param customUserId 顾客ID
|
||||
* @param clerkUserId 陪聊ID
|
||||
* @param followState 关注状态[0:未关注,1:已关注]
|
||||
*/
|
||||
void updateFollowState(String customUserId, String clerkUserId, String followState);
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询陪聊关注状态
|
||||
*
|
||||
* @param vo 店员关注状态 查询对象
|
||||
* @return 顾客关注陪聊信息集合
|
||||
* @author admin
|
||||
* @since 2024/5/10 10:28
|
||||
**/
|
||||
IPage<PlayClerkFollowReturnVo> selectByPage(PlayClerkFollowQueryVo vo);
|
||||
|
||||
/**
|
||||
* 查询顾客关注陪聊信息列表
|
||||
*
|
||||
* @param playCustomFollowInfo 顾客关注陪聊信息
|
||||
* @return 顾客关注陪聊信息集合
|
||||
*/
|
||||
IPage<PlayCustomFollowInfoEntity> selectPlayCustomFollowInfoByPage(PlayCustomFollowInfoEntity playCustomFollowInfo);
|
||||
|
||||
/**
|
||||
* 新增顾客关注陪聊信息
|
||||
*
|
||||
* @param playCustomFollowInfo 顾客关注陪聊信息
|
||||
* @return 结果
|
||||
*/
|
||||
boolean create(PlayCustomFollowInfoEntity playCustomFollowInfo);
|
||||
|
||||
/**
|
||||
* 修改顾客关注陪聊信息
|
||||
*
|
||||
* @param playCustomFollowInfo 顾客关注陪聊信息
|
||||
* @return 结果
|
||||
*/
|
||||
boolean update(PlayCustomFollowInfoEntity playCustomFollowInfo);
|
||||
|
||||
/**
|
||||
* 批量删除顾客关注陪聊信息
|
||||
*
|
||||
* @param ids 需要删除的顾客关注陪聊信息主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
int deletePlayCustomFollowInfoByIds(String[] ids);
|
||||
|
||||
/**
|
||||
* 删除顾客关注陪聊信息信息
|
||||
*
|
||||
* @param id 顾客关注陪聊信息主键
|
||||
* @return 结果
|
||||
*/
|
||||
int deletePlayCustomFollowInfoById(String id);
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.starry.admin.modules.custom.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.starry.admin.modules.custom.module.entity.PlayCustomLevelInfoEntity;
|
||||
import com.starry.admin.modules.platform.entity.SysTenantEntity;
|
||||
import com.starry.admin.modules.system.entity.SysTenantEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
package com.starry.admin.modules.custom.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.starry.admin.modules.clerk.module.entity.PlayClerkUserInfoEntity;
|
||||
import com.starry.admin.modules.custom.entity.PlayCustomFollowInfoEntity;
|
||||
import com.starry.admin.modules.custom.mapper.PlayCustomFollowInfoMapper;
|
||||
import com.starry.admin.modules.custom.service.IPlayCustomFollowInfoService;
|
||||
import com.starry.admin.modules.weichat.entity.PlayClerkFollowQueryVo;
|
||||
import com.starry.admin.modules.weichat.entity.PlayClerkFollowReturnVo;
|
||||
import com.starry.common.utils.IdUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 顾客关注陪聊信息Service业务层处理
|
||||
*
|
||||
* @author admin
|
||||
* @since 2024-04-30
|
||||
*/
|
||||
@Service
|
||||
public class PlayCustomFollowInfoServiceImpl extends ServiceImpl<PlayCustomFollowInfoMapper, PlayCustomFollowInfoEntity> implements IPlayCustomFollowInfoService {
|
||||
@Resource
|
||||
private PlayCustomFollowInfoMapper playCustomFollowInfoMapper;
|
||||
|
||||
/**
|
||||
* 查询顾客关注陪聊信息
|
||||
*
|
||||
* @param id 顾客关注陪聊信息主键
|
||||
* @return 顾客关注陪聊信息
|
||||
*/
|
||||
@Override
|
||||
public PlayCustomFollowInfoEntity selectPlayCustomFollowInfoById(String id) {
|
||||
return this.baseMapper.selectById(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String queryFollowState(String customUserId, String clerkUserId) {
|
||||
LambdaQueryWrapper<PlayCustomFollowInfoEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(PlayCustomFollowInfoEntity::getClerkId, clerkUserId);
|
||||
lambdaQueryWrapper.eq(PlayCustomFollowInfoEntity::getCustomId, customUserId);
|
||||
PlayCustomFollowInfoEntity entity = this.baseMapper.selectOne(lambdaQueryWrapper);
|
||||
return entity == null ? "0" : entity.getFollowState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFollowState(String customUserId, String clerkUserId, String followState) {
|
||||
LambdaQueryWrapper<PlayCustomFollowInfoEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(PlayCustomFollowInfoEntity::getClerkId, clerkUserId);
|
||||
lambdaQueryWrapper.eq(PlayCustomFollowInfoEntity::getCustomId, customUserId);
|
||||
PlayCustomFollowInfoEntity entity = this.baseMapper.selectOne(lambdaQueryWrapper);
|
||||
if (entity == null) {
|
||||
entity = new PlayCustomFollowInfoEntity();
|
||||
entity.setCustomId(customUserId);
|
||||
entity.setFollowState(followState);
|
||||
entity.setClerkId(clerkUserId);
|
||||
entity.setFollowTime(new Date());
|
||||
this.baseMapper.insert(entity);
|
||||
} else {
|
||||
entity.setFollowState(followState);
|
||||
this.baseMapper.updateById(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<PlayClerkFollowReturnVo> selectByPage(PlayClerkFollowQueryVo vo) {
|
||||
MPJLambdaWrapper<PlayCustomFollowInfoEntity> lambdaQueryWrapper = new MPJLambdaWrapper<PlayCustomFollowInfoEntity>()
|
||||
// 查询主表全部字段
|
||||
.selectAll(PlayCustomFollowInfoEntity.class)
|
||||
// 陪聊用户表全部字段
|
||||
.selectAll(PlayClerkUserInfoEntity.class)
|
||||
// 陪聊用户表
|
||||
.leftJoin(PlayClerkUserInfoEntity.class, PlayClerkUserInfoEntity::getId, PlayCustomFollowInfoEntity::getClerkId);
|
||||
if (StrUtil.isNotBlank(vo.getCustomId())) {
|
||||
lambdaQueryWrapper.eq(PlayCustomFollowInfoEntity::getCustomId, vo.getCustomId());
|
||||
}
|
||||
if (StrUtil.isNotBlank(vo.getFollowState())) {
|
||||
lambdaQueryWrapper.eq(PlayCustomFollowInfoEntity::getFollowState, vo.getFollowState());
|
||||
}
|
||||
IPage<PlayClerkFollowReturnVo> iPage = this.baseMapper.selectJoinPage(new Page<>(vo.getPageNum(), vo.getPageSize()), PlayClerkFollowReturnVo.class, lambdaQueryWrapper);
|
||||
for (PlayClerkFollowReturnVo record : iPage.getRecords()) {
|
||||
LambdaQueryWrapper<PlayCustomFollowInfoEntity> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper1.eq(PlayCustomFollowInfoEntity::getClerkId,record.getClerkId());
|
||||
record.setFollowNumber(this.baseMapper.selectList(lambdaQueryWrapper1).size());
|
||||
}
|
||||
return iPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询顾客关注陪聊信息列表
|
||||
*
|
||||
* @param playCustomFollowInfo 顾客关注陪聊信息
|
||||
* @return 顾客关注陪聊信息
|
||||
*/
|
||||
@Override
|
||||
public IPage<PlayCustomFollowInfoEntity> selectPlayCustomFollowInfoByPage(PlayCustomFollowInfoEntity playCustomFollowInfo) {
|
||||
Page<PlayCustomFollowInfoEntity> page = new Page<>(1, 10);
|
||||
return this.baseMapper.selectPage(page, new LambdaQueryWrapper<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增顾客关注陪聊信息
|
||||
*
|
||||
* @param playCustomFollowInfo 顾客关注陪聊信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean create(PlayCustomFollowInfoEntity playCustomFollowInfo) {
|
||||
if (StrUtil.isBlankIfStr(playCustomFollowInfo.getId())) {
|
||||
playCustomFollowInfo.setId(IdUtils.getUuid());
|
||||
}
|
||||
return save(playCustomFollowInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改顾客关注陪聊信息
|
||||
*
|
||||
* @param playCustomFollowInfo 顾客关注陪聊信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean update(PlayCustomFollowInfoEntity playCustomFollowInfo) {
|
||||
return updateById(playCustomFollowInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除顾客关注陪聊信息
|
||||
*
|
||||
* @param ids 需要删除的顾客关注陪聊信息主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePlayCustomFollowInfoByIds(String[] ids) {
|
||||
return playCustomFollowInfoMapper.deleteBatchIds(Arrays.asList(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除顾客关注陪聊信息信息
|
||||
*
|
||||
* @param id 顾客关注陪聊信息主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePlayCustomFollowInfoById(String id) {
|
||||
return playCustomFollowInfoMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.starry.admin.modules.custom.service.impl;
|
||||
|
||||
import com.starry.common.utils.IdUtils;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@@ -15,6 +14,7 @@ import com.starry.admin.modules.custom.module.entity.PlayCustomUserInfoEntity;
|
||||
import com.starry.admin.modules.custom.module.vo.PlayCustomLeaveMsgQueryVo;
|
||||
import com.starry.admin.modules.custom.module.vo.PlayCustomLeaveMsgReturnVo;
|
||||
import com.starry.admin.modules.custom.service.IPlayCustomLeaveMsgService;
|
||||
import com.starry.common.utils.IdUtils;
|
||||
import com.starry.common.utils.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.starry.admin.modules.custom.mapper.PlayCustomLevelInfoMapper;
|
||||
import com.starry.admin.modules.custom.module.entity.PlayCustomLevelInfoEntity;
|
||||
import com.starry.admin.modules.custom.service.IPlayCustomLevelInfoService;
|
||||
import com.starry.admin.modules.platform.entity.SysTenantEntity;
|
||||
import com.starry.admin.modules.system.entity.SysTenantEntity;
|
||||
import com.starry.common.utils.IdUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.starry.admin.common.exception.CustomException;
|
||||
import com.starry.admin.modules.balance.service.IPlayBalanceDetailsInfoService;
|
||||
import com.starry.admin.modules.custom.mapper.PlayCustomUserInfoMapper;
|
||||
import com.starry.admin.modules.custom.module.entity.PlayCustomLevelInfoEntity;
|
||||
import com.starry.admin.modules.custom.module.entity.PlayCustomUserInfoEntity;
|
||||
@@ -20,6 +19,7 @@ import com.starry.admin.modules.custom.module.vo.PlayCustomUserReturnVo;
|
||||
import com.starry.admin.modules.custom.service.IPlayCustomUserInfoService;
|
||||
import com.starry.admin.modules.order.module.entity.PlayOrderInfoEntity;
|
||||
import com.starry.admin.modules.order.service.impl.PlayOrderInfoServiceImpl;
|
||||
import com.starry.admin.modules.personnel.service.IPlayBalanceDetailsInfoService;
|
||||
import com.starry.common.utils.IdUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
Reference in New Issue
Block a user