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

Commit 7b423be9 authored by 姜秀龙's avatar 姜秀龙

LostFoundAdmin

parent bbf05886
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;
/**
* <p>
* xx 服务实现类
* </p>
*
* @author jiangxiulong
* @since 2025-08-20 13:13
*/
public class ValidationGroups {
public interface Create {}
public interface Update {}
public interface Delete {}
public interface Query {}
}
package com.liquidnet.service.sweet.service;
import com.baomidou.mybatisplus.extension.service.IService;
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 是否成功
*/
boolean addAdmin(SweetLostFoundAdminParam admin);
/**
* 编辑管理员
*
* @param admin 管理员信息
* @return 是否成功
*/
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);
}
\ 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.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.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
-- 草莓演出失物招领功能数据库表结构
-- 创建时间: 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(120) NOT NULL DEFAULT '' COMMENT '物品描述,最多120字',
`pickup_location` tinyint(1) NOT NULL DEFAULT 1 COMMENT '拾捡地:1-音乐节现场 2-其他',
`pickup_date` date NOT NULL COMMENT '捡拾日期',
`item_type` tinyint(1) NOT NULL DEFAULT 1 COMMENT '物品类型:1-证件卡类 2-3C数码类 3-服饰类 4-其他',
`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_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 ResponseDto.success(sweetLostFoundAdminService.addAdmin(admin));
}
@PutMapping("/update")
@ApiOperation("编辑管理员")
public ResponseDto<Boolean> updateAdmin(@RequestBody @Validated({ValidationGroups.Update.class}) SweetLostFoundAdminParam admin) {
return ResponseDto.success(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));
}
}
\ 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.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.vo.SweetLostFoundAdminVo;
import org.springframework.beans.BeanUtils;
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 {
@Override
public boolean addAdmin(SweetLostFoundAdminParam admin) {
SweetLostFoundAdmin foundAdmin = SweetLostFoundAdmin.getNew();
foundAdmin.setAdminId(IDGenerator.nextSnowId());
foundAdmin.setPhone(admin.getPhone());
foundAdmin.setName(admin.getName());
foundAdmin.setPermissionType(admin.getPermissionType());
foundAdmin.setAuthScope(admin.getAuthScope());
foundAdmin.setPerformanceId(admin.getPerformanceId());
return baseMapper.insert(foundAdmin) > 0;
}
@Override
public boolean editAdmin(SweetLostFoundAdminParam admin) {
SweetLostFoundAdmin foundAdmin = SweetLostFoundAdmin.getNew();
foundAdmin.setId(admin.getId());
foundAdmin.setPhone(admin.getPhone());
foundAdmin.setName(admin.getName());
foundAdmin.setPermissionType(admin.getPermissionType());
foundAdmin.setAuthScope(admin.getAuthScope());
foundAdmin.setPerformanceId(admin.getPerformanceId());
return 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);
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(全站)
if (performanceId != null && !performanceId.trim().isEmpty()) {
queryWrapper.and(wrapper ->
wrapper.eq("performance_id", performanceId.trim())
.or()
.eq("auth_scope", 2)
);
} else {
// 如果没有performanceId,只查authScope=2的全站管理员
queryWrapper.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;
}
}
\ No newline at end of file
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