package com.citygis.web.dataEncrypt.controller;

import com.citygis.common.annotation.Log;
import com.citygis.common.core.domain.AjaxResult;
import com.citygis.common.enums.BusinessType;
import com.citygis.web.dataEncrypt.domain.JiaMi;
import com.citygis.web.dataEncrypt.service.DataEncryptService;
import com.citygis.web.dataEncrypt.service.JiaMiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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 javax.annotation.Resource;

@Api(tags = "表字段加密")
@RestController
@RequestMapping("/web/jiaMi")
public class JiaMiController {

    @Resource
    JiaMiService jiaMiService;

    @Resource
    DataEncryptService dataEncryptService;

    /**
     * 表字段加密
     *
     * @param jiaMi
     * @return
     * @throws Exception
     */
    @ApiOperation("表字段加密")
    @Log(title = "表字段加密", businessType = BusinessType.OTHER)
    @PostMapping(value = "/handleEncryption")
    public AjaxResult handleEncryption(@RequestBody JiaMi jiaMi) throws Exception {
        return jiaMiService.handleEncryption(jiaMi);
    }

    @ApiOperation("数据完整性")
    @Log(title = "数据完整性", businessType = BusinessType.OTHER)
    @PostMapping(value = "/dataCompleteness")
    public AjaxResult dataCompleteness(@RequestBody JiaMi jiaMi) {
        return jiaMiService.dataCompleteness(jiaMi.getTableName(), jiaMi.getIdColumn());
    }

    @ApiOperation("验证数据完整性")
    @Log(title = "验证数据完整性", businessType = BusinessType.OTHER)
    @PostMapping(value = "/verifyDataCompleteness")
    public AjaxResult verifyDataCompleteness(@RequestBody JiaMi jiaMi) {
        return jiaMiService.verifyDataCompleteness(jiaMi.getTableName(), jiaMi.getIdColumn());
    }

}
