package com.czg.controller.admin;

import com.czg.annotation.SaAdminCheckPermission;
import com.czg.market.dto.MkDrainageConfigDTO;
import com.czg.market.service.MkDrainageConfigService;
import com.czg.market.vo.MkDrainageConfigVO;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 管理端/私域引流配置
 *
 * @author Administrator
 */
@RestController
@RequestMapping("/admin/drainageConfig")
public class DrainageConfigController {

    @Resource
    private MkDrainageConfigService service;

    /**
     * 配置信息获取
     * 权限标识: activate:list
     */
    @SaAdminCheckPermission(parentName = "私域引流", value = "drainageConfig:detail", name = "私域引流详情")
    @GetMapping
    public CzgResult<MkDrainageConfigVO> detail() {
        return CzgResult.success(service.detail(StpKit.USER.getShopId()));
    }

    /**
     * 配置信息修改
     *
     * @return 是否成功
     */
    @SaAdminCheckPermission(parentName = "私域引流",value = "drainageConfig:edit", name = "私域引流修改")
    @PostMapping
    public CzgResult<Boolean> edit(@Validated @RequestBody MkDrainageConfigDTO config) {
        return CzgResult.success(service.edit(StpKit.USER.getShopId(), config));
    }


}
