package com.red.circle.console.adapter.app.activity;

import com.red.circle.console.app.service.app.activity.PictureConfigService;
import com.red.circle.console.infra.annotations.OpsOperationReqLog;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.inner.model.cmd.activity.ActivityPictureQryCmd;
import com.red.circle.other.inner.model.dto.activity.ActivityPictureConfigDTO;
import com.red.circle.tool.core.date.TimestampUtils;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 活动图片配置 前端控制器.
 *
 * @author zongpubin on 2023-12-20 16:00
 */
@AllArgsConstructor
@RestController
@RequestMapping("/activity-picture/config")
public class ActivityPictureConfigRestController extends BaseController {

  private final PictureConfigService pictureConfigService;

  /**
   * 获取活动图片配置
   */
  @GetMapping
  public PageResult<ActivityPictureConfigDTO> getActivityPicture(ActivityPictureQryCmd query) {
    return pictureConfigService.getActivityPicture(query);
  }

  @OpsOperationReqLog("添加活动图片配置")
  @PostMapping
  public void addActivityPicture(@RequestBody ActivityPictureConfigDTO dto) {
    pictureConfigService.addActivityPicture(dto);
  }

  @OpsOperationReqLog("删除活动图片配置")
  @DeleteMapping("/delete/{id}")
  public void deleteActivityPicture(@PathVariable("id") Long id
  ) {
    pictureConfigService.removeActivityPicture(id);
  }

  @OpsOperationReqLog("修改活动图片配置")
  @PutMapping
  public void updateActivityPicture(@RequestBody ActivityPictureConfigDTO dto) {
    dto.setUpdateUser(getReqUserId());
    dto.setUpdateTime(TimestampUtils.now());
    pictureConfigService.updateActivityPicture(dto);
  }


}
