From cf25acecf27ab3f7bd1511e11cdeecccbad8f196 Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期四, 22 五月 2025 11:28:54 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev --- framework/src/main/java/cn/lili/modules/lmk/mapper/ActivityMapper.java | 35 ++ framework/src/main/java/cn/lili/modules/lmk/service/ActivityService.java | 71 +++++ framework/src/main/java/cn/lili/modules/lmk/domain/query/ActivityQuery.java | 39 ++ manager-api/src/main/java/cn/lili/controller/lmk/ManagerUploadController.java | 63 ++++ framework/src/main/java/cn/lili/modules/lmk/domain/entity/Activity.java | 73 +++++ framework/src/main/java/cn/lili/modules/lmk/domain/form/ActivityForm.java | 103 +++++++ framework/src/main/java/cn/lili/modules/lmk/domain/vo/ActivityVO.java | 91 ++++++ framework/src/main/java/cn/lili/modules/lmk/service/impl/ActivityServiceImpl.java | 147 ++++++++++ manager-api/src/main/java/cn/lili/controller/lmk/ActivityController.java | 88 ++++++ framework/src/main/resources/mapper/lmk/ActivityMapper.xml | 79 +++++ 10 files changed, 789 insertions(+), 0 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/entity/Activity.java b/framework/src/main/java/cn/lili/modules/lmk/domain/entity/Activity.java new file mode 100644 index 0000000..a3b7c91 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/entity/Activity.java @@ -0,0 +1,73 @@ +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; + + + +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/form/ActivityForm.java b/framework/src/main/java/cn/lili/modules/lmk/domain/form/ActivityForm.java new file mode 100644 index 0000000..f6c7f77 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/form/ActivityForm.java @@ -0,0 +1,103 @@ +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; + } +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/query/ActivityQuery.java b/framework/src/main/java/cn/lili/modules/lmk/domain/query/ActivityQuery.java new file mode 100644 index 0000000..22396a1 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/query/ActivityQuery.java @@ -0,0 +1,39 @@ +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; +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/ActivityVO.java b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/ActivityVO.java new file mode 100644 index 0000000..e9240ba --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/ActivityVO.java @@ -0,0 +1,91 @@ +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; + } +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/mapper/ActivityMapper.java b/framework/src/main/java/cn/lili/modules/lmk/mapper/ActivityMapper.java new file mode 100644 index 0000000..6304f42 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/mapper/ActivityMapper.java @@ -0,0 +1,35 @@ +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); + +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/ActivityService.java b/framework/src/main/java/cn/lili/modules/lmk/service/ActivityService.java new file mode 100644 index 0000000..0cfa942 --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/service/ActivityService.java @@ -0,0 +1,71 @@ +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); +} diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/ActivityServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/ActivityServiceImpl.java new file mode 100644 index 0000000..c63218f --- /dev/null +++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/ActivityServiceImpl.java @@ -0,0 +1,147 @@ +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()); + } + + } + // 涓虹┖鎶汭llegalArgumentException锛屽仛鍏ㄥ眬寮傚父澶勭悊 + 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(); + } +} diff --git a/framework/src/main/resources/mapper/lmk/ActivityMapper.xml b/framework/src/main/resources/mapper/lmk/ActivityMapper.xml new file mode 100644 index 0000000..abb1370 --- /dev/null +++ b/framework/src/main/resources/mapper/lmk/ActivityMapper.xml @@ -0,0 +1,79 @@ +<?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> diff --git a/manager-api/src/main/java/cn/lili/controller/lmk/ActivityController.java b/manager-api/src/main/java/cn/lili/controller/lmk/ActivityController.java new file mode 100644 index 0000000..8d0be71 --- /dev/null +++ b/manager-api/src/main/java/cn/lili/controller/lmk/ActivityController.java @@ -0,0 +1,88 @@ +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); + } +} diff --git a/manager-api/src/main/java/cn/lili/controller/lmk/ManagerUploadController.java b/manager-api/src/main/java/cn/lili/controller/lmk/ManagerUploadController.java new file mode 100644 index 0000000..6d6d327 --- /dev/null +++ b/manager-api/src/main/java/cn/lili/controller/lmk/ManagerUploadController.java @@ -0,0 +1,63 @@ +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); + } + +} -- Gitblit v1.8.0