package com.ym.mec.web.controller;

import com.ym.mec.biz.dal.entity.Photo;
import com.ym.mec.biz.dal.page.PhotoQueryInfo;
import com.ym.mec.biz.service.PhotoService;
import com.ym.mec.common.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
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;

import java.util.List;

@RequestMapping("photo")
@Api(tags = "相片")
@RestController
public class PhotoController extends BaseController {

	@Autowired
	private PhotoService photoService;

	@ApiOperation("新增")
	@PostMapping(value = "add")
	@PreAuthorize("@pcs.hasPermissions('photo/add')")
	public Object add(@RequestBody List<Photo> photoList) {
		return succeed(photoService.batchAdd(photoList));
	}

	@ApiOperation("修改")
	@PostMapping(value = "batchUpdate")
	@PreAuthorize("@pcs.hasPermissions('photo/batchUpdate')")
	public Object batchUpdate(@RequestBody List<Photo> photoList) {
		return succeed(photoService.batchUpdate(photoList));
	}

	@ApiOperation("删除")
	@PostMapping(value = "del")
	@PreAuthorize("@pcs.hasPermissions('photo/del')")
	public Object del(String ids) {
		return succeed(photoService.del(ids));
	}

	@ApiOperation("分页查询")
	@PostMapping(value = "queryPage")
	@PreAuthorize("@pcs.hasPermissions('photo/queryPage')")
	public Object queryPage(PhotoQueryInfo queryInfo) {
		return succeed(photoService.queryPhotoPage(queryInfo));
	}
}
