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


import com.red.circle.console.app.service.app.user.UserBeautifulNumberService;
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.user.BeautifulNumberQryCmd;
import com.red.circle.other.inner.model.cmd.user.UserBeautifulNumberCmd;
import com.red.circle.other.inner.model.dto.user.BeautifulNumberDTO;
import lombok.RequiredArgsConstructor;
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;

/**
 * <p>
 * 房间靓号 前端控制器
 * </p>
 *
 * @author houyong
 * @since 2021-03-31
 */
@Deprecated
@RestController
@RequestMapping("/user/beautiful/number")
@RequiredArgsConstructor
public class UserBeautifulNumberRestController extends BaseController {

  private final UserBeautifulNumberService userBeautifulNumberService;

  /**
   * 获取靓号池信息.
   */
  @GetMapping
  public PageResult<BeautifulNumberDTO> pageBeautifulNumber(BeautifulNumberQryCmd query) {
    return userBeautifulNumberService.pageBeautifulNumber(query);
  }

  @OpsOperationReqLog(value = "修改靓号池信息")
  @PutMapping
  public void updateBeautifulNumber(@RequestBody UserBeautifulNumberCmd cmd) {
    cmd.setUpdateUser(cmd.getReqUserId());
    userBeautifulNumberService.updateBeautifulNumber(cmd);
  }

  @OpsOperationReqLog(value = "新增靓号池信息")
  @PostMapping
  public void addBeautifulNumber(@RequestBody UserBeautifulNumberCmd cmd) {
    cmd.setUpdateUser(cmd.getReqUserId());
    userBeautifulNumberService.addBeautifulNumber(cmd);
  }

  /**
   * 删除靓号.
   */
  @GetMapping("/delete/{id}")
  public void deleteBeautifulNumber(@PathVariable("id") Long id) {
    userBeautifulNumberService.deleteBeautifulNumber(id);
  }

}
