package com.hotwj.platform.common.photoEvidence.controller;

import com.hotwj.platform.common.photoEvidence.domain.bo.PhotoEvidenceCreateBo;
import com.hotwj.platform.common.photoEvidence.domain.vo.PhotoEvidenceVo;
import com.hotwj.platform.common.photoEvidence.service.IPhotoEvidenceService;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.domain.model.LoginUser;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.web.core.BaseController;
import org.springframework.validation.annotation.Validated;
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;

@Validated
@RestController
@RequestMapping("/common/photoEvidence")
public class PhotoEvidenceController extends BaseController {

    @Resource
    private IPhotoEvidenceService photoEvidenceService;

    @RepeatSubmit
    @Log(title = "照片取证水印生成", businessType = BusinessType.INSERT)
    @PostMapping("/create")
    @Operation(summary = "生成带时间地点水印的照片取证记录")
    public R<PhotoEvidenceVo> create(@Valid @RequestBody PhotoEvidenceCreateBo bo) {
        LoginUser loginUser = LoginHelper.getLoginUser();
        Long companyId = loginUser.getCompanyId();
        bo.setCompanyId(companyId);
        bo.setOperatorId(loginUser.getBusinessUserId());
        bo.setOperatorName(loginUser.getUsername());

        PhotoEvidenceVo vo = photoEvidenceService.create(bo);
        return R.ok(vo);
    }
}
