package com.template.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.template.annotation.DESRespondSecret;
import com.template.api.SmartPushConfigControllerAPI;
import com.template.model.pojo.SmartPushConfig;
import com.template.model.pojo.SmartVisitorRestsConfig;
import com.template.model.result.CommonResult;
import com.template.services.SmartPushConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ceshi
 * @since 2024-06-05
 */
@RestController
@DESRespondSecret
public class SmartPushConfigController implements SmartPushConfigControllerAPI {

    @Autowired
    SmartPushConfigService smartPushConfigService;

    @Override
    @DESRespondSecret(validated = true)
    public CommonResult list() {
        List<SmartPushConfig> list = smartPushConfigService.list(new LambdaQueryWrapper<>());
        SmartPushConfig s = list.get(0);
        return CommonResult.ok(s);
    }

    @Override
    @DESRespondSecret(validated = true)
    public CommonResult update(SmartPushConfig smartPushConfig) {
        boolean update = smartPushConfigService.updateById(smartPushConfig);
        if (update) {
            return CommonResult.ok();
        }
        return CommonResult.fail();
    }
}

