package com.sysu.admin.controller.crop.images;


import com.alibaba.fastjson.annotation.JSONField;
import com.sysu.admin.support.system.config.ConfigContext;
import com.xiesx.fastboot.core.jpa.entity.JpaPlusEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import lombok.experimental.FieldNameConstants;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("/crop_image")
public class CropImageController {

    @Autowired
    CropImageService cropImageService;

    @RequestMapping("/view")
    public String view(Long id, Model model){
        List<CropImage> cropImageList = cropImageService.findByCropId(id);
        cropImageList.stream().forEach(cropImage -> {
            switch (CropImage.getImageType(cropImage.getType())){
                case fay:
                    model.addAttribute("fay",cropImage);
                    break;
                case center:
                    model.addAttribute("center",cropImage);
                    break;
                case near:
                    model.addAttribute("near",cropImage);
                    break;
            }
        });
        return "page/crop-image/view";
    }


}
