FormController.java 1.93 KB
package vion.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import vion.dto.FormDTO;
import vion.service.IFormService;
import vion.vo.FormVO;

/**
 * 表单集合
 */
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
public class FormController {

    private final IFormService formService;

    @GetMapping("/form")
    @SaCheckPermission(value = "form:list", orRole = "admin")
    public Page<FormVO> list(FormDTO dto) {
        return formService.list(dto);
    }

    @PostMapping("/form")
    @SaCheckPermission(value = "form:save", orRole = "admin")
    public Object save(@RequestBody FormDTO dto) {
        return formService.save(dto);
    }

    @PostMapping("/form/{id}")
    @SaCheckPermission(value = "form:edit", orRole = "admin")
    public String updateById(@PathVariable Long id, @RequestBody FormDTO dto) {
        return formService.updateById(id, dto);
    }

    @GetMapping("/form/{id}")
    @SaCheckPermission(value = "form:query", orRole = "admin")
    public FormVO getById(@PathVariable Long id) {
        return formService.getByUniqueId(id, null);
    }

    @DeleteMapping("/form/{id}")
    @SaCheckPermission(value = "form:remove", orRole = "admin")
    public String removeById(@PathVariable Long id) {
        return formService.removeById(id) ? "删除成功" : "删除失败";
    }

    @GetMapping("/form/sign/{uuid}")
    public FormVO getByUuid(@PathVariable String uuid) {
        return formService.getByUniqueId(null, uuid);
    }

    /**
     * 签字专用更新接口
     *
     * @param uuid  uuid
     * @param dto dto
     * @return java.lang.String
     */
    @PostMapping("/form/sign/{uuid}")
    public String updByUuid(@PathVariable String uuid, @RequestBody FormDTO dto) {
        return formService.updByUuid(uuid, dto);
    }
}