New file |
| | |
| | | package cn.lili.modules.lmk.domain.entity; |
| | | |
| | | import cn.lili.mybatis.BaseEntity; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 活动 |
| | | */ |
| | | @Data |
| | | @TableName("lmk_activity") |
| | | public class Activity extends BaseEntity { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** 活动名称 */ |
| | | @TableField("activity_name") |
| | | private String activityName; |
| | | |
| | | /** 活动类型 */ |
| | | @TableField("activity_type") |
| | | private String activityType; |
| | | |
| | | /** 报名开始时间 */ |
| | | @TableField("report_start_time") |
| | | private Date reportStartTime; |
| | | |
| | | /** 报名结束时间 */ |
| | | @TableField("report_end_time") |
| | | private Date reportEndTime; |
| | | |
| | | /** 活动开始时间 */ |
| | | @TableField("start_time") |
| | | private Date startTime; |
| | | |
| | | /** 活动结束时间 */ |
| | | @TableField("end_time") |
| | | private Date endTime; |
| | | |
| | | /** 活动状态 */ |
| | | @TableField("status") |
| | | private String status; |
| | | |
| | | /** 是否推荐 */ |
| | | @TableField("recommend") |
| | | private Boolean recommend; |
| | | |
| | | /** 封面地址 */ |
| | | @TableField("cover") |
| | | private String cover; |
| | | |
| | | /** 封面类型 */ |
| | | @TableField("cover_type") |
| | | private String coverType; |
| | | |
| | | /** 最大报名人数 */ |
| | | @TableField("limit_user_num") |
| | | private Integer limitUserNum; |
| | | |
| | | /** 活动地点 */ |
| | | @TableField("activity_location") |
| | | private String activityLocation; |
| | | |
| | | /** 活动内容 */ |
| | | @TableField("activity_content") |
| | | private String activityContent; |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.form; |
| | | |
| | | |
| | | import cn.lili.base.AbsForm; |
| | | import cn.lili.group.Add; |
| | | import cn.lili.group.Update; |
| | | import cn.lili.modules.lmk.domain.entity.Activity; |
| | | import cn.lili.modules.lmk.domain.entity.CustomerBlack; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.springframework.lang.NonNull; |
| | | |
| | | import javax.validation.constraints.NotBlank; |
| | | import javax.validation.constraints.NotNull; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @ApiModel(value = "Activity查询参数", description = "活动查表单") |
| | | public class ActivityForm extends AbsForm { |
| | | |
| | | /** 活动名称 */ |
| | | @NotBlank(message = "活动名称不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty(value = "活动名称", example = "春季徒步大会") |
| | | private String activityName; |
| | | |
| | | /** 活动类型 */ |
| | | @NotBlank(message = "活动类型不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty(value = "活动类型:线上/线下,目前默认都是线下", example = "线下") |
| | | private String activityType; |
| | | |
| | | /** 报名开始时间 */ |
| | | @NotNull(message = "报名开始时间不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty(value = "报名开始时间", example = "2025-05-20 09:00:00") |
| | | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date reportStartTime; |
| | | |
| | | /** 报名结束时间 */ |
| | | @NotNull(message = "报名结束时间不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty(value = "报名结束时间", example = "2025-05-25 18:00:00") |
| | | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date reportEndTime; |
| | | |
| | | /** 活动开始时间 */ |
| | | @NotNull(message = "活动开始时间不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty(value = "活动开始时间", example = "2025-06-01 08:30:00") |
| | | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date startTime; |
| | | |
| | | /** 活动结束时间 */ |
| | | @NotNull(message = "活动结束时间不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty(value = "活动结束时间", example = "2025-06-01 17:00:00") |
| | | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date endTime; |
| | | |
| | | /** 活动状态 */ |
| | | @NotBlank(message = "活动状态不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty(value = "活动状态") |
| | | private String status; |
| | | |
| | | /** 是否推荐 */ |
| | | @ApiModelProperty(value = "是否推荐(0-否,1-是)", example = "1") |
| | | private Boolean recommend; |
| | | |
| | | /** 封面地址 */ |
| | | @NotBlank(message = "封面图片不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty(value = "封面图片/视频地址", example = "/covers/spring_hike.jpg") |
| | | private String cover; |
| | | |
| | | /** 封面类型 */ |
| | | @NotBlank(message = "封面类型不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty(value = "封面类型:视频、文字、图片", example = "图片") |
| | | private String coverType; |
| | | |
| | | /** 最大报名人数 */ |
| | | @ApiModelProperty(value = "最大报名人数限制", example = "200") |
| | | private Integer limitUserNum; |
| | | |
| | | /** 活动地点 */ |
| | | @ApiModelProperty(value = "活动地点", example = "北京市朝阳区奥林匹克公园") |
| | | private String activityLocation; |
| | | |
| | | /** 活动内容 */ |
| | | @NotBlank(message = "活动详细内容不能为空", groups = {Add.class, Update.class}) |
| | | @ApiModelProperty(value = "活动详细内容(支持富文本)", example = "<p>活动流程:...</p>") |
| | | private String activityContent; |
| | | |
| | | public static Activity getEntityByForm(@NonNull ActivityForm form, Activity entity) { |
| | | if(entity == null) { |
| | | entity = new Activity(); |
| | | } |
| | | BeanUtils.copyProperties(form, entity); |
| | | return entity; |
| | | } |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.query; |
| | | |
| | | import cn.lili.base.AbsQuery; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @ApiModel(value = "Activity查询参数", description = "活动查询参数") |
| | | public class ActivityQuery extends AbsQuery { |
| | | /** |
| | | * 活动名 |
| | | */ |
| | | private String activityName; |
| | | /** |
| | | * 活动类型 |
| | | */ |
| | | private String activityType; |
| | | |
| | | /** |
| | | * 是否推荐 |
| | | */ |
| | | private Boolean recommend; |
| | | /** |
| | | * 报名开始时时间 |
| | | */ |
| | | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date reportStartTime; |
| | | /** |
| | | * 报名结束时间 |
| | | */ |
| | | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date reportEndTime; |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.domain.vo; |
| | | |
| | | |
| | | import cn.lili.base.AbsVo; |
| | | import cn.lili.modules.lmk.domain.entity.Activity; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import org.springframework.lang.NonNull; |
| | | |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @ApiModel(value = "Activity查询参数", description = "活动查表单") |
| | | public class ActivityVO extends AbsVo { |
| | | |
| | | /** 活动名称 */ |
| | | @ApiModelProperty(value = "活动名称", example = "春季徒步大会") |
| | | private String activityName; |
| | | |
| | | /** 活动类型 */ |
| | | @ApiModelProperty(value = "活动类型:线上/线下,目前默认都是线下", example = "线下") |
| | | private String activityType; |
| | | |
| | | /** 报名开始时间 */ |
| | | @ApiModelProperty(value = "报名开始时间", example = "2025-05-20 09:00:00") |
| | | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date reportStartTime; |
| | | |
| | | /** 报名结束时间 */ |
| | | @ApiModelProperty(value = "报名结束时间", example = "2025-05-25 18:00:00") |
| | | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date reportEndTime; |
| | | |
| | | /** 活动开始时间 */ |
| | | @ApiModelProperty(value = "活动开始时间", example = "2025-06-01 08:30:00") |
| | | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date startTime; |
| | | |
| | | /** 活动结束时间 */ |
| | | @ApiModelProperty(value = "活动结束时间", example = "2025-06-01 17:00:00") |
| | | @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date endTime; |
| | | |
| | | /** 活动状态 */ |
| | | @ApiModelProperty(value = "活动状态", example = "进行中/已结束/已取消") |
| | | private String status; |
| | | |
| | | /** 是否推荐 */ |
| | | @ApiModelProperty(value = "是否推荐(0-否,1-是)", example = "1") |
| | | private Boolean recommend; |
| | | |
| | | /** 封面地址 */ |
| | | @ApiModelProperty(value = "封面图片/视频地址", example = "/covers/spring_hike.jpg") |
| | | private String cover; |
| | | |
| | | /** 封面类型 */ |
| | | @ApiModelProperty(value = "封面类型:视频、文字、图片", example = "图片") |
| | | private String coverType; |
| | | |
| | | /** 最大报名人数 */ |
| | | @ApiModelProperty(value = "最大报名人数限制", example = "200") |
| | | private Integer limitUserNum; |
| | | |
| | | /** 活动地点 */ |
| | | @ApiModelProperty(value = "活动地点", example = "北京市朝阳区奥林匹克公园") |
| | | private String activityLocation; |
| | | |
| | | /** 活动内容 */ |
| | | @ApiModelProperty(value = "活动详细内容(支持富文本)", example = "<p>活动流程:...</p>") |
| | | private String activityContent; |
| | | |
| | | /** 资源路径*/ |
| | | private String url; |
| | | |
| | | |
| | | public static ActivityVO getVoByEntity(@NonNull Activity entity, ActivityVO vo) { |
| | | if(vo == null) { |
| | | vo = new ActivityVO(); |
| | | } |
| | | BeanUtils.copyProperties(entity, vo); |
| | | return vo; |
| | | } |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.mapper; |
| | | |
| | | import cn.lili.modules.lmk.domain.entity.Activity; |
| | | import cn.lili.modules.lmk.domain.entity.CustomerBlack; |
| | | import cn.lili.modules.lmk.domain.query.ActivityQuery; |
| | | import cn.lili.modules.lmk.domain.query.CustomerBlackQuery; |
| | | import cn.lili.modules.lmk.domain.vo.ActivityVO; |
| | | import cn.lili.modules.lmk.domain.vo.CustomerBlackVO; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * 活动 Mapper 接口 |
| | | * |
| | | * @author zxl |
| | | * @since 2025-05-15 |
| | | */ |
| | | @Mapper |
| | | public interface ActivityMapper extends BaseMapper<Activity> { |
| | | |
| | | /** |
| | | * id查找客户黑名单 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | ActivityVO getById(String id); |
| | | |
| | | /** |
| | | * 分页 |
| | | */ |
| | | IPage getPage(IPage page, @Param("query") ActivityQuery query); |
| | | |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.service; |
| | | |
| | | import cn.lili.base.Result; |
| | | import cn.lili.modules.lmk.domain.entity.Activity; |
| | | import cn.lili.modules.lmk.domain.form.ActivityForm; |
| | | import cn.lili.modules.lmk.domain.query.ActivityQuery; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface ActivityService extends IService<Activity> { |
| | | |
| | | /** |
| | | * 添加 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | Result add(ActivityForm form); |
| | | |
| | | /** |
| | | * 修改 |
| | | * @param form |
| | | * @return |
| | | */ |
| | | Result update(ActivityForm form); |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | Result remove(List<String> ids); |
| | | |
| | | /** |
| | | * id删除 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | Result removeById(String id); |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | Result page(ActivityQuery query); |
| | | |
| | | /** |
| | | * 根据id查找 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | Result detail(String id); |
| | | |
| | | /** |
| | | * 列表 |
| | | * @return |
| | | */ |
| | | Result all(); |
| | | |
| | | Result uploadObject(MultipartFile file); |
| | | |
| | | String getPreviewUrl(String fileKey); |
| | | |
| | | Result deleteObject(String fileKey); |
| | | |
| | | Result activityChangeStatus(ActivityForm form); |
| | | |
| | | Result activityChangeRecommend(ActivityForm form); |
| | | } |
New file |
| | |
| | | package cn.lili.modules.lmk.service.impl; |
| | | |
| | | import cn.lili.base.Result; |
| | | import cn.lili.modules.lmk.domain.entity.Activity; |
| | | import cn.lili.modules.lmk.domain.entity.CustomerBlack; |
| | | import cn.lili.modules.lmk.domain.entity.CustomerTagRef; |
| | | import cn.lili.modules.lmk.domain.form.ActivityForm; |
| | | import cn.lili.modules.lmk.domain.form.CustomerTagRefForm; |
| | | import cn.lili.modules.lmk.domain.query.ActivityQuery; |
| | | import cn.lili.modules.lmk.domain.vo.ActivityVO; |
| | | import cn.lili.modules.lmk.domain.vo.CustomerBlackVO; |
| | | import cn.lili.modules.lmk.mapper.ActivityMapper; |
| | | import cn.lili.modules.lmk.mapper.CustomerBlackMapper; |
| | | import cn.lili.modules.lmk.service.ActivityService; |
| | | import cn.lili.modules.lmk.service.LmkFileService; |
| | | import cn.lili.utils.PageUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import io.micrometer.core.instrument.util.StringUtils; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.Assert; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class ActivityServiceImpl extends ServiceImpl<ActivityMapper, Activity> implements ActivityService { |
| | | |
| | | private final ActivityMapper activityMapper; |
| | | |
| | | private final LmkFileService lmkFileService; |
| | | |
| | | @Override |
| | | public Result add(ActivityForm form) { |
| | | Activity entity = ActivityForm.getEntityByForm(form, null); |
| | | //默认新增活动为 |
| | | entity.setStatus("未开始"); |
| | | //默认不为推荐 |
| | | entity.setRecommend(false); |
| | | |
| | | baseMapper.insert(entity); |
| | | return Result.ok("添加成功"); |
| | | } |
| | | |
| | | @Override |
| | | public Result update(ActivityForm form) { |
| | | |
| | | Activity entity = baseMapper.selectById(form.getId()); |
| | | //判断修改前的封面类型是否为文本,文本不需要删除文件 |
| | | if (!"文字".equals(entity.getCoverType())){ |
| | | //判断路径是否改变 |
| | | if (!form.getCover().equals(entity.getCover())) { |
| | | //删除云服务器中旧的图片 |
| | | lmkFileService.deleteObject(entity.getCover()); |
| | | } |
| | | |
| | | } |
| | | // 为空抛IllegalArgumentException,做全局异常处理 |
| | | Assert.notNull(entity, "记录不存在"); |
| | | BeanUtils.copyProperties(form, entity); |
| | | |
| | | baseMapper.updateById(entity); |
| | | return Result.ok("修改成功"); |
| | | } |
| | | |
| | | @Override |
| | | public Result remove(List<String> ids) { |
| | | baseMapper.deleteBatchIds(ids); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | @Override |
| | | public Result removeById(String id) { |
| | | //删除,同时判断该对象的封面是否存在 ,存在则在云服务器删除 |
| | | ActivityVO vo = baseMapper.getById(id); |
| | | if (StringUtils.isNotEmpty(vo.getCover())){ |
| | | lmkFileService.deleteObject(vo.getCover()); |
| | | } |
| | | baseMapper.deleteById(id); |
| | | return Result.ok("删除成功"); |
| | | } |
| | | |
| | | @Override |
| | | public Result page(ActivityQuery query) { |
| | | IPage<ActivityVO> page = PageUtil.getPage(query, ActivityVO.class); |
| | | |
| | | baseMapper.getPage(page, query); |
| | | for (ActivityVO vo : page.getRecords()) { |
| | | if (!"文字".equals(vo.getCoverType())){ |
| | | String url = lmkFileService.getPreviewUrl(vo.getCover()); |
| | | vo.setUrl(url); |
| | | } |
| | | } |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |
| | | |
| | | @Override |
| | | public Result detail(String id) { |
| | | ActivityVO vo = baseMapper.getById(id); |
| | | Assert.notNull(vo, "记录不存在"); |
| | | return Result.ok().data(vo); |
| | | } |
| | | |
| | | @Override |
| | | public Result all() { |
| | | List<Activity> entities = baseMapper.selectList(null); |
| | | List<ActivityVO> vos = entities.stream() |
| | | .map(entity -> ActivityVO.getVoByEntity(entity, null)) |
| | | .collect(Collectors.toList()); |
| | | return Result.ok().data(vos); |
| | | } |
| | | |
| | | @Override |
| | | public Result uploadObject(MultipartFile file) { |
| | | return lmkFileService.uploadObject(file); |
| | | } |
| | | |
| | | @Override |
| | | public String getPreviewUrl(String fileKey) { |
| | | return lmkFileService.getPreviewUrl(fileKey); |
| | | } |
| | | |
| | | @Override |
| | | public Result deleteObject(String fileKey) { |
| | | return lmkFileService.deleteObject(fileKey); |
| | | } |
| | | |
| | | @Override |
| | | public Result activityChangeStatus(ActivityForm form) { |
| | | Activity entity = baseMapper.selectById(form.getId()); |
| | | entity.setStatus(form.getStatus()); |
| | | baseMapper.updateById(entity); |
| | | return Result.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public Result activityChangeRecommend(ActivityForm form) { |
| | | Activity entity = baseMapper.selectById(form.getId()); |
| | | entity.setRecommend(form.getRecommend()); |
| | | baseMapper.updateById(entity); |
| | | return Result.ok(); |
| | | } |
| | | } |
New 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="cn.lili.modules.lmk.mapper.ActivityMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="cn.lili.modules.lmk.domain.vo.ActivityVO"> |
| | | <result column="activity_name" property="activityName" /> |
| | | <result column="activity_type" property="activityType"/> |
| | | <result column="report_start_time" property="reportStartTime" /> |
| | | <result column="report_end_time" property="reportEndTime" /> |
| | | <result column="start_time" property="startTime" /> |
| | | |
| | | <result column="end_time" property="endTime" /> |
| | | <result column="status" property="status" /> |
| | | <result column="recommend" property="recommend" /> |
| | | <result column="cover" property="cover" /> |
| | | <result column="cover_type" property="coverType" /> |
| | | <result column="limit_user_num" property="limitUserNum" /> |
| | | <result column="activity_location" property="activityLocation" /> |
| | | <result column="activity_content" property="activityContent" /> |
| | | </resultMap> |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | <select id="getById" resultMap="BaseResultMap"> |
| | | SELECT |
| | | LA.id, |
| | | LA.activity_name, |
| | | LA.activity_type, |
| | | LA.report_start_time, |
| | | LA.report_end_time, |
| | | LA.start_time, |
| | | LA.end_time, |
| | | LA.status, |
| | | LA.recommend, |
| | | LA.cover, |
| | | LA.cover_type, |
| | | LA.limit_user_num, |
| | | LA.activity_location, |
| | | LA.activity_content |
| | | FROM |
| | | lmk_activity LA |
| | | WHERE |
| | | LA.id = #{id} AND LA.delete_flag = 0 |
| | | </select> |
| | | |
| | | |
| | | <select id="getPage" resultMap="BaseResultMap"> |
| | | SELECT |
| | | LA.id, |
| | | LA.activity_name, |
| | | LA.activity_type, |
| | | LA.report_start_time, |
| | | LA.report_end_time, |
| | | LA.start_time, |
| | | LA.end_time, |
| | | LA.status, |
| | | LA.recommend, |
| | | LA.cover, |
| | | LA.cover_type, |
| | | LA.limit_user_num, |
| | | LA.activity_location, |
| | | LA.activity_content |
| | | FROM |
| | | lmk_activity LA |
| | | WHERE |
| | | LA.delete_flag = 0 |
| | | <if test="query.activityName != null and query.activityName != ''">AND LA.activity_name LIKE CONCAT('%', #{query.activityName}, '%')</if> |
| | | <if test="query.activityType != null and query.activityType != ''">AND LA.activity_type LIKE CONCAT('%', #{query.activityType}, '%')</if> |
| | | <if test="query.recommend != null and query.recommend != ''">AND LA.recommend = #{recommend}</if> |
| | | <if test="query.reportStartTime != null">AND LA.report_start_time >= #{query.reportStartTime}</if> |
| | | <if test="query.reportEndTime != null">AND LA.report_end_time <= #{query.reportEndTime}</if> |
| | | </select> |
| | | |
| | | </mapper> |
New file |
| | |
| | | package cn.lili.controller.lmk; |
| | | |
| | | import cn.lili.base.Result; |
| | | import cn.lili.group.Add; |
| | | import cn.lili.group.Update; |
| | | import cn.lili.modules.lmk.domain.form.ActivityForm; |
| | | import cn.lili.modules.lmk.domain.form.CustomerBlackForm; |
| | | import cn.lili.modules.lmk.domain.query.ActivityQuery; |
| | | import cn.lili.modules.lmk.domain.query.CustomerBlackQuery; |
| | | import cn.lili.modules.lmk.service.ActivityService; |
| | | import cn.lili.modules.lmk.service.CustomerBlackService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 活动 前端控制器 |
| | | * |
| | | * @author zxl |
| | | * @since 2025-05-15 |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @Api(value = "活动", tags = "活动") |
| | | @RestController |
| | | @RequestMapping("/manager/activity") |
| | | public class ActivityController { |
| | | |
| | | private final ActivityService activityService; |
| | | |
| | | @PostMapping |
| | | @ApiOperation(value = "添加", notes = "添加") |
| | | public Result add(@RequestBody @Validated(Add.class) ActivityForm form) { |
| | | return activityService.add(form); |
| | | } |
| | | |
| | | @PutMapping |
| | | @ApiOperation(value = "修改", notes = "修改") |
| | | public Result update(@RequestBody @Validated(Update.class) ActivityForm form) { |
| | | return activityService.update(form); |
| | | } |
| | | |
| | | @DeleteMapping("/{id}") |
| | | @ApiOperation(value = "ID删除", notes = "ID删除") |
| | | public Result removeById(@PathVariable("id") String id) { |
| | | return activityService.removeById(id); |
| | | } |
| | | |
| | | @DeleteMapping("/batch") |
| | | @ApiOperation(value = "批量删除", notes = "批量删除") |
| | | public Result remove(@RequestBody @NotEmpty(message = "请选择数据") List<String> ids) { |
| | | return activityService.remove(ids); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @ApiOperation(value = "分页", notes = "分页") |
| | | public Result page(ActivityQuery query) { |
| | | return activityService.page(query); |
| | | } |
| | | |
| | | @GetMapping("/{idh }") |
| | | @ApiOperation(value = "详情", notes = "详情") |
| | | public Result detail(@PathVariable("id") String id) { |
| | | return activityService.detail(id); |
| | | } |
| | | |
| | | @GetMapping("/list") |
| | | @ApiOperation(value = "列表", notes = "列表") |
| | | public Result list() { |
| | | return activityService.all(); |
| | | } |
| | | |
| | | @PutMapping("/changeStatus") |
| | | @ApiOperation(value = "发布/下架", notes = "发布/下架") |
| | | public Result activityChangeStatus(@RequestBody ActivityForm form) { |
| | | return activityService.activityChangeStatus(form); |
| | | } |
| | | @PutMapping("/changeRecommend") |
| | | @ApiOperation(value = "推荐/取消推荐", notes = "推荐/取消推荐") |
| | | public Result activityChangeRecommend(@RequestBody ActivityForm form){ |
| | | return activityService.activityChangeRecommend(form); |
| | | } |
| | | } |
New file |
| | |
| | | package cn.lili.controller.lmk; |
| | | |
| | | import cn.lili.base.Result; |
| | | import cn.lili.modules.lmk.domain.vo.LmkFileVO; |
| | | import cn.lili.modules.lmk.service.ActivityService; |
| | | import cn.lili.modules.lmk.service.LmkFileService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.ibatis.annotations.Delete; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @RequestMapping("/manager/lmk/common") |
| | | @Slf4j |
| | | public class ManagerUploadController { |
| | | |
| | | |
| | | |
| | | private final ActivityService activityService; |
| | | |
| | | @PostMapping("/upload") |
| | | public Result handleFileUpload(@RequestPart("file") MultipartFile file) throws Exception { |
| | | System.out.println("开始上传"); |
| | | if (file == null) { |
| | | return Result.error("上传文件不能为空"); |
| | | } |
| | | System.out.println(file.getSize()); |
| | | System.out.println(file.getName()); |
| | | // 上传到云服务器 |
| | | Result result = activityService.uploadObject(file); |
| | | Object object = result.get("data"); |
| | | LmkFileVO lmkFileVO = null; |
| | | if (object != null) { |
| | | if (object instanceof LmkFileVO) { |
| | | lmkFileVO = (LmkFileVO) object; |
| | | //插入数据库 |
| | | return Result.ok().data(lmkFileVO); |
| | | |
| | | } else { |
| | | log.error("类型不匹配,期望:{} 实际:{}", |
| | | LmkFileVO.class.getName(), |
| | | object.getClass().getName()); |
| | | return Result.error("类型不匹配"); |
| | | } |
| | | } |
| | | return Result.error("上传云服务器异常"); |
| | | } |
| | | |
| | | @GetMapping("/getUrl/{fileKey}") |
| | | public Result getUrl(@PathVariable(value = "fileKey") String fileKey){ |
| | | return Result.ok().data(activityService.getPreviewUrl(fileKey)); |
| | | } |
| | | |
| | | @DeleteMapping("/delByKey") |
| | | @ApiOperation(value = "删除某个文件") |
| | | public Result delByKey(@RequestBody String fileKey) { |
| | | return activityService.deleteObject(fileKey); |
| | | } |
| | | |
| | | } |