/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights reserved. <a>http://www.cqcis.com</a>
 */
package com.crunii.micro.service.sysmgr.controller;

import com.crunii.micro.common.dto.PageReq;
import com.crunii.micro.common.dto.PageRsp;
import com.crunii.micro.common.dto.Result;
import com.crunii.micro.domain.entity.main.TEncryptConfig;
import com.crunii.micro.service.sysmgr.dto.enc.EncryptConfigC;
import com.crunii.micro.service.sysmgr.dto.enc.EncryptConfigReq;
import com.crunii.micro.service.sysmgr.dto.enc.EncryptConfigU;
import com.crunii.micro.service.sysmgr.service.EncryptConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author 田平 create 2023-02-21 10:47:54
 */
@Api(value = "加密字段配置相关")
@Controller
@Slf4j
@RequestMapping("/auth/EncryptConfigController")
public class EncryptConfigController {

	@Autowired
	private EncryptConfigService encryptConfigService;

	@ApiOperation(value = "加密字段配置分页")
	@RequestMapping(path = "/pageEncryptConfig", method = RequestMethod.POST)
	@ResponseBody
	public Result<PageRsp<TEncryptConfig>> pageEncryptConfig(@RequestBody @ApiParam PageReq<EncryptConfigReq> req) {
		log.info("req:" + req.toString());
		Result<PageRsp<TEncryptConfig>> result = new Result<>();
		result.setData(encryptConfigService.pageEncryptConfig(req));
		return result;
	}

	@ApiOperation(value = "创建加密字段配置")
	@RequestMapping(path = "/createEncryptConfig", method = RequestMethod.POST)
	@ResponseBody
	public Result<String> createEncryptConfig(@RequestBody @ApiParam EncryptConfigC encryptConfigC) {
		Result<String> result = new Result<>();
		encryptConfigService.createEncryptConfig(encryptConfigC);
		return result;
	}

	@ApiOperation(value = "更新加密字段配置")
	@RequestMapping(path = "/updateEncryptConfig", method = RequestMethod.POST)
	@ResponseBody
	public Result<String> updateEncryptConfig(@RequestBody @ApiParam EncryptConfigU encryptConfigU) {
		Result<String> result = new Result<>();
		encryptConfigService.updateEncryptConfig(encryptConfigU);
		return result;
	}

}
