记得上下班打卡 | git大法好,push需谨慎

Commit 37e2bb64 authored by 姜秀龙's avatar 姜秀龙

Merge remote-tracking branch 'origin/master' into jxl-xiangou

parents a755bcd4 b8beb1c4
package com.liquidnet.service.sweet.param;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 失物招领管理员查询参数
*
* @author liquidnet
* @since 2025-01-18
*/
@Data
@ApiModel("失物招领管理员查询参数")
public class SweetLostFoundAdminParam implements Serializable {
@ApiModelProperty("主键ID 编辑填写")
@NotNull(message = "ID不能为空", groups = ValidationGroups.Update.class)
private Long id;
@ApiModelProperty("手机号")
@NotBlank(message = "手机号不能为空")
private String phone;
@ApiModelProperty("备注姓名")
private String name;
@ApiModelProperty("权限类型:1-发帖员(仅发帖,发布后不可编辑) 2-管理员(发帖、编辑、删除)")
@NotNull(message = "权限类型不能为空")
private Integer permissionType;
@ApiModelProperty("授权范围:1-本站次 2-全站")
@NotNull(message = "授权范围不能为空")
private Integer authScope;
@ApiModelProperty("演出ID")
@NotBlank(message = "演出ID不能为空")
private String performanceId;
}
\ No newline at end of file
package com.liquidnet.service.sweet.param;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 失物招领信息查询参数
*
* @author liquidnet
* @since 2025-01-18
*/
@Data
@ApiModel("失物招领信息查询参数")
public class SweetLostFoundItemParam implements Serializable {
@ApiModelProperty("主键ID 编辑填写")
@NotNull(message = "ID不能为空", groups = ValidationGroups.Update.class)
private Long id;
@ApiModelProperty("演出ID")
@NotBlank(message = "演出ID不能为空")
private String performanceId;
@ApiModelProperty("物品类型:1-证件卡类 2-3C数码类 3-服饰类 4-其他")
@NotNull(message = "物品类型不能为空")
private Integer itemType;
@ApiModelProperty("拾捡地:1-音乐节现场 2-其他")
@NotNull(message = "拾捡地不能为空")
private Integer pickupLocation;
@ApiModelProperty("捡拾日期")
@NotBlank(message = "捡拾日期不能为空")
private String pickupDate;
@ApiModelProperty("物品描述,最多120字")
@NotBlank(message = "物品描述不能为空")
private String description;
@ApiModelProperty("物品图片URL")
@NotBlank(message = "物品图片URL不能为空")
private String itemImage;
@ApiModelProperty("发布人uid")
@NotBlank(message = "发布人uid不能为空")
private String publisherUid;
}
\ No newline at end of file
package com.liquidnet.service.sweet.param;
import javax.validation.groups.Default;
/**
* <p>
* xx 服务实现类
* </p>
*
* @author jiangxiulong
* @since 2025-08-20 13:13
*/
public class ValidationGroups {
public interface Create extends Default {}
public interface Update extends Default {}
public interface Delete extends Default {}
public interface Query extends Default {}
}
package com.liquidnet.service.sweet.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.sweet.entity.SweetLostFoundAdmin;
import com.liquidnet.service.sweet.param.SweetLostFoundAdminParam;
import com.liquidnet.service.sweet.vo.SweetLostFoundAdminVo;
import java.util.List;
/**
* 失物招领管理员服务接口
*
* @author liquidnet
* @since 2025-01-18
*/
public interface ISweetLostFoundAdminService extends IService<SweetLostFoundAdmin> {
/**
* 添加管理员
*
* @param admin 管理员信息
* @return 是否成功
*/
ResponseDto<Boolean> addAdmin(SweetLostFoundAdminParam admin);
/**
* 编辑管理员
*
* @param admin 管理员信息
* @return 是否成功
*/
ResponseDto<Boolean> editAdmin(SweetLostFoundAdminParam admin);
/**
* 删除管理员
*
* @param id 管理员ID
* @return 是否成功
*/
boolean deleteAdmin(Long id);
/**
* 获取管理员详情
*
* @param id 管理员ID
* @return 管理员详情
*/
SweetLostFoundAdminVo getAdminDetail(Long id);
/**
* 分页查询管理员列表
*
* @param performanceId 查询参数
* @return 分页结果
*/
List<SweetLostFoundAdminVo> getAdminList(String performanceId);
/**
* 检查是否有管理员权限
*
* @param phone 手机号
* @param performanceId 演出ID
* @return 权限详情信息
*/
SweetLostFoundAdminVo hasPermission(String phone, String performanceId);
}
\ No newline at end of file
package com.liquidnet.service.sweet.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.liquidnet.service.sweet.entity.SweetLostFoundItem;
import com.liquidnet.service.sweet.param.SweetLostFoundItemParam;
import com.liquidnet.service.sweet.vo.SweetLostFoundItemVo;
import java.util.List;
/**
* 失物招领信息服务接口
*
* @author liquidnet
* @since 2025-01-18
*/
public interface ISweetLostFoundItemService extends IService<SweetLostFoundItem> {
/**
* 发布失物信息
*
* @param item 失物信息
* @return 是否成功
*/
boolean publishItem(SweetLostFoundItemParam item);
/**
* 编辑失物信息
*
* @param item 失物信息
* @return 是否成功
*/
boolean editItem(SweetLostFoundItemParam item);
/**
* 删除失物信息
*
* @param id 物品ID
* @return 是否成功
*/
boolean deleteItem(Long id);
/**
* 获取失物信息详情
*
* @param id 物品ID
* @return 失物信息详情
*/
SweetLostFoundItemVo getItemDetail(Long id);
/**
* 根据演出ID查询失物信息列表
*
* @param itemType 演出ID
* @param performanceId 演出ID
* @return 失物信息列表
*/
List<SweetLostFoundItemVo> getItemList(Integer itemType, String performanceId);
}
\ No newline at end of file
package com.liquidnet.service.sweet.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* 失物招领信息返回VO
*
* @author liquidnet
* @since 2025-01-18
*/
@Data
@ApiModel("失物招领信息返回")
public class SweetLostFoundItemVo {
@ApiModelProperty("主键ID")
private Long id;
@ApiModelProperty("失物信息ID")
private String itemId;
@ApiModelProperty("物品图片URL")
private String itemImage;
@ApiModelProperty("物品描述,最多120字")
private String description;
@ApiModelProperty("拾捡地:1-音乐节现场 2-其他")
private Integer pickupLocation;
@ApiModelProperty("捡拾日期")
private String pickupDate;
@ApiModelProperty("物品类型:1-证件卡类 2-3C数码类 3-服饰类 4-其他")
private Integer itemType;
@ApiModelProperty("演出ID")
private String performanceId;
@ApiModelProperty("发布人uid")
private String publisherUid;
@ApiModelProperty("创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
@ApiModelProperty("更新时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
}
\ No newline at end of file
......@@ -245,5 +245,10 @@ liquidnet:
erp:
wdt:
url: https://sandbox.wangdian.cn/openapi2/
alipay:
applet:
appId: appId
pubKey: pubKey
privateKey: xxxx
#application-dev-end
\ No newline at end of file
package com.liquidnet.service.sweet.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
/**
* 失物招领管理员实体类
*
* @author liquidnet
* @since 2025-01-18
*/
@ApiModel("失物招领管理员")
@Data
@EqualsAndHashCode(callSuper = false)
public class SweetLostFoundAdmin implements Serializable, Cloneable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("主键ID")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty("管理员ID")
private String adminId;
@ApiModelProperty("手机号")
private String phone;
@ApiModelProperty("备注姓名")
private String name;
@ApiModelProperty("权限类型:1-发帖员(仅发帖,发布后不可编辑) 2-管理员(发帖、编辑、删除)")
private Integer permissionType;
@ApiModelProperty("授权范围:1-本站次 2-全站")
private Integer authScope;
@ApiModelProperty("演出ID")
private String performanceId;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
@ApiModelProperty("是否删除:0-未删除 1-已删除")
private Integer isDeleted;
private static final SweetLostFoundAdmin obj = new SweetLostFoundAdmin();
public static SweetLostFoundAdmin getNew() {
try {
return (SweetLostFoundAdmin) obj.clone();
} catch (CloneNotSupportedException e) {
return new SweetLostFoundAdmin();
}
}
// 权限类型枚举
public enum PermissionType {
POSTER(1, "发帖员"),
ADMIN(2, "管理员");
private final int code;
private final String desc;
PermissionType(int code, String desc) {
this.code = code;
this.desc = desc;
}
public int getCode() {
return code;
}
public String getDesc() {
return desc;
}
}
// 授权范围枚举
public enum AuthScope {
CURRENT_EVENT(1, "本站次"),
ALL_EVENTS(2, "全站");
private final int code;
private final String desc;
AuthScope(int code, String desc) {
this.code = code;
this.desc = desc;
}
public int getCode() {
return code;
}
public String getDesc() {
return desc;
}
}
}
\ No newline at end of file
package com.liquidnet.service.sweet.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
/**
* 失物招领信息实体类
*
* @author liquidnet
* @since 2025-01-18
*/
@ApiModel("失物招领信息")
@Data
@EqualsAndHashCode(callSuper = false)
public class SweetLostFoundItem implements Serializable, Cloneable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("主键ID")
@TableId(value = "id", type = IdType.AUTO)
private Long id;
@ApiModelProperty("失物信息ID")
private String itemId;
@ApiModelProperty("物品图片URL")
private String itemImage;
@ApiModelProperty("物品描述,最多120字")
private String description;
@ApiModelProperty("拾捡地:1-音乐节现场 2-其他")
private Integer pickupLocation;
@ApiModelProperty("捡拾日期")
private String pickupDate;
@ApiModelProperty("物品类型:1-证件卡类 2-3C数码类 3-服饰类 4-其他")
private Integer itemType;
@ApiModelProperty("演出ID")
private String performanceId;
@ApiModelProperty("发布人uid")
private String publisherUid;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("更新时间")
private Date updateTime;
@ApiModelProperty("是否删除:0-未删除 1-已删除")
private Integer isDeleted;
private static final SweetLostFoundItem obj = new SweetLostFoundItem();
public static SweetLostFoundItem getNew() {
try {
return (SweetLostFoundItem) obj.clone();
} catch (CloneNotSupportedException e) {
return new SweetLostFoundItem();
}
}
// 拾捡地枚举
public enum PickupLocation {
FESTIVAL_SITE(1, "音乐节现场"),
OTHER_PLACE(2, "其他");
private final int code;
private final String desc;
PickupLocation(int code, String desc) {
this.code = code;
this.desc = desc;
}
public int getCode() {
return code;
}
public String getDesc() {
return desc;
}
}
// 物品类型枚举
public enum ItemType {
DOCUMENT_CARD(1, "证件卡类"),
DIGITAL_DEVICE(2, "3C数码类"),
CLOTHING(3, "服饰类"),
OTHER(4, "其他");
private final int code;
private final String desc;
ItemType(int code, String desc) {
this.code = code;
this.desc = desc;
}
public int getCode() {
return code;
}
public String getDesc() {
return desc;
}
}
}
\ No newline at end of file
package com.liquidnet.service.sweet.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.liquidnet.service.sweet.entity.SweetLostFoundAdmin;
/**
* 失物招领管理员Mapper接口
*
* @author liquidnet
* @since 2025-01-18
*/
public interface SweetLostFoundAdminMapper extends BaseMapper<SweetLostFoundAdmin> {
}
\ No newline at end of file
package com.liquidnet.service.sweet.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.liquidnet.service.sweet.entity.SweetLostFoundItem;
/**
* 失物招领信息Mapper接口
*
* @author liquidnet
* @since 2025-01-18
*/
public interface SweetLostFoundItemMapper extends BaseMapper<SweetLostFoundItem> {
}
\ No newline at end of file
package com.liquidnet.service.sweet.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
/**
* 失物招领管理员返回VO
*
* @author liquidnet
* @since 2025-01-18
*/
@ApiModel("失物招领管理员返回")
@Data
@EqualsAndHashCode(callSuper = false)
public class SweetLostFoundAdminVo implements Serializable, Cloneable {
@ApiModelProperty("主键ID")
private Long id;
@ApiModelProperty("手机号")
private String phone;
@ApiModelProperty("备注姓名")
private String name;
@ApiModelProperty("权限类型:1-发帖员 2-管理员")
private Integer permissionType;
@ApiModelProperty("授权范围:1-本站次 2-全站")
private Integer authScope;
@ApiModelProperty("演出ID")
private String performanceId;
@ApiModelProperty("创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
@ApiModelProperty("更新时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
}
\ No newline at end of file
<?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.liquidnet.service.sweet.mapper.SweetLostFoundAdminMapper">
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id
, phone, name, permission_type, auth_scope, performance_id,
create_time, update_time, is_deleted, create_user_id, update_user_id
</sql>
<!-- 分页查询管理员列表 -->
<select id="selectAdminPage" resultType="com.liquidnet.service.sweet.vo.SweetLostFoundAdminVo">
SELECT
a.id,
a.phone,
a.name,
a.permission_type,
a.auth_scope,
a.performance_id,
a.create_time,
a.update_time,
a.create_user_id,
a.update_user_id
FROM sweet_lost_found_admin a
WHERE a.is_deleted = 0
<if test="param.phone != null and param.phone != ''">
AND a.phone LIKE CONCAT('%', #{param.phone}, '%')
</if>
<if test="param.name != null and param.name != ''">
AND a.name LIKE CONCAT('%', #{param.name}, '%')
</if>
<if test="param.permissionType != null">
AND a.permission_type = #{param.permissionType}
</if>
<if test="param.authScope != null">
AND a.auth_scope = #{param.authScope}
</if>
<if test="param.performanceId != null">
AND a.performance_id = #{param.performanceId}
</if>
ORDER BY a.create_time DESC
</select>
</mapper>
\ No newline at end of file
<?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.liquidnet.service.sweet.mapper.SweetLostFoundItemMapper">
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id
, item_image, description, pickup_location, pickup_date, item_type,
performance_id, create_time, update_time, is_deleted, create_user_id, update_user_id
</sql>
<!-- 查询失物信息列表 -->
<select id="selectItemPage" resultType="com.liquidnet.service.sweet.vo.SweetLostFoundItemVo">
SELECT
i.id,
i.item_image,
i.description,
i.pickup_location,
i.pickup_date,
i.item_type,
i.performance_id,
i.create_time,
i.update_time,
i.create_user_id
FROM sweet_lost_found_item i
WHERE i.is_deleted = 0
<if test="param.performanceId != null">
AND i.performance_id = #{param.performanceId}
</if>
<if test="param.itemType != null">
AND i.item_type = #{param.itemType}
</if>
<if test="param.startDate != null">
AND i.pickup_date >= #{param.startDate}
</if>
<if test="param.endDate != null">
AND i.pickup_date &lt;= #{param.endDate}
</if>
ORDER BY i.create_time DESC
</select>
</mapper>
\ No newline at end of file
-- 草莓演出失物招领功能数据库表结构
-- 创建时间: 2025-01-18
-- 表前缀: sweet_
-- 失物招领管理员表
CREATE TABLE IF NOT EXISTS `sweet_lost_found_admin`
(
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`admin_id` varchar(64) NOT NULL DEFAULT '' COMMENT '管理员ID',
`phone` varchar(11) NOT NULL DEFAULT '' COMMENT '手机号',
`name` varchar(50) NOT NULL DEFAULT '' COMMENT '备注姓名',
`permission_type` tinyint(1) NOT NULL DEFAULT 1 COMMENT '权限类型:1-发帖员(仅发帖,发布后不可编辑) 2-管理员(发帖、编辑、删除)',
`auth_scope` tinyint(1) NOT NULL DEFAULT 1 COMMENT '授权范围:1-本站次 2-全站',
`performance_id` varchar(64) NOT NULL DEFAULT '' COMMENT '演出ID',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`is_deleted` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否删除:0-未删除 1-已删除',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_admin_id` (`admin_id`),
KEY `idx_phone` (`phone`),
KEY `idx_performance_id` (`performance_id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 COMMENT ='失物招领管理员表';
-- 失物招领信息表
CREATE TABLE IF NOT EXISTS `sweet_lost_found_item`
(
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`item_id` varchar(64) NOT NULL DEFAULT '' COMMENT '失物信息ID',
`item_image` varchar(500) NOT NULL DEFAULT '' COMMENT '物品图片URL',
`description` varchar(500) NOT NULL DEFAULT '' COMMENT '物品描述,最多120字',
`pickup_location` tinyint(1) NOT NULL DEFAULT 1 COMMENT '拾捡地:1-音乐节现场 2-其他',
`pickup_date` varchar(20) NOT NULL DEFAULT '' COMMENT '捡拾日期',
`item_type` tinyint(1) NOT NULL DEFAULT 1 COMMENT '物品类型:1-证件卡类 2-3C数码类 3-服饰类 4-其他',
`performance_id` varchar(64) NOT NULL DEFAULT '' COMMENT '演出ID',
`publisher_uid` varchar(64) NOT NULL DEFAULT '' COMMENT '发布人uid',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`is_deleted` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否删除:0-未删除 1-已删除',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_item_id` (`item_id`),
KEY `idx_performance_id` (`performance_id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4 COMMENT ='失物招领信息表';
\ No newline at end of file
package com.liquidnet.service.sweet.controller;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.sweet.param.SweetLostFoundAdminParam;
import com.liquidnet.service.sweet.param.ValidationGroups;
import com.liquidnet.service.sweet.service.ISweetLostFoundAdminService;
import com.liquidnet.service.sweet.vo.SweetLostFoundAdminVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 失物招领管理员Controller
*
* @author liquidnet
* @since 2025-01-18
*/
@RestController
@RequestMapping("/lost-found/admin")
@Api(value = "失物招领管理员管理", tags = "失物招领管理员管理")
@Validated
public class SweetLostFoundAdminController {
@Autowired
private ISweetLostFoundAdminService sweetLostFoundAdminService;
@PostMapping("/add")
@ApiOperation("添加管理员")
public ResponseDto<Boolean> addAdmin(@RequestBody @Validated SweetLostFoundAdminParam admin) {
return sweetLostFoundAdminService.addAdmin(admin);
}
@PutMapping("/update")
@ApiOperation("编辑管理员")
public ResponseDto<Boolean> updateAdmin(@RequestBody @Validated({ValidationGroups.Update.class}) SweetLostFoundAdminParam admin) {
return sweetLostFoundAdminService.editAdmin(admin);
}
@DeleteMapping("/delete/{id}")
@ApiOperation("删除管理员")
public ResponseDto<Boolean> deleteAdmin(
@ApiParam("管理员ID") @PathVariable Long id) {
return ResponseDto.success(sweetLostFoundAdminService.deleteAdmin(id));
}
@GetMapping("/detail/{id}")
@ApiOperation("获取管理员详情")
public ResponseDto<SweetLostFoundAdminVo> getAdminDetail(
@ApiParam("管理员ID") @PathVariable Long id) {
return ResponseDto.success(sweetLostFoundAdminService.getAdminDetail(id));
}
@GetMapping("/list/{performanceId}")
@ApiOperation("获取管理员列表")
public ResponseDto<List<SweetLostFoundAdminVo>> getAdminList(@ApiParam("演出ID") @PathVariable String performanceId) {
return ResponseDto.success(sweetLostFoundAdminService.getAdminList(performanceId));
}
@GetMapping("/permission/{phone}/{performanceId}")
@ApiOperation("获取权限")
/**
* 1. 删除不能图简单直接删除两个 key 这样容易删除单站把全站的也删除掉
* 2. 不能再读取的时候读不到在查 sql 再写入 redis 这里的情况不适用,没权限的用户导致一直查 sql 了
* 另外还会导致因为权限混在一起,crud 的时候考虑的会太复杂,现在分开处理逻辑就简单些,所以要在 cu的写入 redis
*/
public ResponseDto<SweetLostFoundAdminVo> getPermission(
@ApiParam("手机号") @PathVariable String phone,
@ApiParam("演出ID") @PathVariable String performanceId) {
return ResponseDto.success(sweetLostFoundAdminService.hasPermission(phone, performanceId));
}
}
\ No newline at end of file
package com.liquidnet.service.sweet.controller;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.sweet.param.SweetLostFoundItemParam;
import com.liquidnet.service.sweet.param.ValidationGroups;
import com.liquidnet.service.sweet.service.ISweetLostFoundItemService;
import com.liquidnet.service.sweet.vo.SweetLostFoundItemVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 失物招领信息Controller
*
* @author liquidnet
* @since 2025-01-18
*/
@RestController
@RequestMapping("/lost-found/item")
@Api(value = "失物招领信息管理", tags = "失物招领信息管理")
@Validated
public class SweetLostFoundItemController {
@Autowired
private ISweetLostFoundItemService sweetLostFoundItemService;
@PostMapping("/publish")
@ApiOperation("发布失物信息")
public ResponseDto<Boolean> publishItem(@RequestBody @Validated SweetLostFoundItemParam item) {
return ResponseDto.success(sweetLostFoundItemService.publishItem(item));
}
@PutMapping("/update")
@ApiOperation("编辑失物信息")
public ResponseDto<Boolean> updateItem(@RequestBody @Validated({ValidationGroups.Update.class}) SweetLostFoundItemParam item) {
return ResponseDto.success(sweetLostFoundItemService.editItem(item));
}
@DeleteMapping("/delete/{itemId}")
@ApiOperation("删除失物信息")
public ResponseDto<Boolean> deleteItem(
@ApiParam("失物信息ID") @PathVariable Long itemId) {
return ResponseDto.success(sweetLostFoundItemService.deleteItem(itemId));
}
@GetMapping("/detail/{itemId}")
@ApiOperation("获取失物信息详情")
public ResponseDto<SweetLostFoundItemVo> getItemDetail(
@ApiParam("失物信息ID") @PathVariable Long itemId) {
return ResponseDto.success(sweetLostFoundItemService.getItemDetail(itemId));
}
@GetMapping("/list")
@ApiOperation("获取失物信息列表")
public ResponseDto<List<SweetLostFoundItemVo>> getItemList(
@ApiParam("物品类型") @RequestParam(required = false) Integer itemType,
@ApiParam("演出ID") @RequestParam String performanceId
) {
return ResponseDto.success(sweetLostFoundItemService.getItemList(itemType, performanceId));
}
}
\ No newline at end of file
......@@ -11,7 +11,10 @@ import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@Api(tags = "小程序-公众号登陆相关")
@RestController
......@@ -25,18 +28,20 @@ public class SweetWechatLoginController {
@GetMapping("userInfo")
@ApiOperation("小程序解密手机号")
@ApiImplicitParams({
@ApiImplicitParam(type = "query", dataType = "String", name = "code", value = "微信code", required = true),
@ApiImplicitParam(type = "query", dataType = "String", name = "encryptedData", value = "encryptedData", required = true),
@ApiImplicitParam(type = "query", dataType = "String", name = "iv", value = "iv", required = true),
@ApiImplicitParam(type = "query", dataType = "Integer", name = "type", value = "1草莓 2五百里 3mdsk 4正在 5跳飞船音乐节 6小家伙"),
@ApiImplicitParam(type = "query", dataType = "String", name = "userCode", value = " 获取 uid oid的 code"),
@ApiImplicitParam(type = "query", dataType = "String", name = "code", value = "获取手机号的 code", required = true),
@ApiImplicitParam(type = "query", dataType = "String", name = "encryptedData", value = "encryptedData"),
@ApiImplicitParam(type = "query", dataType = "String", name = "iv", value = "iv"),
@ApiImplicitParam(type = "query", dataType = "Integer", name = "type", value = "1草莓 2五百里 3mdsk 4正在 5跳飞船音乐节 6小家伙", required = true),
})
public ResponseDto userInfo(
@RequestParam(required = false) String userCode,
@RequestParam() String code,
@RequestParam() String encryptedData,
@RequestParam() String iv,
@RequestParam(required = false) String encryptedData,
@RequestParam(required = false) String iv,
@RequestParam(defaultValue = "1") Integer type
) {
return sweetLoginService.userInfo(code, encryptedData, iv, type);
return sweetLoginService.userInfo(userCode, code, encryptedData, iv, type);
}
@ApiOperation(value = "小程序获取openid", notes = "这里仅用于获取OPENID使用")
......
package com.liquidnet.service.sweet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.sweet.entity.SweetLostFoundAdmin;
import com.liquidnet.service.sweet.mapper.SweetLostFoundAdminMapper;
import com.liquidnet.service.sweet.param.SweetLostFoundAdminParam;
import com.liquidnet.service.sweet.service.ISweetLostFoundAdminService;
import com.liquidnet.service.sweet.utils.LostFoundRedisUtils;
import com.liquidnet.service.sweet.vo.SweetLostFoundAdminVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
/**
* 失物招领管理员服务实现类
*
* @author liquidnet
* @since 2025-01-18
*/
@Service
public class SweetLostFoundAdminServiceImpl extends ServiceImpl<SweetLostFoundAdminMapper, SweetLostFoundAdmin> implements ISweetLostFoundAdminService {
@Autowired
private LostFoundRedisUtils lostFoundRedisUtils;
@Override
public ResponseDto<Boolean> addAdmin(SweetLostFoundAdminParam admin) {
String phone = admin.getPhone().trim();
String performanceId = admin.getPerformanceId().trim();
Integer authScope = admin.getAuthScope();
// 统一查询:检查当前手机号在所有相关场景下的冲突
QueryWrapper<SweetLostFoundAdmin> conflictWrapper = new QueryWrapper<>();
conflictWrapper.eq("phone", phone)
.eq("is_deleted", 0);
// 规则1:如果创建的是全站管理员,检查是否已存在全站管理员
if (authScope != null && authScope == 2) {
conflictWrapper.eq("auth_scope", 2);
}
// 规则2:如果创建的是特定演出管理员,检查是否已存在该演出记录或全站管理员
else {
conflictWrapper.and(wrapper ->
wrapper.eq("performance_id", performanceId)
.or()
.eq("auth_scope", 2)
);
}
if (baseMapper.selectCount(conflictWrapper) > 0) {
return ResponseDto.failure("该手机号已存在");
}
SweetLostFoundAdmin foundAdmin = SweetLostFoundAdmin.getNew();
foundAdmin.setAdminId(IDGenerator.nextSnowId());
foundAdmin.setPhone(phone);
foundAdmin.setName(admin.getName());
foundAdmin.setPermissionType(admin.getPermissionType());
foundAdmin.setAuthScope(admin.getAuthScope());
foundAdmin.setPerformanceId(performanceId);
boolean result = baseMapper.insert(foundAdmin) > 0;
SweetLostFoundAdminVo vo = new SweetLostFoundAdminVo();
BeanUtils.copyProperties(foundAdmin, vo);
lostFoundRedisUtils.setAdminCache(phone, performanceId, vo);
return ResponseDto.success(result);
}
// 假设:
// - 已存在记录:phone=13800138000, performanceId="A", authScope=1
// - 现在创建:phone=13800138000, performanceId="B", authScope=2
//
// 当前写法:允许创建(因为只在全站管理员场景检查)
// 建议写法:会报错(因为会查到performanceId="A"的记录)
// 假设:
// - 已存在记录:phone=13800138000, performanceId="A", authScope=2
// - 现在创建:phone=13800138000, performanceId="B", authScope=1
//
// 当前行为:会允许创建,但这可能不符合业务需求
@Override
public ResponseDto<Boolean> editAdmin(SweetLostFoundAdminParam admin) {
Long id = admin.getId();
String phone = admin.getPhone().trim();
String performanceId = admin.getPerformanceId().trim();
Integer authScope = admin.getAuthScope();
// 检查要修改的管理员是否存在
SweetLostFoundAdmin existingAdmin = baseMapper.selectById(id);
if (existingAdmin == null || existingAdmin.getIsDeleted() == 1) {
return ResponseDto.failure("管理员记录不存在或已删除");
}
// 统一查询:检查修改后手机号在所有相关场景下的冲突(排除自身)
QueryWrapper<SweetLostFoundAdmin> conflictWrapper = new QueryWrapper<>();
conflictWrapper.eq("phone", phone)
.ne("id", id)
.eq("is_deleted", 0);
// 规则1:如果修改为全站管理员,检查是否已存在全站管理员
if (authScope != null && authScope == 2) {
conflictWrapper.eq("auth_scope", 2);
}
// 规则2:如果修改为特定演出管理员,检查是否已存在该演出记录或全站管理员
else {
conflictWrapper.and(wrapper ->
wrapper.eq("performance_id", performanceId)
.or()
.eq("auth_scope", 2)
);
}
if (baseMapper.selectCount(conflictWrapper) > 0) {
return ResponseDto.failure("该手机号已存在");
}
SweetLostFoundAdmin foundAdmin = SweetLostFoundAdmin.getNew();
foundAdmin.setId(id);
foundAdmin.setPhone(phone);
foundAdmin.setName(admin.getName());
foundAdmin.setPermissionType(admin.getPermissionType());
foundAdmin.setAuthScope(admin.getAuthScope());
foundAdmin.setPerformanceId(performanceId);
// 缓存
SweetLostFoundAdminVo vo = new SweetLostFoundAdminVo();
BeanUtils.copyProperties(foundAdmin, vo);
// 因为可能会更改权限范围 写入有范围的判断 所以直接删除老的
lostFoundRedisUtils.deleteAdminCache(existingAdmin.getPhone(), existingAdmin.getPerformanceId(), existingAdmin.getAuthScope());
lostFoundRedisUtils.setAdminCache(phone, performanceId, vo);
return ResponseDto.success(baseMapper.updateById(foundAdmin) > 0);
}
@Override
public boolean deleteAdmin(Long id) {
// 检查管理员是否存在
SweetLostFoundAdmin admin = baseMapper.selectById(id);
if (admin == null) {
return false;
}
// 逻辑删除:更新is_deleted字段为1
admin.setIsDeleted(1);
lostFoundRedisUtils.deleteAdminCache(admin.getPhone(), admin.getPerformanceId(), admin.getAuthScope());
return baseMapper.updateById(admin) > 0;
}
@Override
public SweetLostFoundAdminVo getAdminDetail(Long id) {
SweetLostFoundAdmin admin = baseMapper.selectById(id);
if (admin == null || admin.getIsDeleted() == 1) {
return null;
}
SweetLostFoundAdminVo vo = new SweetLostFoundAdminVo();
BeanUtils.copyProperties(admin, vo);
return vo;
}
@Override
public List<SweetLostFoundAdminVo> getAdminList(String performanceId) {
// 构建查询条件
QueryWrapper<SweetLostFoundAdmin> queryWrapper = new QueryWrapper<>();
// 过滤逻辑删除的记录
queryWrapper.eq("is_deleted", 0);
// 查询条件:performanceId = 指定演出ID OR authScope = 2(全站)
queryWrapper.and(wrapper ->
wrapper.eq("performance_id", performanceId.trim())
.or()
.eq("auth_scope", 2)
);
// 默认按创建时间降序
queryWrapper.orderByDesc("create_time");
// 执行查询
List<SweetLostFoundAdmin> adminList = baseMapper.selectList(queryWrapper);
// 转换为VO对象
List<SweetLostFoundAdminVo> voList = adminList.stream()
.map(admin -> {
SweetLostFoundAdminVo vo = new SweetLostFoundAdminVo();
BeanUtils.copyProperties(admin, vo);
return vo;
})
.collect(Collectors.toList());
return voList;
}
@Override
public SweetLostFoundAdminVo hasPermission(String phone, String performanceId) {
SweetLostFoundAdminVo adminCache = lostFoundRedisUtils.getAdminCache(phone, performanceId);
// if (adminCache == null) {
// QueryWrapper<SweetLostFoundAdmin> queryWrapper = new QueryWrapper<>();
// queryWrapper.eq("phone", phone.trim())
// .eq("is_deleted", 0);
// queryWrapper.and(wrapper ->
// wrapper.eq("performance_id", performanceId.trim())
// .or()
// .eq("auth_scope", 2)
// );
// SweetLostFoundAdmin admin = baseMapper.selectOne(queryWrapper);
// if (admin == null) {
// return null;
// }
// SweetLostFoundAdminVo vo = new SweetLostFoundAdminVo();
// BeanUtils.copyProperties(admin, vo);
// lostFoundRedisUtils.setAdminCache(phone, performanceId, vo);
// return vo;
// }
return adminCache;
}
}
\ No newline at end of file
package com.liquidnet.service.sweet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.service.sweet.entity.SweetLostFoundItem;
import com.liquidnet.service.sweet.mapper.SweetLostFoundItemMapper;
import com.liquidnet.service.sweet.param.SweetLostFoundItemParam;
import com.liquidnet.service.sweet.service.ISweetLostFoundItemService;
import com.liquidnet.service.sweet.utils.LostFoundRedisUtils;
import com.liquidnet.service.sweet.vo.SweetLostFoundItemVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
/**
* 失物招领信息服务实现类
*
* @author liquidnet
* @since 2025-01-18
*/
@Service
public class SweetLostFoundItemServiceImpl extends ServiceImpl<SweetLostFoundItemMapper, SweetLostFoundItem> implements ISweetLostFoundItemService {
@Autowired
private LostFoundRedisUtils lostFoundRedisUtils;
@Override
public boolean publishItem(SweetLostFoundItemParam item) {
if (item == null) {
return false;
}
SweetLostFoundItem lostFoundItem = SweetLostFoundItem.getNew();
lostFoundItem.setItemId(IDGenerator.nextSnowId());
BeanUtils.copyProperties(item, lostFoundItem);
lostFoundRedisUtils.deleteItemListCache(item.getPerformanceId());
return baseMapper.insert(lostFoundItem) > 0;
}
@Override
public boolean editItem(SweetLostFoundItemParam item) {
if (item == null || item.getId() == null) {
return false;
}
SweetLostFoundItem lostFoundItem = SweetLostFoundItem.getNew();
BeanUtils.copyProperties(item, lostFoundItem);
lostFoundRedisUtils.deleteItemListCache(item.getPerformanceId());
lostFoundRedisUtils.deleteItemDetailCache(item.getId());
return baseMapper.updateById(lostFoundItem) > 0;
}
@Override
public boolean deleteItem(Long id) {
if (id == null) {
return false;
}
// 检查物品是否存在
SweetLostFoundItem item = baseMapper.selectById(id);
if (item == null || item.getIsDeleted() == 1) {
return false;
}
item.setIsDeleted(1);
lostFoundRedisUtils.deleteItemListCache(item.getPerformanceId());
return baseMapper.updateById(item) > 0;
}
@Override
public SweetLostFoundItemVo getItemDetail(Long id) {
if (id == null) {
return null;
}
SweetLostFoundItemVo itemDetail = lostFoundRedisUtils.getItemDetail(id);
if (itemDetail == null) {
SweetLostFoundItem item = baseMapper.selectById(id);
if (item == null || item.getIsDeleted() == 1) {
return null;
}
SweetLostFoundItemVo vo = new SweetLostFoundItemVo();
BeanUtils.copyProperties(item, vo);
lostFoundRedisUtils.setItemDetail(id, vo);
return vo;
}
return itemDetail;
}
@Override
public List<SweetLostFoundItemVo> getItemList(Integer itemType, String performanceId) {
List<SweetLostFoundItemVo> itemList = lostFoundRedisUtils.getItemList(performanceId, itemType);
if (itemList == null || itemList.isEmpty()) {
QueryWrapper<SweetLostFoundItem> queryWrapper = new QueryWrapper<>();
// 过滤
queryWrapper.eq("is_deleted", 0);
queryWrapper.eq("performance_id", performanceId.trim());
// 排序
queryWrapper.orderByDesc("create_time");
// 执行查询
List<SweetLostFoundItem> items = baseMapper.selectList(queryWrapper);
// 转换为VO对象列表
List<SweetLostFoundItemVo> itemVos = items.stream()
.map(item -> {
SweetLostFoundItemVo vo = new SweetLostFoundItemVo();
BeanUtils.copyProperties(item, vo);
return vo;
})
.collect(Collectors.toList());
lostFoundRedisUtils.setItemList(performanceId, itemVos);
if(null == itemType) {
return itemVos;
}
return itemVos.stream()
.filter(item -> itemType.equals(item.getItemType()))
.collect(Collectors.toList());
}
return itemList;
}
}
\ No newline at end of file
......@@ -12,13 +12,11 @@ import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.feign.adam.api.FeignAdamBaseClient;
import com.liquidnet.service.feign.stone.api.FeignStoneIntegralClient;
import com.liquidnet.service.sweet.dto.vo.WechatTokenInfoVo;
import com.liquidnet.service.sweet.dto.vo.WechatUserInfoVo;
import com.liquidnet.service.sweet.utils.QueueUtils;
import com.liquidnet.service.sweet.utils.WechatUsersRedisUtils;
import com.liquidnet.service.sweet.vo.SweetAppletUsersVo;
import com.liquidnet.service.sweet.vo.SweetWechatUsersVo;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.bean.WxOAuth2UserInfo;
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
......@@ -58,20 +56,29 @@ public class SweetWechatLoginServiceImpl {
@Lazy
private FeignAdamBaseClient feignAdamBaseClient;
public ResponseDto userInfo(String code, String encryptedData, String iv, Integer type) {
public ResponseDto userInfo(String userCode, String code, String encryptedData, String iv, Integer type) {
log.info("小程序解密用户信息参数:[code=[{}], encryptedData=[{}], [iv=[{}], type=[{}]", code, encryptedData, iv, type);
try {
// 获取unid openid
WxMaJscode2SessionResult sessionInfo = sweetWechatService.sessionInfo(code, type);
if (null == sessionInfo) {
WxMaJscode2SessionResult sessionInfo = null;
WxMaPhoneNumberInfo wxMaPhoneNumberInfo = null;
String unionId = null;
String openId = null;
if (type == 1 && Objects.isNull(encryptedData)) {
// 获取unid openid
sessionInfo = sweetWechatService.sessionInfo(userCode, type);
// 解密手机号码信息
wxMaPhoneNumberInfo = sweetWechatService.getPhoneNumber(code, type);
} else {
sessionInfo = sweetWechatService.sessionInfo(code, type);
wxMaPhoneNumberInfo = sweetWechatService.phoneNumberInfo(sessionInfo.getSessionKey(), encryptedData, iv, type);
}
if (Objects.isNull(sessionInfo)) {
return ResponseDto.failure("login handler error");
}
String unionId = sessionInfo.getUnionid();
String openId = sessionInfo.getOpenid();
// 解密手机号码信息
WxMaPhoneNumberInfo wxMaPhoneNumberInfo = sweetWechatService.phoneNumberInfo(sessionInfo.getSessionKey(), encryptedData, iv, type);
unionId = sessionInfo.getUnionid();
openId = sessionInfo.getOpenid();
if (Objects.isNull(wxMaPhoneNumberInfo) || StringUtils.isBlank(wxMaPhoneNumberInfo.getPhoneNumber())) {
return ResponseDto.failure("解密手机信息失败");
return ResponseDto.failure("获取手机信息失败");
}
String phoneNumber = wxMaPhoneNumberInfo.getPhoneNumber();
String purePhoneNumber = wxMaPhoneNumberInfo.getPurePhoneNumber();
......
......@@ -43,6 +43,16 @@ public class SweetWechatService {
return wxMaService.getUserService().getPhoneNoInfo(sessionKey, encryptedData, iv);
}
public WxMaPhoneNumberInfo getPhoneNumber(String code, Integer anum) {
WxMaService wxMaService = wechatMaConfigure.getWxMaService(anum);
try {
return wxMaService.getUserService().getPhoneNumber(code);
} catch (Exception e) {
log.error("getPhoneNumber error", e);
return null;
}
}
/**
* 服务号--------------
*/
......
package com.liquidnet.service.sweet.utils;
import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.service.sweet.vo.SweetLostFoundAdminVo;
import com.liquidnet.service.sweet.vo.SweetLostFoundItemVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.stream.Collectors;
/**
* 失物招领Redis缓存工具类
*
* @author liquidnet
* @since 2025-01-18
*/
@Slf4j
@Component
public class LostFoundRedisUtils {
@Autowired
private RedisUtil redisUtil;
// Redis key前缀
private static final String LOST_FOUND_KEY_PREFIX = "sweet:lost_found:";
private static final String ITEM_LIST_KEY = LOST_FOUND_KEY_PREFIX + "item_list:";
private static final String ITEM_DETAIL_KEY = LOST_FOUND_KEY_PREFIX + "item_detail:";
private static final String ADMIN_DETAIL_KEY = LOST_FOUND_KEY_PREFIX + "admin_detail:";
// 缓存过期时间(秒)
private static final long LIST_EXPIRE_TIME = 432000; // 5天
private static final long DETAIL_EXPIRE_TIME = 432000; // 5天
/**
* 获取失物信息列表缓存
*
* @param performanceId 演出ID
* @param itemType 物品类型(可选,null表示全部)
* @return 失物信息列表
*/
public List<SweetLostFoundItemVo> getItemList(String performanceId, Integer itemType) {
try {
String key = buildItemListKey(performanceId);
Object cachedValue = redisUtil.get(key);
if (cachedValue != null) {
List<SweetLostFoundItemVo> allItems = (List<SweetLostFoundItemVo>) cachedValue;
// 如果指定了itemType,进行筛选
if (itemType != null) {
return allItems.stream()
.filter(item -> itemType.equals(item.getItemType()))
.collect(Collectors.toList());
}
return allItems;
}
} catch (Exception e) {
log.error("获取失物信息列表缓存失败", e);
}
return null;
}
/**
* 设置失物信息列表缓存
*
* @param performanceId 演出ID
* @param itemList 失物信息列表
*/
public void setItemList(String performanceId, List<SweetLostFoundItemVo> itemList) {
try {
String key = buildItemListKey(performanceId);
redisUtil.set(key, itemList, LIST_EXPIRE_TIME);
} catch (Exception e) {
log.error("设置失物信息列表缓存失败", e);
}
}
/**
* 获取失物信息详情缓存
*
* @param itemId 物品ID
* @return 失物信息详情
*/
public SweetLostFoundItemVo getItemDetail(Long itemId) {
try {
String key = ITEM_DETAIL_KEY + itemId;
Object cachedValue = redisUtil.get(key);
if (cachedValue != null) {
return (SweetLostFoundItemVo) cachedValue;
}
} catch (Exception e) {
log.error("获取失物信息详情缓存失败", e);
}
return null;
}
/**
* 设置失物信息详情缓存
*
* @param itemId 物品ID
* @param itemDetail 失物信息详情
*/
public void setItemDetail(Long itemId, SweetLostFoundItemVo itemDetail) {
try {
String key = ITEM_DETAIL_KEY + itemId;
redisUtil.set(key, itemDetail, DETAIL_EXPIRE_TIME);
} catch (Exception e) {
log.error("设置失物信息详情缓存失败", e);
}
}
/**
* 删除失物信息列表缓存
*
* @param performanceId 演出ID
*/
public void deleteItemListCache(String performanceId) {
try {
String key = buildItemListKey(performanceId);
redisUtil.del(key);
} catch (Exception e) {
log.error("删除失物信息列表缓存失败", e);
}
}
/**
* 删除失物信息详情缓存
*
* @param itemId 物品ID
*/
public void deleteItemDetailCache(Long itemId) {
try {
String key = ITEM_DETAIL_KEY + itemId;
redisUtil.del(key);
} catch (Exception e) {
log.error("删除失物信息详情缓存失败", e);
}
}
/**
* 构建失物信息列表缓存key
*
* @param performanceId 演出ID
* @return 缓存key
*/
private String buildItemListKey(String performanceId) {
return ITEM_LIST_KEY + performanceId;
}
/*private String buildItemListKey(String performanceId) {
StringBuilder keyBuilder = new StringBuilder(ITEM_LIST_KEY);
keyBuilder.append(performanceId);
return keyBuilder.toString();
}*/
/**
* 检查管理员是否存在
*
* @param phone 手机号
* @param performanceId 演出ID
* @return 是否存在
*/
public SweetLostFoundAdminVo getAdminCache(String phone, String performanceId) {
try {
// 优先检查全站管理员缓存
String globalKey = ADMIN_DETAIL_KEY + phone + ":global";
Object globalCache = redisUtil.get(globalKey);
if (globalCache != null) {
return (SweetLostFoundAdminVo) globalCache;
}
// 检查特定演出管理员缓存
String specificKey = ADMIN_DETAIL_KEY + phone + ":" + performanceId;
Object specificCache = redisUtil.get(specificKey);
if (specificCache != null) {
return (SweetLostFoundAdminVo) specificCache;
}
} catch (Exception e) {
log.error("检查管理员缓存失败", e);
}
return null;
}
/**
* 设置管理员缓存
*
* @param phone 手机号
* @param performanceId 演出ID
* @param vo 管理员信息
*/
public void setAdminCache(String phone, String performanceId, SweetLostFoundAdminVo vo) {
try {
if (vo.getAuthScope() != null && vo.getAuthScope() == 2) {
// 全站管理员使用全局缓存键
String globalKey = ADMIN_DETAIL_KEY + phone + ":global";
redisUtil.set(globalKey, vo, DETAIL_EXPIRE_TIME);
} else {
// 特定演出管理员使用演出特定的缓存键
String specificKey = ADMIN_DETAIL_KEY + phone + ":" + performanceId;
redisUtil.set(specificKey, vo, DETAIL_EXPIRE_TIME);
}
} catch (Exception e) {
log.error("设置管理员缓存失败", e);
}
}
/**
* 删除管理员缓存
*
* @param phone 手机号
* @param performanceId 演出ID
*/
public void deleteAdminCache(String phone, String performanceId, Integer authScope) {
try {
if (authScope != null && authScope == 1) {
// 删除特定演出管理员缓存
String specificKey = ADMIN_DETAIL_KEY + phone + ":" + performanceId;
redisUtil.del(specificKey);
} else if (authScope != null && authScope == 2) {
// 删除全站管理员缓存
String globalKey = ADMIN_DETAIL_KEY + phone + ":global";
redisUtil.del(globalKey);
} else {
String specificKey = ADMIN_DETAIL_KEY + phone + ":" + performanceId;
redisUtil.del(specificKey);
String globalKey = ADMIN_DETAIL_KEY + phone + ":global";
redisUtil.del(globalKey);
}
} catch (Exception e) {
log.error("删除管理员缓存失败", e);
}
}
}
\ No newline at end of file
......@@ -280,7 +280,7 @@
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-miniapp</artifactId>
<version>4.1.0</version>
<version>4.7.0</version>
</dependency>
<dependency>
<groupId>com.github.binarywang</groupId>
......
......@@ -20,7 +20,7 @@ liquidnet:
# username: admin
# password: admin
config:
# location: /Users/hujiachen/IdeaProjects/liquidnet-bus-v1/liquidnet-bus-config/liquidnet-config
# location: /Users/jiangxiulong/IdeaProjects/liquidnet-bus-v1/liquidnet-bus-config/liquidnet-config
location: /app/support-config
# end-dev-这里是配置信息基本值
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment