package com.gear.admin.controller.finance;
|
|
import java.util.List;
|
import javax.servlet.http.HttpServletResponse;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.gear.common.builder.WhereBuilder;
|
import com.gear.common.vo.Result;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
import com.gear.common.annotation.Log;
|
import com.gear.common.core.controller.BaseController;
|
import com.gear.common.enums.BusinessType;
|
import com.gear.finance.domain.FinanceGoodsType;
|
import com.gear.finance.service.IFinanceGoodsTypeService;
|
import com.gear.common.utils.poi.ExcelUtil;
|
|
/**
|
* 商品类型Controller
|
*
|
* @author czx
|
* @date 2023-11-16
|
*/
|
@RestController
|
@RequestMapping("/finance/goodsType")
|
public class FinanceGoodsTypeController extends BaseController
|
{
|
@Autowired
|
private IFinanceGoodsTypeService financeGoodsTypeService;
|
|
/**
|
* 查询商品类型列表
|
*/
|
@PreAuthorize("@ss.hasPermi('finance:goodsType:list')")
|
@GetMapping("/list")
|
public Result<List<FinanceGoodsType>> list(FinanceGoodsType financeGoodsType)
|
{
|
List<FinanceGoodsType> list = financeGoodsTypeService.list();
|
return Result.OK(list);
|
}
|
|
/**
|
* 导出商品类型列表
|
*/
|
@PreAuthorize("@ss.hasPermi('finance:goodsType:export')")
|
@Log(title = "商品类型", businessType = BusinessType.EXPORT)
|
@PostMapping("/export")
|
public void export(HttpServletResponse response, FinanceGoodsType financeGoodsType){
|
QueryWrapper<FinanceGoodsType> queryWrapper = WhereBuilder.build(financeGoodsType);
|
List<FinanceGoodsType> list = financeGoodsTypeService.list(queryWrapper);
|
ExcelUtil<FinanceGoodsType> util = new ExcelUtil<FinanceGoodsType>(FinanceGoodsType.class);
|
util.exportExcel(response, list, "商品类型数据");
|
}
|
|
/**
|
* 获取商品类型详细信息
|
*/
|
@PreAuthorize("@ss.hasPermi('finance:goodsType:query')")
|
@GetMapping(value = "/{id}")
|
public Result<FinanceGoodsType> getInfo(@PathVariable("id") String id){
|
FinanceGoodsType financeGoodsType = financeGoodsTypeService.getById(id);
|
if(financeGoodsType==null) {
|
return Result.error("未找到对应数据");
|
}
|
return Result.OK(financeGoodsType);
|
}
|
|
/**
|
* 新增商品类型
|
*/
|
@PreAuthorize("@ss.hasPermi('finance:goodsType:add')")
|
@Log(title = "商品类型", businessType = BusinessType.INSERT)
|
@PostMapping
|
public Result<String> add(@RequestBody FinanceGoodsType financeGoodsType){
|
financeGoodsTypeService.save(financeGoodsType);
|
return Result.ok("添加成功!");
|
}
|
|
/**
|
* 修改商品类型
|
*/
|
@PreAuthorize("@ss.hasPermi('finance:goodsType:edit')")
|
@Log(title = "商品类型", businessType = BusinessType.UPDATE)
|
@PutMapping
|
public Result<String> edit(@RequestBody FinanceGoodsType financeGoodsType){
|
financeGoodsTypeService.updateById(financeGoodsType);
|
return Result.ok("编辑成功!");
|
}
|
|
/**
|
* 删除商品类型
|
*/
|
@PreAuthorize("@ss.hasPermi('finance:goodsType:remove')")
|
@Log(title = "商品类型", businessType = BusinessType.DELETE)
|
@DeleteMapping("/{ids}")
|
public Result<String> remove(@PathVariable List<String> ids){
|
financeGoodsTypeService.removeBatchByIds(ids);
|
return Result.ok("删除成功!");
|
}
|
}
|