package com.cpop.system.business.controller.backstage;

import com.cpop.core.base.R;
import com.cpop.system.business.bo.StoreBo;
import com.cpop.system.business.bo.StorePageBo;
import com.cpop.system.business.bo.StoreRenewBo;
import com.cpop.system.business.service.StoreRenewService;
import com.cpop.system.business.vo.StorePageVo;
import com.mybatisflex.core.paginate.Page;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.cpop.system.business.service.StoreService;
import io.swagger.annotations.Api;

/**
 * 系统-店铺/校区表 控制层。
 *
 * @author DB
 * @since 2023-10-26
 */
@RestController
@Api(tags = "系统-店铺/校区表接口")
@RequestMapping("/backstage/store")
public class BackstageStoreController {

	@Autowired
	private StoreService storeService;

	@Autowired
	private StoreRenewService storeRenewService;

	/**
	 * 查询校区分页列表
	 * @param bo 请求参数
	 * @return R<PageVo<CampusPageListVo>>
	 * @author Administrator
	 * @since 2023/6/7 0007 10:18
	 */
	@PreAuthorize("@aps.hasPermission('brandStore:store:list')")
	@ApiOperation("查询校区分页列表")
	@GetMapping("/getStorePage")
	public R<Page<StorePageVo>> getStorePage(StorePageBo bo) {
		Page<StorePageVo> pageVo = storeService.getStorePage(bo);
		return R.ok(pageVo);
	}

	/**
	 * 校区续费
	 * @author DB
	 * @since 2024/1/11
	 * @param bo 请求参数
	 * @return R<Void>
	 */
	@ApiOperation("校区续费")
	@PutMapping("/storeRenew")
	public R<Void> storeRenew(@RequestBody @Validated StoreRenewBo bo) {
		storeRenewService.storeRenew(bo);
		return R.ok();
	}

	/**
	 * 更新校区
	 * @author DB
	 * @since 2024/1/15
	 * @param bo 请求参数
	 * @return R<Void>
	 */
	@ApiOperation("更新校区")
	@PutMapping("/updateStore")
	public R<Void> updateStore(@RequestBody @Validated StoreBo bo) {
		storeService.updateStore(bo);
		return R.ok();
	}
}
