package org.jeecg.modules.api.workorderController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.apiBean.PageBean;
import org.jeecg.modules.apiService.CollectionService;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags="收藏信息相关接口")
@RestController
@RequestMapping("/workorder/collection")
@Slf4j
public class CollectionController {

    //轮播图信息
    @Resource
    private CollectionService collectionService;
    /****************************************************************************************************/

    @ApiOperation(value="收藏信息-我的收藏", notes="收藏信息-我的收藏")
    @RequestMapping(value = "/queryCollectionList", method = {RequestMethod.GET})
    public Result<?> queryCollectionList(@RequestHeader("X-Access-Token") String userId, String statusId, PageBean pageBean){
        return collectionService.queryCollectionList(userId, statusId, pageBean);
    }

    @ApiOperation(value="收藏信息-添加收藏", notes="收藏信息-添加收藏")
    @RequestMapping(value = "/addCollection", method = {RequestMethod.GET})
    public Result<?> addCollection(@RequestHeader("X-Access-Token") String userId, String templateId){
        String message;

        if(StringUtils.isEmpty(templateId)){
            message = "工单编号不存在，请输入templateId！";
        }else {
            return collectionService.addCollection(userId, templateId);
        }
        return Result.error(message);
    }

    @ApiOperation(value="收藏信息-取消收藏", notes="收藏信息-取消收藏")
    @RequestMapping(value = "/deleteCollection", method = {RequestMethod.GET})
    public Result<?> deleteCollection(@RequestHeader("X-Access-Token") String userId, String collectionId){
        String message;

        if(StringUtils.isEmpty(collectionId)){
            message = "收藏编号不存在，请输入collectionId！";
        }else {
            return collectionService.deleteCollection(userId, collectionId);
        }
        return Result.error(message);

    }

}
