package org.springblade.modules.system.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wn.common.datamodel.ResultDTO;
import io.swagger.annotations.ApiImplicitParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.cache.utils.CacheUtil;
import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.RoleConstant;
import org.springblade.modules.app.common.dto.ProblemBackDTO;
import org.springblade.modules.app.common.query.ProblemBackQuery;
import org.springblade.modules.app.manager.ProblemBackManager;
import org.springblade.modules.system.entity.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

import static org.springblade.core.cache.constant.CacheConstant.PARAM_CACHE;

@NonDS
@RestController
@AllArgsConstructor
@RequestMapping(AppConstant.APPLICATION_SYSTEM_NAME + "/problem")
@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
public class ProblemBackController extends BladeController {
    @Autowired
    private ProblemBackManager problemBackManager;

    @PostMapping("/submit")
	//@ApiOperationSupport(order = 3)
	//@ApiOperation(value = "新增或修改", notes = "传入param")
	public R submit(@Valid @RequestBody ProblemBackDTO param) {
		return R.status(problemBackManager.update(param));
	}

    //@ApiOperation(value = "分页查询反馈列表")
    @GetMapping("/page")
    public R<Page<ProblemBackDTO>> page(ProblemBackQuery query){
        return R.data(problemBackManager.page(query));
    }

    //@ApiOperation(value = "查询反馈信息")
    @PutMapping("/info/{id}")
    @ApiImplicitParam(name = "id", value = "反馈id", required = true)
    public R<ProblemBackDTO> info(@PathVariable("id") Long id){
        return R.data(problemBackManager.info(id));
    }
}
