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

import com.cpop.core.base.entity.R;
import com.cpop.system.business.bo.StoreBo;
import com.cpop.system.business.service.StoreRenewService;
import com.cpop.system.business.vo.StorePageVo;
import com.mybatisflex.core.paginate.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
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;

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

	@Autowired
	private StoreService storeService;

	@Autowired
	private StoreRenewService storeRenewService;

	/**
	 * 查询校区分页列表
	 * @param name 校区名
	 * @return R<PageVo<StorePageVo>>
	 * @author Administrator
	 * @since 2023/6/7 0007 10:18
	 */
	@Operation(summary = "查询校区分页列表")
	@GetMapping("/getStorePage")
	public R<Page<StorePageVo>> getStorePage(@RequestParam(required = false) @Parameter(description = "校区名") String name) {
		Page<StorePageVo> pageVo = storeService.getStorePage(name);
		return R.ok(pageVo);
	}

	/**
	 * 校区续费
	 * @author DB
	 * @since 2024/1/11
	 * @return R<Void>
	 */
	@Deprecated(since = "1.1.0")
	@Operation(summary = "校区续费")
	@PutMapping("/storeRenew")
	public R<Void> storeRenew() {
		return R.fail("校区续费接口已弃用");
	}

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