package com.liquidnet.client.admin.web.controller.zhengzai.smile;


import com.liquidnet.client.admin.common.core.domain.AjaxResult;
import com.liquidnet.client.admin.common.core.page.TableDataInfo;
import com.liquidnet.client.admin.zhengzai.smile.dto.SmileOrgAndUserVo;
import com.liquidnet.client.admin.zhengzai.smile.dto.SmileOrganizationParam;
import com.liquidnet.client.admin.zhengzai.smile.dto.SmileOrganizationVo;
import com.liquidnet.client.admin.zhengzai.smile.service.ISmileOrganizationService;
import com.liquidnet.service.smile.entity.SmileOrganization;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liquidnet
 * @since 2022-03-14
 */
@Api(tags = "组织管理")
@RestController
@RequestMapping("/smile/organization")
public class SmileOrganizationController {

    @Autowired
    ISmileOrganizationService smileOrganizationService;

    @PostMapping("/list")
    @ApiOperation("获取组织列表")
    @ResponseBody
    public TableDataInfo organizationList(SmileOrganizationParam smileOrganizationParam){
        return smileOrganizationService.organizationList(smileOrganizationParam);
    }

    @PostMapping("/create")
    @ApiOperation("新增组织")
    @ResponseBody
    public AjaxResult create(@RequestBody SmileOrganizationVo smileOrganizationVo){
        return smileOrganizationService.create(smileOrganizationVo);
    }

    @PostMapping("/updateOrg")
    @ApiOperation("修改组织")
    @ResponseBody
    public AjaxResult updateOrg(@RequestBody SmileOrganization smileOrganization){
        return smileOrganizationService.update(smileOrganization);

    }

    @PostMapping("/getOrgById")
    @ApiOperation("根据组织id获取信息")
    @ResponseBody
    public AjaxResult getOrgById(@RequestParam(name = "id")Long id){
        SmileOrgAndUserVo orgById = smileOrganizationService.getOrgById(id);
        return AjaxResult.success(orgById);
    }

}
