package org.dromara.zhishu.controller;


import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaIgnore;
import jakarta.validation.constraints.NotNull;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.zhishu.domain.Logistics;
import org.dromara.zhishu.domain.bo.LogisticsBo;
import org.dromara.zhishu.domain.bo.TLogisticsBo;
import org.dromara.zhishu.service.LogisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/logistics")
public class LogisticsController {

    @Autowired
    private LogisticsService logisticsService;

//    @SaCheckPermission("zhishu:shop:export")
    @Log(title = "", businessType = BusinessType.EXPORT)
    @PostMapping("/logistics")
    @SaIgnore
    public void export(@RequestBody LogisticsBo bo) {
      Integer num= logisticsService.insert(bo);
      if(num>0){
          System.out.println("插入成功");
  }
    }
    @GetMapping("/select")
    @SaIgnore
    public List<Logistics> getLogistics(@RequestParam String warehouseId) {
        List<Logistics> logistics = logisticsService.selectLogistics(warehouseId);
        return logistics;
    }
    @GetMapping("/logistics/{id}")
    @SaIgnore
    public Logistics getInfo(@NotNull(message = "主键不能为空")
                                 @PathVariable Long id){
        return logisticsService.queryById(id);
    }
    /**
     * 修改物流管理
     */
//    @SaCheckPermission("logistics:logistics:edit")
    @Log(title = "修改物流模版", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping("/logistics")
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody LogisticsBo bo) {
       Boolean num= logisticsService.setTemplate(bo);
//        return toAjax(.updateByBo(bo));
        return null;
    }

}
