package com.rf.psychological.plan.rest;

import com.alibaba.fastjson.JSONObject;
import com.rf.psychological.base.rest.BaseController;
import com.rf.psychological.security.AesEncryptUtils;
import com.rf.psychological.security.SafetyProcess;
import com.rf.psychological.plan.service.HisTestPlanService;
import com.rf.psychological.utils.Result;
import com.rf.psychological.plan.dao.model.HisTestPlanEntry;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
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;

/**
 * @Author:zzf
 * @Date:2022/6/28:17:07
 * @Description:
 */
@Slf4j
@RestController
@RequestMapping("/his/plan")
@Api(tags = "历史测试计划")
public class HisTestPlanController extends BaseController {

    @Autowired
    private HisTestPlanService service;
    /**
     * 查询
     */
    @PostMapping("/find")
    @SafetyProcess
    @ApiOperation("历史测试计划查询")
    public Result find(@RequestBody String json) throws Exception {
        JSONObject jsonObject = JSONObject.parseObject(AesEncryptUtils.decrypt(JSONObject.parseObject(json).getString("data")));
        Page<HisTestPlanEntry> planEntries = this.service.find(jsonObject);
        return success(planEntries);
    }

}
