package com.ym.mec.web.controller;


import com.ym.mec.auth.api.client.SysUserFeignService;
import com.ym.mec.auth.api.entity.SysUser;
import com.ym.mec.biz.dal.dao.EmployeeDao;
import com.ym.mec.biz.dal.entity.Employee;
import com.ym.mec.biz.dal.entity.OrganizationCloudTeacherFee;
import com.ym.mec.biz.dal.page.OrganizationCloudTeacherFeeQueryInfo;
import com.ym.mec.biz.service.OrganizationCloudTeacherFeeService;
import com.ym.mec.biz.service.OrganizationService;
import com.ym.mec.common.controller.BaseController;
import com.ym.mec.common.entity.HttpResponseResult;
import com.ym.mec.common.page.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

@RequestMapping("organizationCloudTeacherFee")
@Api(tags = "分部云教练价格配置服务")
@RestController
public class OrganizationCloudTeacherFeeController extends BaseController {

    @Autowired
    private OrganizationCloudTeacherFeeService organizationCloudTeacherFeeService;
    @Autowired
    private SysUserFeignService sysUserFeignService;
    @Autowired
    private OrganizationService organizationService;

    @ApiOperation(value = "分页查询分部列表")
    @GetMapping("/queryPage")
    @PreAuthorize("@pcs.hasPermissions('organizationCloudTeacherFee/queryPage')")
    public HttpResponseResult<PageInfo<OrganizationCloudTeacherFee>> queryPage(OrganizationCloudTeacherFeeQueryInfo queryInfo) {
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        return succeed(organizationCloudTeacherFeeService.queryPage(queryInfo));
    }

    @ApiOperation(value = "新增分部配置")
    @PostMapping("/add")
    @PreAuthorize("@pcs.hasPermissions('organizationCloudTeacherFee/add')")
    public HttpResponseResult<OrganizationCloudTeacherFee> add(OrganizationCloudTeacherFee organizationCloudTeacherFee) {
        return succeed(organizationCloudTeacherFeeService.add(organizationCloudTeacherFee));
    }

    @ApiOperation(value = "修改分部配置")
    @PostMapping("/update")
    @PreAuthorize("@pcs.hasPermissions('organizationCloudTeacherFee/update')")
    public HttpResponseResult<OrganizationCloudTeacherFee> update(OrganizationCloudTeacherFee organizationCloudTeacherFee) {
        return succeed(organizationCloudTeacherFeeService.updateFee(organizationCloudTeacherFee));
    }

}
