package com.dg.core.controller;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.dg.core.ResultData;
|
import com.dg.core.annotation.Authorization;
|
import com.dg.core.db.gen.entity.KeywordEntity;
|
import com.dg.core.service.IKeywordService;
|
import com.dg.core.util.TableDataInfo;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.util.Assert;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.List;
|
|
@Api(tags = {"关键词接口"})
|
@RestController
|
@RequestMapping("/keyword")
|
public class KeywordController extends BaseController
|
{
|
@Autowired(required = true)
|
IKeywordService iKeywordService;
|
|
/**
|
* 查询关键词列表
|
* @return
|
*/
|
@ApiOperation("关键词列表接口")
|
@GetMapping("/getlist")
|
@Authorization
|
public TableDataInfo selectConfigList(@RequestParam(value = "pageNum",required = false) Integer pageNum,
|
@RequestParam(value = "pageSize",required = false) Integer pageSize)
|
{
|
Assert.notNull(pageNum, "pageNum can not be empty");
|
Assert.notNull(pageSize, "pageSize can not be empty");
|
Page<KeywordEntity> pageParam = new Page<>(pageNum,pageSize);
|
List<KeywordEntity> list = iKeywordService.selectConfigList(pageParam,pageSize);
|
|
int num=iKeywordService.countNum();
|
return getDataTable(list,num);
|
}
|
|
/**
|
* 查询详情
|
* @return
|
*/
|
@ApiOperation("关键词详情接口")
|
@GetMapping("/getData")
|
@Authorization
|
public ResultData selectConfigData(@RequestParam(value = "id",required = false) String id,
|
@RequestParam(value = "name",required = false) String name)
|
{
|
return ResultData.success(iKeywordService.selectConfigData(id,name));
|
}
|
|
|
/**
|
* 添加关键词
|
* @return
|
*/
|
@ApiOperation("关键词添加接口")
|
@PostMapping("/add")
|
@Authorization
|
public ResultData insertConfig(@RequestBody KeywordEntity entity)
|
{
|
KeywordEntity enti=iKeywordService.selectConfigData("",entity.getName());
|
if(enti==null)
|
{
|
if(iKeywordService.insertConfig(entity)>0)
|
{
|
enti=iKeywordService.selectConfigData("",entity.getName());
|
return ResultData.success(enti);
|
}
|
}
|
else
|
{
|
return ResultData.success(enti);
|
}
|
return ResultData.error("创建数据失败");
|
}
|
|
/**
|
* 编辑关键词
|
* @return
|
*/
|
@ApiOperation("关键词编辑接口")
|
@PostMapping("/update")
|
@Authorization
|
public ResultData updateConfig(@RequestBody KeywordEntity entity)
|
{
|
return toAjax(iKeywordService.updateConfig(entity));
|
}
|
|
/**
|
* 删除关键词
|
* @param Id
|
* @return
|
*/
|
@ApiOperation("关键词删除接口")
|
@DeleteMapping("/delete")
|
@Authorization
|
public ResultData deleteConfigById(String Id)
|
{
|
return toAjax(iKeywordService.deleteConfigById(Id));
|
}
|
|
}
|