You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

104 lines
3.5 KiB

package com.ruoyi.business.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.BusVouchers;
import com.ruoyi.business.service.IBusVouchersService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
* 消费券Controller
*
* @author ruoyi
* @date 2022-09-20
*/
@RestController
@RequestMapping("/business/vouchers")
public class BusVouchersController extends BaseController
{
@Autowired
private IBusVouchersService busVouchersService;
/**
* 查询消费券列表
*/
@PreAuthorize("@ss.hasPermi('business:vouchers:list')")
@GetMapping("/list")
public TableDataInfo list(BusVouchers busVouchers)
{
startPage();
List<BusVouchers> list = busVouchersService.selectBusVouchersList(busVouchers);
return getDataTable(list);
}
/**
* 导出消费券列表
*/
@PreAuthorize("@ss.hasPermi('business:vouchers:export')")
@Log(title = "消费券", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, BusVouchers busVouchers)
{
List<BusVouchers> list = busVouchersService.selectBusVouchersList(busVouchers);
ExcelUtil<BusVouchers> util = new ExcelUtil<BusVouchers>(BusVouchers.class);
util.exportExcel(response, list, "消费券数据");
}
/**
* 获取消费券详细信息
*/
@PreAuthorize("@ss.hasPermi('business:vouchers:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Integer id)
{
return AjaxResult.success(busVouchersService.selectBusVouchersById(id));
}
/**
* 新增消费券
*/
@PreAuthorize("@ss.hasPermi('business:vouchers:add')")
@Log(title = "消费券", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody BusVouchers busVouchers)
{
return toAjax(busVouchersService.insertBusVouchers(busVouchers));
}
/**
* 修改消费券
*/
@PreAuthorize("@ss.hasPermi('business:vouchers:edit')")
@Log(title = "消费券", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody BusVouchers busVouchers)
{
return toAjax(busVouchersService.updateBusVouchers(busVouchers));
}
/**
* 删除消费券
*/
@PreAuthorize("@ss.hasPermi('business:vouchers:remove')")
@Log(title = "消费券", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Integer[] ids)
{
return toAjax(busVouchersService.deleteBusVouchersByIds(ids));
}
}