package com.crm.manager.controller;

import com.crm.manager.service.MamPmPercentChangeService;
import com.crm.rely.backend.core.dto.base.BaseResultDto;
import com.crm.rely.backend.core.dto.base.BaseResultWithPagerDto;
import com.crm.rely.backend.core.dto.mam.MamPmPercentChangeDto;
import com.crm.rely.backend.core.entity.base.BaseApproveEntity;
import com.crm.rely.backend.core.entity.base.SingleLongEntity;
import com.crm.rely.backend.core.entity.mam.MamPmPercentChangeListEntity;
import org.springframework.beans.factory.annotation.Autowired;
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;

import java.util.List;

/**
 * pm业务接口
 *
 * @author y
 * @create 2022/1/21
 */
@RestController
@RequestMapping("/pm/percent/change")
public class MamPmPercentChangeController {

    @Autowired
    private MamPmPercentChangeService mamPmPercentChangeService;

    @PostMapping("/detail")
    public BaseResultDto<Object> detail(@RequestBody SingleLongEntity entity) throws Exception {

        return BaseResultDto.success(mamPmPercentChangeService.getDetail(entity.getId()));

    }

    @PostMapping("/list")
    public BaseResultWithPagerDto<List<MamPmPercentChangeDto>> list(@RequestBody MamPmPercentChangeListEntity entity) throws Exception {
        return mamPmPercentChangeService.getList(entity);
    }

    @PostMapping("/approve")
    public BaseResultDto<Boolean> approve(@RequestBody BaseApproveEntity entity) throws Exception {

        return BaseResultDto.success(mamPmPercentChangeService.approve(entity));

    }

}
