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

import com.red.circle.console.app.dto.clienobject.sys.SysEmojiConfigCO;
import com.red.circle.console.app.service.app.sys.SysEmojiConfigService;
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.sys.SysEmojiConfigParamCmd;
import com.red.circle.other.inner.model.cmd.sys.SysEmojiConfigQryCmd;
import com.red.circle.other.inner.model.cmd.sys.SysEmojiGroupParamCmd;
import com.red.circle.other.inner.model.cmd.sys.SysEmojiGroupQryCmd;
import com.red.circle.other.inner.model.dto.material.EmojiGroupDTO;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 表情管理 前端控制器.
 * </p>
 *
 * @author pengshigang
 * @since 2021-08-25
 */
@RestController
@RequestMapping(value = "/emoji/config")
@RequiredArgsConstructor
public class SysEmojiConfigRestController extends BaseController {

  private final SysEmojiConfigService sysEmojiConfigService;

  /**
   * 表情列表-分组.
   */
  @GetMapping("/group/page")
  public PageResult<EmojiGroupDTO> pageEmojiGroup(SysEmojiGroupQryCmd query) {
    return sysEmojiConfigService.pageEmojiGroup(query);
  }


  @OpsOperationReqLog("表情列表-添加或修改")
  @PostMapping("/group/add-or-update")
  public void groupAddOrUpdate(@RequestBody @Validated SysEmojiGroupParamCmd param) {
    sysEmojiConfigService.groupAddOrUpdate(param);
  }

  /**
   * 表情列表-系统.
   */
  @GetMapping("/group/sys-origin-list")
  public List<EmojiGroupDTO> groupListBySysOrigin(String sysOrigin) {
    return sysEmojiConfigService.groupListBySysOrigin(sysOrigin);
  }


  @OpsOperationReqLog("表情列表-系统")
  @GetMapping("/group/shelf-status-switch")
  public void switchGroupShelfStatus(Long id, Boolean status) {
    sysEmojiConfigService.switchGroupShelfStatus(id, status);
  }

  /**
   * 表情列表
   */
  @GetMapping("/page")
  public PageResult<SysEmojiConfigCO> pageEmojiConfig(SysEmojiConfigQryCmd query) {
    return sysEmojiConfigService.pageEmojiConfig(query);
  }

  /**
   * 新增或修改表情配置
   */
  @OpsOperationReqLog(value = "新增或修改表情配置")
  @PostMapping("/add-or-update")
  public void addOrUpdate(@RequestBody SysEmojiConfigParamCmd param) {
    sysEmojiConfigService.addOrUpdate(param);
  }

  /**
   * 下架或上架表情
   */
  @OpsOperationReqLog(value = "下架或上架表情")
  @PostMapping("/off-shelf/{id}")
  public void offShelf(@PathVariable("id") Long id) {
    sysEmojiConfigService.offShelf(id);
  }

}
