package com.crm.manager.controller;

import com.crm.manager.service.SysSalesShareService;
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.system.sales.SysSalesShareDto;
import com.crm.rely.backend.core.entity.custom.info.InfoEntity;
import com.crm.rely.backend.core.entity.system.sales.SysSalesShareListEntity;
import com.crm.rely.backend.core.entity.user.info.UserShareUpdateEntity;
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;

/**
 * @author y
 * @create 2022/6/10
 */

@RestController
@RequestMapping("/sys/sales/share")
public class SysSalesShareController {

    @Autowired
    private SysSalesShareService sysSalesShareService;

    @PostMapping("/add")
    public BaseResultDto add(@RequestBody UserShareUpdateEntity entity, InfoEntity infoEntity) throws Exception {
        entity.setUserId(infoEntity.getIbInfo().getId());
        sysSalesShareService.add(entity);
        return BaseResultDto.success();

    }

    @PostMapping("/search/list")
    public BaseResultWithPagerDto<List<SysSalesShareDto>> searchList(@RequestBody SysSalesShareListEntity entity) throws Exception {
        return sysSalesShareService.searchList(entity);
    }

}
