
package com.tmerclub.cloud.biz.controller.platform;

import com.tmerclub.cloud.biz.service.AttachFileService;
import com.tmerclub.cloud.common.constant.Constant;
import com.tmerclub.cloud.common.response.ServerResponseEntity;
import com.tmerclub.cloud.common.security.AuthUserContext;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author lth
 * @Date 2021/6/1 15:45
 */
@RestController("platformAttachFileController")
@RequestMapping("/p/attachFile")
@Tag(name = "platform-上传文件记录表")
public class AttachFileController {

    @Autowired
    private AttachFileService attachFileService;

    @DeleteMapping("/deleteByIds")
    @Operation(summary = "根据文件id列表批量删除文件记录", description = "根据文件id列表批量删除文件记录")
    public ServerResponseEntity<Void> deleteByIds(@RequestBody List<Long> ids) {
        Long shopId = Constant.PLATFORM_SHOP_ID;
        attachFileService.deleteByIdsAndShopId(ids, shopId);
        return ServerResponseEntity.success();
    }

    @PutMapping("/batchMove")
    @Operation(summary = "根据文件id列表与分组id批量移动文件", description = "根据文件id列表与分组id批量移动文件")
    public ServerResponseEntity<Void> batchMove(@RequestBody List<Long> ids, @RequestParam(value = "groupId", required = false, defaultValue = "") Long groupId) {
        Long shopId = Constant.PLATFORM_SHOP_ID;
        Integer sysType = AuthUserContext.get().getSysType();
        attachFileService.batchMoveByShopIdAndIdsAndGroupId(shopId, ids, groupId, sysType);
        return ServerResponseEntity.success();
    }
}
