| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.xinquan.common.core.domain.R; |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.system.domain.CommonQuestion; |
| | | import com.xinquan.system.domain.HotWords; |
| | | import com.xinquan.system.service.HotWordsService; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | public class HotWordsController { |
| | | @Resource |
| | | private HotWordsService hotWordsService; |
| | | @PostMapping("/list") |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @GetMapping("/list") |
| | | @ApiOperation(value = "热词管理-列表查询", tags = {"运营中心"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "分页参数,当前页码", name = "pageCurr", required = true, dataType = "Integer"), |
| | | @ApiImplicitParam(value = "分页参数,每页数量", name = "pageSize", required = true, dataType = "Integer") |
| | | }) |
| | | public R<PageDTO<HotWords>> list( |
| | | @RequestParam(value = "pageCurr", defaultValue = "1") Integer pageCurr, |
| | | @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | Long userId = SecurityUtils.getUserId(); |
| | | if (userId == 0)return R.tokenError("登录失效"); |
| | | Integer pageCurr, |
| | | Integer pageSize) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Page<HotWords> page1 = new Page<>(pageCurr, pageSize); |
| | | Page<HotWords> page = hotWordsService.lambdaQuery() |
| | | .orderByDesc(HotWords::getSortNum) |
| | | .page(new Page<>(pageCurr, pageSize)); |
| | | .page(page1); |
| | | if (page.getRecords().isEmpty()){ |
| | | return R.ok(PageDTO.empty(page)); |
| | | } |
| | |
| | | @PostMapping("/add") |
| | | @ApiOperation(value = "热词管理-添加热词", tags = {"管理后台-运营中心"}) |
| | | public R add(@RequestBody HotWords hotWords) { |
| | | int size = hotWordsService.lambdaQuery().list().size(); |
| | | if (size>=20){ |
| | | return R.fail("热词数量已达上限"); |
| | | } |
| | | hotWordsService.save(hotWords); |
| | | return R.ok(); |
| | | } |
| | |
| | | hotWordsService.update(hotWordsLambdaUpdateWrapper); |
| | | return R.ok(); |
| | | } |
| | | @DeleteMapping("/add") |
| | | @DeleteMapping("/delete") |
| | | @ApiOperation(value = "热词管理-删除热词", tags = {"管理后台-运营中心"}) |
| | | public R add(String id) { |
| | | hotWordsService.removeById(id); |
| | | hotWordsService.removeById(Long.valueOf(id)); |
| | | return R.ok(); |
| | | } |
| | | @DeleteMapping("/queryAddCount") |
| | | @GetMapping("/queryAddCount") |
| | | @ApiOperation(value = "热词管理-查询还可以上传多少个热词", tags = {"管理后台-运营中心"}) |
| | | public R queryAddCount() { |
| | | int i = 20 - hotWordsService.lambdaQuery().list().size(); |