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


import com.red.circle.console.app.dto.clienobject.sys.SysCustomerServiceConfigCO;
import com.red.circle.console.app.service.app.sys.SysCustomerServiceConfigService;
import com.red.circle.console.infra.annotations.OpsOperationReqLog;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.inner.model.cmd.sys.CustomerServiceConfigCmd;
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;

/**
 * 客服配置.
 *
 * @author pengshigang on 2022/10/8
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/sys/customer-service")
public class SysCustomerServiceRestController extends BaseController {

  private final SysCustomerServiceConfigService sysCustomerServiceConfigService;

  /**
   * 客服列表.
   */
  @GetMapping("/list/{sysOrigin}")
  public List<SysCustomerServiceConfigCO> pageList(
      @PathVariable("sysOrigin") String sysOrigin, String region) {

    return sysCustomerServiceConfigService.list(sysOrigin, region);
  }

  @OpsOperationReqLog("添加客服")
  @PostMapping("/add")
  public void add(@RequestBody @Validated CustomerServiceConfigCmd param) {
    sysCustomerServiceConfigService.add(param);
  }

  @OpsOperationReqLog("修改客服")
  @PostMapping("/update")
  public void update(@RequestBody @Validated CustomerServiceConfigCmd param) {
    sysCustomerServiceConfigService.update(param);
  }

  @OpsOperationReqLog("删除客服")
  @GetMapping("/delete/{id}")
  public void delete(@PathVariable("id") Long id) {
    sysCustomerServiceConfigService.delete(id);
  }

}
