表情包管理
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
package com.accompany.admin.controller.face;
|
||||
|
||||
import com.accompany.business.model.face.FaceNew;
|
||||
import com.accompany.business.model.face.FaceTabNew;
|
||||
import com.accompany.business.param.BasePageParams;
|
||||
import com.accompany.business.service.face.FaceNewService;
|
||||
import com.accompany.business.service.face.FaceTabNewService;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 新版表情包 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author wxf
|
||||
* @since 2024-12-27
|
||||
*/
|
||||
@Api(value = "表情包管理", tags = "表情包管理")
|
||||
@RestController
|
||||
@RequestMapping("/faceNew")
|
||||
public class FaceNewAdminController {
|
||||
|
||||
@Autowired
|
||||
private FaceNewService faceNewService;
|
||||
@Autowired
|
||||
private FaceTabNewService faceTabNewService;
|
||||
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "表情包ID"),
|
||||
@ApiImplicitParam(name = "tabId", value = "Tab ID,下拉接口(/faceNew/tab/list)"),
|
||||
@ApiImplicitParam(name = "status", value = "状态 -1-全部,1展示, 0不展示"),
|
||||
})
|
||||
@ApiOperation(value = "表情包列表", httpMethod = "GET")
|
||||
@GetMapping(value = "/list")
|
||||
public BusiResult<IPage<FaceNew>> listPage(Integer id, Integer tabId, Integer status, BasePageParams basePageParams) {
|
||||
IPage<FaceNew> faceList = faceNewService.listPage(id, tabId, status,basePageParams);
|
||||
return BusiResult.success(faceList);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "表情包标签列表", httpMethod = "GET")
|
||||
@GetMapping(value = "/tab/list")
|
||||
public BusiResult<List<FaceTabNew>> tabList() {
|
||||
List<FaceTabNew> faceList = faceTabNewService.tabList();
|
||||
return BusiResult.success(faceList);
|
||||
}
|
||||
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "表情包ID"),
|
||||
@ApiImplicitParam(name = "tabId", value = "Tab ID,下拉接口(/faceNew/tab/list)"),
|
||||
@ApiImplicitParam(name = "status", value = "状态 -1-全部,1展示, 0不展示"),
|
||||
@ApiImplicitParam(name = "faceIndex", value = "表情包封面"),
|
||||
@ApiImplicitParam(name = "faceUrl", value = "表情:上传svga格式"),
|
||||
@ApiImplicitParam(name = "seqNo", value = "排序"),
|
||||
@ApiImplicitParam(name = "showTimes", value = "展示次数"),
|
||||
})
|
||||
@ApiOperation(value = "保存编辑", httpMethod = "POST")
|
||||
@PostMapping(value = "/saveOrUpdate")
|
||||
public BusiResult<Void> saveOrUpdage(FaceNew faceNew) {
|
||||
faceNewService.saveOrUpdage(faceNew);
|
||||
faceTabNewService.faceTableCache().delete();
|
||||
return BusiResult.success();
|
||||
}
|
||||
|
||||
@ApiOperation("删除")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public BusiResult<Void> delete(Integer id) {
|
||||
faceNewService.removeById(id);
|
||||
faceTabNewService.faceTableCache().delete();
|
||||
return BusiResult.success();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
package com.accompany.admin.controller.face;
|
||||
|
||||
import com.accompany.business.model.face.FaceTabNew;
|
||||
import com.accompany.business.param.BasePageParams;
|
||||
import com.accompany.business.service.face.FaceTabNewService;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 新版表情标签表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author wxf
|
||||
* @since 2024-12-27
|
||||
*/
|
||||
@Api(value = "表情包Tab管理", tags = "表情包Tab管理")
|
||||
@RestController
|
||||
@RequestMapping("/faceTabNew")
|
||||
public class FaceTabNewAdminController {
|
||||
|
||||
@Autowired
|
||||
private FaceTabNewService faceTabNewService;
|
||||
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "tabId"),
|
||||
@ApiImplicitParam(name = "useVip", value = "类型 -1-全部,0-普通,1-贵族"),
|
||||
@ApiImplicitParam(name = "status", value = "状态 -1-全部,1展示, 0不展示"),
|
||||
})
|
||||
@ApiOperation(value = "表情包Tab列表", httpMethod = "GET")
|
||||
@GetMapping(value = "/list")
|
||||
public BusiResult<IPage<FaceTabNew>> listPage(Integer id, Integer status, Integer useVip, BasePageParams basePageParams) {
|
||||
IPage<FaceTabNew> iPage = faceTabNewService.listPage(id, status, useVip, basePageParams);
|
||||
return BusiResult.success(iPage);
|
||||
}
|
||||
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "tabId"),
|
||||
@ApiImplicitParam(name = "useVip", value = "类型 0-普通,1-贵族"),
|
||||
@ApiImplicitParam(name = "status", value = "状态 1展示, 0不展示"),
|
||||
@ApiImplicitParam(name = "tabUrl", value = "tab图"),
|
||||
@ApiImplicitParam(name = "tabSeq", value = "排序"),
|
||||
})
|
||||
@ApiOperation(value = "Tab保存编辑", httpMethod = "POST")
|
||||
@PostMapping(value = "/saveOrUpdate")
|
||||
public BusiResult<Void> saveOrUpdage(FaceTabNew faceTabNew) {
|
||||
faceTabNewService.saveOrUpdage(faceTabNew);
|
||||
return BusiResult.success();
|
||||
}
|
||||
|
||||
@ApiOperation("删除")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public BusiResult<Void> delete(Integer id) {
|
||||
faceTabNewService.removeById(id);
|
||||
faceTabNewService.faceTableCache().delete();
|
||||
return BusiResult.success();
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package com.accompany.business.constant;
|
||||
|
||||
import com.accompany.common.redis.BaseRedisKey;
|
||||
|
||||
public interface FaceConstant {
|
||||
|
||||
enum RedisKey implements BaseRedisKey {
|
||||
face_tab_new,
|
||||
;
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return "face:" + name();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,87 @@
|
||||
package com.accompany.business.model.face;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 新版表情包
|
||||
* </p>
|
||||
*
|
||||
* @author wxf
|
||||
* @since 2024-12-27
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("face_new")
|
||||
public class FaceNew implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@TableField("face_name")
|
||||
private String faceName;
|
||||
|
||||
/**
|
||||
* 标签id
|
||||
*/
|
||||
@TableField("tab_id")
|
||||
private Integer tabId;
|
||||
|
||||
/**
|
||||
* 封面图
|
||||
*/
|
||||
@TableField("face_index")
|
||||
private String faceIndex;
|
||||
|
||||
/**
|
||||
* svga地址
|
||||
*/
|
||||
@TableField("face_url")
|
||||
private String faceUrl;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@TableField("seq_no")
|
||||
private Integer seqNo;
|
||||
|
||||
|
||||
/**
|
||||
* 是否展示 0不展示 1展示
|
||||
*/
|
||||
@TableField("status")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 表情展示几次
|
||||
*/
|
||||
@TableField("show_times")
|
||||
private Integer showTimes;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("update_time")
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,74 @@
|
||||
package com.accompany.business.model.face;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 新版表情标签表
|
||||
* </p>
|
||||
*
|
||||
* @author wxf
|
||||
* @since 2024-12-27
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("face_tab_new")
|
||||
public class FaceTabNew implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@TableField("tab_name")
|
||||
private String tabName;
|
||||
|
||||
/**
|
||||
* 封面图
|
||||
*/
|
||||
@TableField("tab_url")
|
||||
private String tabUrl;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@TableField("tab_seq")
|
||||
private Integer tabSeq;
|
||||
|
||||
/**
|
||||
* 1展示 0不展示
|
||||
*/
|
||||
@TableField("status")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("update_time")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 最低vip使用权限 0普通用户 1~6 vip1~6
|
||||
*/
|
||||
@TableField("use_vip")
|
||||
private Integer useVip;
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
package com.accompany.business.model.face.vo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 新版表情包
|
||||
* </p>
|
||||
*
|
||||
* @author wxf
|
||||
* @since 2024-12-27
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class FaceNewVo {
|
||||
|
||||
|
||||
/**
|
||||
* 封面图
|
||||
*/
|
||||
private String faceUrl;
|
||||
/**
|
||||
* 封面图
|
||||
*/
|
||||
private String faceIndex;
|
||||
|
||||
/**
|
||||
* 表情展示几次
|
||||
*/
|
||||
private Integer showTimes;
|
||||
private Integer seqNo;
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
package com.accompany.business.model.face.vo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 新版表情标签表
|
||||
* </p>
|
||||
*
|
||||
* @author wxf
|
||||
* @since 2024-12-27
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class FaceTabNewVo {
|
||||
|
||||
/**
|
||||
* 标签封面图
|
||||
*/
|
||||
private String tabUrl;
|
||||
private Integer tabId;
|
||||
|
||||
/**
|
||||
* vip几可用
|
||||
*/
|
||||
private Integer useVip;
|
||||
/**
|
||||
* 标签排序
|
||||
*/
|
||||
private Integer tabSeq;
|
||||
|
||||
/**
|
||||
* 表情包
|
||||
*/
|
||||
private List<FaceNewVo> faceNewVoList;
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.accompany.business.mybatismapper.face;
|
||||
|
||||
import com.accompany.business.model.face.FaceNew;
|
||||
import com.accompany.business.model.face.vo.FaceNewVo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 新版表情包 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author wxf
|
||||
* @since 2024-12-27
|
||||
*/
|
||||
@Mapper
|
||||
public interface FaceNewMapper extends BaseMapper<FaceNew> {
|
||||
|
||||
List<FaceNewVo> faceList(@Param("tabId") Integer tabId);
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
package com.accompany.business.mybatismapper.face;
|
||||
|
||||
import com.accompany.business.model.face.FaceTabNew;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 新版表情标签表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author wxf
|
||||
* @since 2024-12-27
|
||||
*/
|
||||
@Mapper
|
||||
public interface FaceTabNewMapper extends BaseMapper<FaceTabNew> {
|
||||
|
||||
List<FaceTabNew> effectList();
|
||||
|
||||
void shelves(@Param("id") Integer id, @Param("status") Integer status);
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
package com.accompany.business.service.face;
|
||||
|
||||
import com.accompany.business.model.face.FaceNew;
|
||||
import com.accompany.business.model.face.vo.FaceNewVo;
|
||||
import com.accompany.business.param.BasePageParams;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 新版表情包 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author wxf
|
||||
* @since 2024-12-27
|
||||
*/
|
||||
public interface FaceNewService extends IService<FaceNew> {
|
||||
IPage<FaceNew> listPage(Integer id, Integer tabId, Integer status, BasePageParams basePageParams);
|
||||
List<FaceNewVo> faceList(Integer faceId);
|
||||
|
||||
void saveOrUpdage(FaceNew faceNew);
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
package com.accompany.business.service.face;
|
||||
|
||||
import com.accompany.business.model.face.FaceTabNew;
|
||||
import com.accompany.business.model.face.vo.FaceTabNewVo;
|
||||
import com.accompany.business.param.BasePageParams;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.redisson.api.RBucket;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 新版表情标签表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author wxf
|
||||
* @since 2024-12-27
|
||||
*/
|
||||
public interface FaceTabNewService extends IService<FaceTabNew> {
|
||||
|
||||
List<FaceTabNewVo> faceList(Long uid);
|
||||
|
||||
IPage<FaceTabNew> listPage(Integer id, Integer status, Integer useVip, BasePageParams basePageParams);
|
||||
|
||||
void saveOrUpdage(FaceTabNew faceTabNew);
|
||||
|
||||
void shelves(Integer id, Integer status);
|
||||
|
||||
RBucket<String> faceTableCache();
|
||||
|
||||
List<FaceTabNew> tabList();
|
||||
|
||||
}
|
@@ -0,0 +1,83 @@
|
||||
package com.accompany.business.service.face.impl;
|
||||
|
||||
import com.accompany.business.constant.FaceConstant;
|
||||
import com.accompany.business.model.face.FaceNew;
|
||||
import com.accompany.business.model.face.vo.FaceNewVo;
|
||||
import com.accompany.business.mybatismapper.face.FaceNewMapper;
|
||||
import com.accompany.business.param.BasePageParams;
|
||||
import com.accompany.business.service.face.FaceNewService;
|
||||
import com.accompany.core.exception.AdminServiceException;
|
||||
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 org.apache.commons.lang3.StringUtils;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 新版表情包 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author wxf
|
||||
* @since 2024-12-27
|
||||
*/
|
||||
@Service
|
||||
public class FaceNewServiceImpl extends ServiceImpl<FaceNewMapper, FaceNew> implements FaceNewService {
|
||||
|
||||
@Autowired
|
||||
private RedissonClient redissonClient;
|
||||
|
||||
@Override
|
||||
public IPage<FaceNew> listPage(Integer id, Integer tabId, Integer status, BasePageParams basePageParams) {
|
||||
Page<FaceNew> page = new Page<>(basePageParams.getPageNo(),basePageParams.getPageSize());
|
||||
|
||||
LambdaQueryWrapper<FaceNew> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(id != null && id != 0, FaceNew::getId, id)
|
||||
.eq(tabId != null && tabId != 0, FaceNew::getTabId, tabId)
|
||||
.eq(status != null && status != -1, FaceNew::getStatus,status)
|
||||
.orderByDesc(FaceNew::getSeqNo);
|
||||
|
||||
return this.page(page,queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FaceNewVo> faceList(Integer faceId) {
|
||||
return this.baseMapper.faceList(faceId);
|
||||
}
|
||||
|
||||
private void existSeqNo(Integer seqNo) {
|
||||
if (seqNo == null) {
|
||||
return;
|
||||
}
|
||||
LambdaQueryWrapper<FaceNew> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(FaceNew::getSeqNo, seqNo);
|
||||
boolean exist = baseMapper.selectCount(queryWrapper) > 0;
|
||||
if (exist) {
|
||||
throw new AdminServiceException("排序已经存在,不允许重复排序");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveOrUpdage(FaceNew faceNew) {
|
||||
|
||||
if (faceNew.getId() == null){
|
||||
existSeqNo(faceNew.getSeqNo());
|
||||
this.save(faceNew);
|
||||
}else {
|
||||
FaceNew face = this.getById(faceNew.getId());
|
||||
if (!face.getSeqNo().equals(faceNew.getSeqNo())) {
|
||||
existSeqNo(faceNew.getSeqNo());
|
||||
}
|
||||
BeanUtils.copyProperties(faceNew,face);
|
||||
face.setUpdateTime(new Date());
|
||||
this.updateById(face);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,138 @@
|
||||
package com.accompany.business.service.face.impl;
|
||||
|
||||
import com.accompany.business.model.face.FaceTabNew;
|
||||
import com.accompany.business.model.face.vo.FaceNewVo;
|
||||
import com.accompany.business.model.face.vo.FaceTabNewVo;
|
||||
import com.accompany.business.mybatismapper.face.FaceTabNewMapper;
|
||||
import com.accompany.business.param.BasePageParams;
|
||||
import com.accompany.business.service.face.FaceNewService;
|
||||
import com.accompany.business.service.face.FaceTabNewService;
|
||||
import com.accompany.core.exception.AdminServiceException;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
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 org.apache.commons.lang3.StringUtils;
|
||||
import org.redisson.api.RBucket;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.redisson.client.codec.StringCodec;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static com.accompany.business.constant.FaceConstant.RedisKey.face_tab_new;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 新版表情标签表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author wxf
|
||||
* @since 2024-12-27
|
||||
*/
|
||||
@Service
|
||||
public class FaceTabNewServiceImpl extends ServiceImpl<FaceTabNewMapper, FaceTabNew> implements FaceTabNewService {
|
||||
|
||||
@Autowired
|
||||
private RedissonClient redissonClient;
|
||||
@Autowired
|
||||
private FaceNewService faceNewService;
|
||||
|
||||
|
||||
@Override
|
||||
public IPage<FaceTabNew> listPage(Integer id, Integer status, Integer useVip, BasePageParams basePageParams) {
|
||||
Page<FaceTabNew> page = new Page<>(basePageParams.getPageNo(), basePageParams.getPageSize());
|
||||
|
||||
LambdaQueryWrapper<FaceTabNew> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(status != null && status != -1, FaceTabNew::getStatus, status).eq(useVip != null && useVip != -1, FaceTabNew::getUseVip, useVip).eq(id != null, FaceTabNew::getId, id);
|
||||
|
||||
queryWrapper.orderByDesc(FaceTabNew::getTabSeq);
|
||||
|
||||
return this.page(page, queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FaceTabNew> tabList() {
|
||||
LambdaQueryWrapper<FaceTabNew> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.orderByAsc(FaceTabNew::getTabSeq);
|
||||
return this.list();
|
||||
}
|
||||
|
||||
private void existSeqNo(Integer seqNo) {
|
||||
if (seqNo == null) {
|
||||
return;
|
||||
}
|
||||
LambdaQueryWrapper<FaceTabNew> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(FaceTabNew::getTabSeq, seqNo);
|
||||
boolean exist = baseMapper.selectCount(queryWrapper) > 0;
|
||||
if (exist) {
|
||||
throw new AdminServiceException("排序已经存在,不允许重复排序");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveOrUpdage(FaceTabNew faceTabNew) {
|
||||
|
||||
if (faceTabNew.getId() == null) {
|
||||
existSeqNo(faceTabNew.getTabSeq());
|
||||
this.save(faceTabNew);
|
||||
} else {
|
||||
FaceTabNew tabNew = this.getById(faceTabNew.getId());
|
||||
if (!tabNew.getTabSeq().equals(faceTabNew.getTabSeq())) {
|
||||
existSeqNo(faceTabNew.getTabSeq());
|
||||
}
|
||||
BeanUtils.copyProperties(faceTabNew, tabNew);
|
||||
tabNew.setUpdateTime(new Date());
|
||||
this.updateById(tabNew);
|
||||
}
|
||||
faceTableCache().delete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shelves(Integer id, Integer status) {
|
||||
this.baseMapper.shelves(id, status);
|
||||
faceTableCache().delete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RBucket<String> faceTableCache() {
|
||||
return redissonClient.getBucket(face_tab_new.getKey(), StringCodec.INSTANCE);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<FaceTabNewVo> faceList(Long uid) {
|
||||
RBucket<String> bucket = this.faceTableCache();
|
||||
String value = bucket.get();
|
||||
if (StringUtils.isNotEmpty(value)) {
|
||||
return JSONArray.parseArray(value, FaceTabNewVo.class);
|
||||
}
|
||||
List<FaceTabNewVo> faceTabNewVos = new ArrayList<>();
|
||||
List<FaceTabNew> faceTabNews = this.baseMapper.effectList();
|
||||
if (CollectionUtils.isEmpty(faceTabNews)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
for (FaceTabNew faceTabNew : faceTabNews) {
|
||||
FaceTabNewVo faceTabNewVo = new FaceTabNewVo();
|
||||
BeanUtils.copyProperties(faceTabNew, faceTabNewVo);
|
||||
faceTabNewVo.setTabId(faceTabNew.getId());
|
||||
List<FaceNewVo> faceNewVoList = faceNewService.faceList(faceTabNew.getId());
|
||||
if (CollectionUtils.isEmpty(faceNewVoList)) {
|
||||
continue;
|
||||
}
|
||||
faceTabNewVo.setFaceNewVoList(faceNewVoList);
|
||||
faceTabNewVos.add(faceTabNewVo);
|
||||
}
|
||||
|
||||
bucket.set(JSON.toJSONString(faceTabNewVos));
|
||||
return faceTabNewVos;
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.accompany.business.mybatismapper.face.FaceNewMapper">
|
||||
|
||||
<select id="faceList" resultType="com.accompany.business.model.face.FaceTabNew">
|
||||
select face_name, tab_id, face_index, face_url, seq_no, show_times from face_new where tab_id = #{tabId} and status = 1 order by seq_no asc
|
||||
</select>
|
||||
</mapper>
|
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.accompany.business.mybatismapper.face.FaceTabNewMapper">
|
||||
<update id="shelves">
|
||||
UPDATE `face_tab_new` SET `status` = #{status} WHERE `id` = #{id};
|
||||
</update>
|
||||
|
||||
<select id="effectList" resultType="com.accompany.business.model.face.vo.FaceTabNew">
|
||||
select * from face_tab_new where status = 1 order by tab_seq asc
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
@@ -0,0 +1,34 @@
|
||||
package com.accompany.business.controller.face;
|
||||
|
||||
import com.accompany.business.model.face.vo.FaceTabNewVo;
|
||||
import com.accompany.business.service.face.FaceTabNewService;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 新版表情标签表 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author wxf
|
||||
* @since 2024-12-27
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/faceTabNew")
|
||||
public class FaceTabNewController {
|
||||
@Autowired
|
||||
private FaceTabNewService faceTabNewService;
|
||||
|
||||
@ApiOperation("表情包列表")
|
||||
@GetMapping(value = "/list")
|
||||
public BusiResult<List<FaceTabNewVo>> faceList(Long uid) {
|
||||
List<FaceTabNewVo> faceList = faceTabNewService.faceList(uid);
|
||||
return BusiResult.success(faceList);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user