/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights reserved.
 * <a>http://www.crunii.com</a>
 */
package com.crunii.micro.service.sysmgr.controller;

/**
 * @author shenhs create 2023/6/14 14:52
 */

import com.crunii.micro.common.dto.Result;
import com.crunii.micro.domain.entity.main.TsmAppButton;
import com.crunii.micro.service.sysmgr.dto.sysmgr.AppButtonC;
import com.crunii.micro.service.sysmgr.dto.sysmgr.AppButtonU;
import com.crunii.micro.service.sysmgr.dto.sysmgr.AppButtonVo;
import com.crunii.micro.service.sysmgr.service.TsmAppService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "app配置")
@RestController
@Slf4j
@RequestMapping("/auth/tsmAppController")
public class TsmAppController {

	@Autowired
	private TsmAppService tsmAppService;

	/**
	 * 新增
	 */
	@ApiOperation("新增")
	@PostMapping("/create")
	public Result<?> createAppButton(@RequestBody AppButtonC buttonC){
		tsmAppService.createAppButton(buttonC);
		return Result.ofSuccess(null);
	}


	/**
	 * 修改
	 */
	@ApiOperation("修改")
	@PostMapping("/update")
	public Result<?> updateAppButton(@RequestBody AppButtonU appButtonU){
		tsmAppService.updateAppButton(appButtonU);
		return Result.ofSuccess(null);
	}

	/**
	 * 删除
	 */
	@ApiOperation("删除")
	@GetMapping("/del")
	public Result<?> delAppButton(Integer id){
		tsmAppService.deleteAppButton( id != null ? id : TsmAppService.DEF_APP_BUTTON_ID);
		return Result.ofSuccess(null);
	}

	/**
	 * 查询
	 */
	@ApiOperation("查询")
	@GetMapping("/query")
	public Result<List<AppButtonVo>> queryAppButton(Integer id){
		return Result.ofSuccess(tsmAppService.queryAppButton( id != null ? id : TsmAppService.DEF_APP_BUTTON_ID));
	}

}
