package com.prolog.rdc.tms.controller.basicConfigure;

import java.util.List;

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 com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.core.pojo.Page;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.rdc.tms.model.dto.basicConfigure.SysExtendedFieldDTO;
import com.prolog.rdc.tms.model.dto.basicConfigure.SysExtendedFieldListDTO;
import com.prolog.rdc.tms.model.vo.basicConfigure.SysExtendedFieldDeleteVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.SysExtendedFieldListVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.SysExtendedFieldQueryVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.SysExtendedFieldSaveVO;
import com.prolog.rdc.tms.model.vo.basicConfigure.SysExtendedFieldUpdataVO;
import com.prolog.rdc.tms.service.basicConfigure.SysExtendedFieldService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 
 *
 * 基础配置-扩展字段控制层
 *
 * @className :SysExtendedFieldController
 * @author :fanzw
 * @creationTime :2022/01/12
 * @description :
 * @modifier :fanzw
 * @modifyTime :2022/01/12
 * @reviseRemarks:
 *
 * @version :1.0.0
 *
 */
@Api(tags = "基础配置-扩展字段")
@RestController
@RequestMapping("/extendedField")
public class SysExtendedFieldController {

	@Autowired
	private SysExtendedFieldService sysExtendedFieldService;

	@UserLog("扩展字段分页查询")
	@ApiOperation(value = "扩展字段分页查询", notes = "扩展字段分页查询")
	@PostMapping("/query")
	public RestMessage<Page<SysExtendedFieldDTO>> pageExtendedFieldExecute(@RequestBody SysExtendedFieldQueryVO sysExtendedFieldQueryVO) {
		try {
			Page<SysExtendedFieldDTO> sysExtendedFieldDTOs = sysExtendedFieldService.pageExtendedFieldData(sysExtendedFieldQueryVO);
			return RestMessage.newInstance(true, "查询成功", sysExtendedFieldDTOs);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("根据扩展对象查询扩展字段")
	@ApiOperation(value = "根据扩展对象查询扩展字段", notes = "根据扩展对象查询扩展字段")
	@PostMapping("/list")
	public RestMessage<List<SysExtendedFieldListDTO>> listExtendedFieldExecute(@RequestBody SysExtendedFieldListVO sysExtendedFieldListVO) {
		try {
			List<SysExtendedFieldListDTO> sysExtendedFieldListDTOs = sysExtendedFieldService.listExtendedFieldData(sysExtendedFieldListVO);
			return RestMessage.newInstance(true, "查询成功", sysExtendedFieldListDTOs);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("扩展字段保存")
	@ApiOperation(value = "扩展字段保存", notes = "扩展字段保存")
	@PostMapping("/save")
	public RestMessage<String> saveExtendedFieldExecute(@RequestBody SysExtendedFieldSaveVO sysExtendedFieldSaveVO) {
		try {
			sysExtendedFieldService.saveExtendedFieldData(sysExtendedFieldSaveVO);
			return RestMessage.newInstance(true, "保存成功", null);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("扩展字段修改")
	@ApiOperation(value = "扩展字段修改", notes = "扩展字段修改")
	@PostMapping("/update")
	public RestMessage<String> updataExtendedFieldExecute(@RequestBody SysExtendedFieldUpdataVO sysExtendedFieldUpdataVO) {
		try {
			sysExtendedFieldService.updataExtendedFieldData(sysExtendedFieldUpdataVO);
			return RestMessage.newInstance(true, "修改成功", null);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

	@UserLog("扩展字段删除")
	@ApiOperation(value = "扩展字段删除", notes = "扩展字段删除")
	@PostMapping("/delete")
	public RestMessage<String> deleteExtendedFieldExecute(@RequestBody List<SysExtendedFieldDeleteVO> sysExtendedFieldDeleteVOs) {
		try {
			sysExtendedFieldService.deleteExtendedFieldData(sysExtendedFieldDeleteVOs);
			return RestMessage.newInstance(true, "删除成功", null);
		} catch (Exception e) {
			e.printStackTrace();
			return RestMessage.newInstance(false, e.getMessage(), null);
		}
	}

}
