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


import com.red.circle.console.app.service.app.sys.SysWeekStarGroupService;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.inner.model.cmd.sys.SysWeekStarGroupAddParamCmd;
import com.red.circle.other.inner.model.cmd.sys.SysWeekStarGroupQryCmd;
import com.red.circle.other.inner.model.dto.sys.SysWeekStarGroupDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 周星礼物分组配置 前端控制器.
 * </p>
 *
 * @author pengliang
 * @since 2021-04-20
 */
@RestController
@RequestMapping("/sys-week-star-group")
@RequiredArgsConstructor
public class SysWeekStarGroupRestController extends BaseController {

  private final SysWeekStarGroupService sysWeekStarGroupService;

  /**
   * 周星礼物分组列表.
   */
  @GetMapping("/page")
  public PageResult<SysWeekStarGroupDTO> page(SysWeekStarGroupQryCmd query) {
    return sysWeekStarGroupService.getPage(query);
  }

  /**
   * 添加分组.
   */
  @PostMapping
  public void add(@RequestBody @Validated SysWeekStarGroupAddParamCmd param) {
    sysWeekStarGroupService.addGroup(param);
  }

  /**
   * 删除分组.
   */
  @DeleteMapping
  public void delete(@RequestParam Long id) {
    sysWeekStarGroupService.deleteAndAssociateGroup(id);
  }

}
