package com.iformall.controller.invest;

import com.iformall.annotation.SystemServiceLog;
import com.iformall.common.InvestResultData;
import com.iformall.domain.po.invest.InvestRemindEntity;
import com.iformall.domain.vo.invest.InvestPageQuery;
import com.iformall.domain.vo.invest.InvestPageResult;
import com.iformall.domain.vo.invest.InvestRemindQuery;
import com.iformall.domain.vo.invest.InvestRemindVo;
import com.iformall.service.invest.InvestBizService;
import com.iformall.service.invest.InvestRemindService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;




/**
 * 招商模块-预约提醒
 *
 * @author
 * @email
 * @date 2019-09-23 18:40:43
 */
@Slf4j
@RestController
@RequestMapping("invest/remind")
@Api(tags = "招商模块-预约提醒")
public class InvestRemindController extends InvestBaseController {
    @Autowired
    private InvestRemindService investRemindService;
    @Autowired
    private InvestBizService bizService;

    /**
     * 分页列表
     */
    @SystemServiceLog
    @ApiOperation("分页列表接口")
    @GetMapping("/list")
    public InvestResultData<InvestPageResult<InvestRemindVo>> list(InvestRemindQuery params) {
        return execute(params, p -> bizService.queryPageRemind(p));
    }


    /**
     * 信息
     */
    @SystemServiceLog
    @GetMapping("/info/{id}")
    public InvestResultData<InvestRemindEntity> info(@PathVariable("id") Long id) {
        return execute(id, p -> bizService.findRemindById(p));
    }

    /**
     * 保存
     */
    //@RequiresPermissions("investFollowRecordEdit")
    @SystemServiceLog
    @PostMapping("/save")
    public InvestResultData save(@RequestBody  InvestRemindEntity investRemind) {
        return execute(investRemind, p -> investRemindService.save(p));
    }

    /**
     * 修改
     */
    @SystemServiceLog
    @PostMapping("/update")
    public InvestResultData update(@RequestBody InvestRemindEntity investRemind) {
        return execute(investRemind, p -> investRemindService.updateById(p));
    }

    /**
     * 删除
     */
    @SystemServiceLog
    @PostMapping("/delete")
    public InvestResultData delete(@RequestBody Long[] ids) {
        return execute(ids, p -> investRemindService.removeByIds(Arrays.asList(p)));
    }

    /**
     * 删除登录用户全部提醒
     */
    @SystemServiceLog
    //@PostMapping("/deleteAll")
    public InvestResultData deleteAll() {
        return execute(null, p -> investRemindService.removeAll());
    }

}
