package com.hotent.uc.controller;


import com.hotent.base.annotation.ApiGroup;
import com.hotent.base.constants.ApiGroupConsts;
import com.hotent.base.controller.BaseController;
import com.hotent.base.model.CommonResult;
import com.hotent.base.query.PageList;
import com.hotent.base.query.QueryFilter;
import com.hotent.base.util.BeanUtils;
import com.hotent.uc.manager.OrgExternalSettingManager;
import com.hotent.uc.manager.ScanLoginManager;
import com.hotent.uc.model.Org;
import com.hotent.uc.model.OrgExternalSetting;
import com.hotent.uc.model.ScanLogin;
import com.hotent.uc.model.User;
import com.hotent.uc.params.org.OrgVo;
import com.hotent.uc.util.UpdateMethod;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 组织外部系统参数配置 接口控制器
 *
 * @company 广州宏天软件股份有限公司
 * @author pangquan
 * @since 2020-10-30
 */
@RestController
@RequestMapping("/uc/org/v1/")
@Api(tags="组织外部系统参数配置")
@ApiGroup(group= {ApiGroupConsts.GROUP_UC})
public class OrgExternalSettingController extends BaseController<OrgExternalSettingManager, OrgExternalSetting> {
	@Autowired
	private OrgExternalSettingManager orgExtSettingService;


	/**
	 * 添加组织外部系统参数
	 *
	 * @param orgExtSetting
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "orgExtSetting/addOrgExternalSetting", method = RequestMethod.POST, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "添加组织外部系统参数", httpMethod = "POST", notes = "添加组织外部系统参数")
	public CommonResult<String> addOrgExternalSetting(
			@ApiParam(name = "orgExtSetting", value = "组织视图", required = true) @RequestBody OrgExternalSetting orgExtSetting) throws Exception {
		CommonResult<String> rtn = null;
		try {
			rtn = orgExtSettingService.addOrgExtSetting(orgExtSetting);
		} catch (Exception e) {
			rtn = new CommonResult<String>(false,e.getMessage(),"保存失败");
		}
		return rtn;
	}


	/**
	 * 修改组织外部系统参数
	 *
	 * @param orgExtSetting
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "orgExtSetting/updateOrgExtSetting", method = RequestMethod.POST, produces = {
			"application/json; charset=utf-8" })
	@ApiOperation(value = "修改组织外部系统参数", httpMethod = "POST", notes = "修改组织外部系统参数")
	public CommonResult<String> updateOrgExtSetting(
			@ApiParam(name = "orgExtSetting", value = "修改组织外部系统参数", required = true) @RequestBody OrgExternalSetting orgExtSetting) throws Exception {
		return orgExtSettingService.updateOrgExtSetting(orgExtSetting);
	}
	/**
	 * 根据组织id获取组织
	 *
	 * @param orgId
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "orgExtSetting/get", method = RequestMethod.GET, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "根据组织id获取组织", httpMethod = "GET", notes = "根据组织id获取组织")
	public CommonResult<OrgExternalSetting> get(@ApiParam(name = "orgId", value = "组织id", required = true) @RequestParam String orgId)
			throws Exception {
		return orgExtSettingService.querySettingByCorpId(orgId);
	}


	/**
	 * 根据组织id获取组织
	 *
	 * @param orgId
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "orgExtSetting/getOrgExtSettingByCorpId", method = RequestMethod.GET, produces = { "application/json; charset=utf-8" })
	@ApiOperation(value = "根据组织id获取组织", httpMethod = "GET", notes = "根据组织id获取组织")
	public OrgExternalSetting getOrgExtSettingByCorpId(@ApiParam(name = "corpId", value = "组织id", required = true) @RequestParam String corpId)
			throws Exception {
		return orgExtSettingService.querySettingByCorpIdCode(corpId);
	}
}
