package com.crm.manager.controller;

import com.crm.manager.service.SysInterestLoginDayNumberService;
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.SysInterestLoginDayNumberDto;
import com.crm.rely.backend.core.entity.base.SingleLongEntity;
import com.crm.rely.backend.core.entity.system.interest.SysInterestLoginDayNumberAddEntity;
import com.crm.rely.backend.core.entity.system.interest.SysInterestLoginDayNumberDeleteEntitys;
import com.crm.rely.backend.core.entity.system.interest.SysInterestLoginDayNumberSearchEntity;
import com.crm.rely.backend.core.entity.system.interest.SysInterestLoginDayNumberUpdateEntity;
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;

@RestController
@RequestMapping("/interest/day/number")
public class SysInterestLoginDayNumberController {

    @Autowired
    private SysInterestLoginDayNumberService sysInterestLoginDayNumberService;

    @PostMapping("/add")
    public BaseResultDto add(@RequestBody @Validated SysInterestLoginDayNumberAddEntity entity) throws Exception {
        sysInterestLoginDayNumberService.add(entity);
        return BaseResultDto.success();
    }

    @PostMapping("/delete")
    public BaseResultDto delete(@RequestBody @Validated SysInterestLoginDayNumberDeleteEntitys entitys) throws Exception {

        sysInterestLoginDayNumberService.delete(entitys);
        return BaseResultDto.success();
    }

    @PostMapping("/update")
    public BaseResultDto update(@RequestBody @Validated SysInterestLoginDayNumberUpdateEntity entity) throws Exception {
        sysInterestLoginDayNumberService.update(entity);
        return BaseResultDto.success();
    }

    @PostMapping("/search/list")
    public ResultWithPagerDto<SysInterestLoginDayNumberDto> pageList(@RequestBody SysInterestLoginDayNumberSearchEntity entity) throws Exception {

        return sysInterestLoginDayNumberService.searchPageList(entity);
    }

    @PostMapping("/search/single")
    public BaseResultDto searchSingle(@RequestBody @Validated SingleLongEntity entity) throws Exception {
        SysInterestLoginDayNumberDto result = sysInterestLoginDayNumberService.searchSingle(entity);
        return BaseResultDto.success(result);
    }
}
