package com.yh.saas.plugin.yiliangyiyun.controller;


import com.baomidou.mybatisplus.plugins.Page;
import com.yh.saas.plugin.yiliangyiyun.entity.SettledCompanyDynamics;
import com.yh.saas.plugin.yiliangyiyun.entity.SettledCompanyInfo;
import com.yh.saas.plugin.yiliangyiyun.exception.ServiceException;
import com.yh.saas.plugin.yiliangyiyun.service.ISettledCompanyDynamicsService;
import com.yh.saas.plugin.yiliangyiyun.service.ISettledCompanyInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 入驻公司发布动态 前端控制器
 * </p>
 *
 * @author Gongdc
 * @since 2021-08-28
 */
@RestController
@RequestMapping("/settledCompanyDynamics")
public class SettledCompanyDynamicsController {

    @Autowired
    private ISettledCompanyDynamicsService settledCompanyDynamicsService;


    /**
     * 列表
     *
     * @param settledCompanyDynamics
     * @return
     */
    @GetMapping("/selectSettledCompanyDynamicsPage")
    public Page<SettledCompanyDynamics> selectSettledCompanyDynamicsPage(SettledCompanyDynamics settledCompanyDynamics) {
        return settledCompanyDynamicsService.selectSettledCompanyDynamicsPage(settledCompanyDynamics);
    }


    /**
     * 发布动态
     *
     * @param settledCompanyDynamic
     * @return
     */
    @PostMapping("/api/addSettledCompanyDynamics")
    public String addSettledCompanyDynamics(@RequestBody SettledCompanyDynamics settledCompanyDynamic) throws ServiceException {
        return settledCompanyDynamicsService.addSettledCompanyDynamics(settledCompanyDynamic);
    }


    /**
     * 删除
     *
     * @param settledCompanyDynamic
     * @return
     */
    @PostMapping("/api/deleteSettledCompanyInfo")
    public void deleteSettledCompanyInfo(@RequestBody SettledCompanyDynamics settledCompanyDynamic) {
        settledCompanyDynamicsService.deleteSettledCompanyDynamics(settledCompanyDynamic.getId());
    }


    /**
     * 审核
     *
     * @param settledCompanyDynamic
     * @return
     */
    @PostMapping("/api/examine")
    public String examine(@RequestBody SettledCompanyDynamics settledCompanyDynamic) {
        return settledCompanyDynamicsService.examine(settledCompanyDynamic);

    }


    /**
     * 显示隐藏
     *
     * @param settledCompanyDynamic
     * @return
     */
    @PostMapping("/api/showHidden")
    public void showHidden(@RequestBody SettledCompanyDynamics settledCompanyDynamic) {
        settledCompanyDynamicsService.showHidden(settledCompanyDynamic.getId());
    }


    /**
     * 查看详情
     *
     * @param id
     * @return
     */
    @GetMapping("/getSettledCompanyDynamics")
    public SettledCompanyDynamics getSettledCompanyDynamics(String id) {
        return settledCompanyDynamicsService.getSettledCompanyDynamics(id);
    }
    /**
     * 查看当天发布
     *
     * @param phone
     * @return
     */
    @GetMapping("/count")
    public Integer count(@RequestParam String phone) {
        return settledCompanyDynamicsService.count(phone);
    }



}

