package com.tievd.jyz.controller;
|
|
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.tievd.cube.commons.annotations.AutoLog;
|
import com.tievd.cube.commons.annotations.DictApi;
|
import com.tievd.cube.commons.base.CubeController;
|
import com.tievd.cube.commons.base.Result;
|
import com.tievd.cube.commons.mybatisplus.QueryGenerator;
|
import com.tievd.jyz.entity.Label;
|
import com.tievd.jyz.service.ILabelService;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import java.io.IOException;
|
import java.util.Arrays;
|
import java.util.List;
|
|
/**
|
* Label
|
*
|
* @author cube
|
* @since 2023-02-27
|
* @version V2.0.0
|
*/
|
@Slf4j
|
@DictApi
|
@RestController
|
@RequestMapping("/jyz/label")
|
public class LabelController extends CubeController<Label, ILabelService> {
|
|
@Autowired
|
private ILabelService labelService;
|
|
/**
|
* 分页列表查询
|
*/
|
@GetMapping("/list")
|
public Result<?> queryPageList(Label label,
|
@RequestParam(defaultValue="1") Integer pageNo,
|
@RequestParam(defaultValue="10") Integer pageSize,
|
HttpServletRequest req) {
|
QueryWrapper<Label> queryWrapper = QueryGenerator.initQueryWrapper(label, req.getParameterMap());
|
Page<Label> page = new Page<>(pageNo, pageSize);
|
IPage<Label> pageList = labelService.page(page, queryWrapper);
|
return Result.ok(pageList);
|
}
|
|
/**
|
* 添加
|
*/
|
@AutoLog("Label-添加")
|
@PostMapping("/add")
|
public Result<?> add(@RequestBody Label label) {
|
labelService.save(label);
|
return Result.ok();
|
}
|
|
/**
|
* 编辑
|
*/
|
@AutoLog("Label-编辑")
|
@PutMapping("/edit")
|
public Result<?> edit(@RequestBody Label label){
|
labelService.updateById(label);
|
return Result.ok();
|
}
|
|
/**
|
* 通过id删除
|
*/
|
@AutoLog("Label-通过id删除")
|
@DeleteMapping("/delete")
|
public Result<?> delete(@RequestParam String id) {
|
labelService.removeById(id);
|
return Result.ok();
|
}
|
|
/**
|
* 批量删除
|
*/
|
@AutoLog("Label-批量删除")
|
@DeleteMapping("/deleteBatch")
|
public Result<?> deleteBatch(@RequestParam String ids) {
|
this.labelService.removeByIds(Arrays.asList(ids.split(",")));
|
return Result.ok();
|
}
|
|
/**
|
* 通过id查询
|
*/
|
@GetMapping("/queryById")
|
public Result<?> queryById(@RequestParam String id) {
|
Label label = labelService.getById(id);
|
return Result.ok(label);
|
}
|
|
/**
|
* 导出excel
|
*/
|
@RequestMapping("/exportXls")
|
public void exportXls(HttpServletRequest request, HttpServletResponse response, Label label) throws IOException {
|
super.exportXls(request, response, label, "Label");
|
}
|
|
/**
|
* 通过excel导入数据
|
*/
|
@PostMapping("/importExcel")
|
public Result<?> importExcel(HttpServletRequest request) throws Exception {
|
return super.importExcel(request, Label.class);
|
}
|
|
@GetMapping("/listLabel")
|
public Result<?> listLabel(){
|
List<String> labels = labelService.listLabel();
|
return Result.ok(labels);
|
}
|
}
|