package com.crm.manager.controller;

import com.crm.manager.service.SysInterestSymbolAmountService;
import com.crm.rely.backend.core.dto.base.BaseResultDto;
import com.crm.rely.backend.core.dto.base.ResultWithPagerDto;
import com.crm.rely.backend.core.dto.system.interest.symbol.amount.SysInterestSymbolAmountDto;
import com.crm.rely.backend.core.entity.base.SingleLongEntity;
import com.crm.rely.backend.core.entity.system.interest.symbol.amount.SysInterestSymbolAmountAddEntity;
import com.crm.rely.backend.core.entity.system.interest.symbol.amount.SysInterestSymbolAmountDeleteEntity;
import com.crm.rely.backend.core.entity.system.interest.symbol.amount.SysInterestSymbolAmountSearchPageEntity;
import com.crm.rely.backend.core.entity.system.interest.symbol.amount.SysInterestSymbolAmountUpdateEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
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;

/**
 * @author: houn
 */
@RestController
@RequestMapping("/interest/symbol/amount")
public class SysInterestSymbolAmountController {

    @Autowired
    private SysInterestSymbolAmountService service;

    /**
     * 添加
     *
     * @param entity
     * @return
     * @throws Exception
     */
    @PostMapping("/add")
    public BaseResultDto add(@RequestBody @Validated SysInterestSymbolAmountAddEntity entity) throws Exception {
        service.add(entity);
        return BaseResultDto.success();
    }

    /**
     * 删除
     *
     * @param entity
     * @return
     * @throws Exception
     */
    @PostMapping("/delete")
    public BaseResultDto delete(@RequestBody @Validated SysInterestSymbolAmountDeleteEntity entity) throws Exception {

        service.delete(entity);
        return BaseResultDto.success();

    }

    /**
     * 修改
     *
     * @param entity
     * @return
     * @throws Exception
     */
    @PostMapping("/update")
    public BaseResultDto update(@RequestBody @Validated SysInterestSymbolAmountUpdateEntity entity) throws Exception {

        service.update(entity);
        return BaseResultDto.success();

    }

    /**
     * @param entity
     * @return
     * @throws Exception
     */
    @PostMapping("/search/list")
    public BaseResultDto list(@RequestBody @Validated SysInterestSymbolAmountSearchPageEntity entity) throws Exception {

        ResultWithPagerDto<SysInterestSymbolAmountDto> result = service.pageSearchList(entity);
        return result;

    }

    @PostMapping("/search/single")
    public BaseResultDto single(@RequestBody @Validated SingleLongEntity entity) throws Exception {
        SysInterestSymbolAmountDto dto = service.searchSingle(entity.getId());
        return BaseResultDto.success(dto);

    }
}
