Initial commit
This commit is contained in:
@@ -0,0 +1,141 @@
|
||||
package com.gxwebsoft.cms.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.cms.service.ArticleCategoryService;
|
||||
import com.gxwebsoft.cms.entity.ArticleCategory;
|
||||
import com.gxwebsoft.cms.param.ArticleCategoryParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文章分类表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-22 17:49:15
|
||||
*/
|
||||
@Api(tags = "文章分类表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/cms/article-category")
|
||||
public class ArticleCategoryController extends BaseController {
|
||||
@Resource
|
||||
private ArticleCategoryService articleCategoryService;
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:articleCategory:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询文章分类表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<ArticleCategory>> page(ArticleCategoryParam param) {
|
||||
PageParam<ArticleCategory, ArticleCategoryParam> page = new PageParam<>(param);
|
||||
// page.setDefaultOrder("create_time desc");
|
||||
page.setDefaultOrder("sort_number");
|
||||
return success(articleCategoryService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(articleCategoryService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:articleCategory:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部文章分类表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<ArticleCategory>> list(ArticleCategoryParam param) {
|
||||
PageParam<ArticleCategory, ArticleCategoryParam> page = new PageParam<>(param);
|
||||
// page.setDefaultOrder("create_time desc");
|
||||
page.setDefaultOrder("sort_number");
|
||||
return success(articleCategoryService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(articleCategoryService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:articleCategory:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询文章分类表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<ArticleCategory> get(@PathVariable("id") Integer id) {
|
||||
return success(articleCategoryService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(articleCategoryService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:articleCategory:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加文章分类表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody ArticleCategory articleCategory) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
articleCategory.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (articleCategoryService.save(articleCategory)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:articleCategory:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改文章分类表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody ArticleCategory articleCategory) {
|
||||
if (articleCategoryService.updateById(articleCategory)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:articleCategory:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除文章分类表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (articleCategoryService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:articleCategory:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加文章分类表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<ArticleCategory> list) {
|
||||
if (articleCategoryService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:articleCategory:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改文章分类表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<ArticleCategory> batchParam) {
|
||||
if (batchParam.update(articleCategoryService, "category_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:articleCategory:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除文章分类表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (articleCategoryService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.gxwebsoft.cms.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.cms.service.ArticleService;
|
||||
import com.gxwebsoft.cms.entity.Article;
|
||||
import com.gxwebsoft.cms.param.ArticleParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文章记录表控制器
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2022-11-16 11:40:27
|
||||
*/
|
||||
@Api(tags = "文章记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/cms/article")
|
||||
public class ArticleController extends BaseController {
|
||||
@Resource
|
||||
private ArticleService articleService;
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:article:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询文章记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Article>> page(ArticleParam param) {
|
||||
// 使用关联查询
|
||||
return success(articleService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:article:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部文章记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Article>> list(ArticleParam param) {
|
||||
PageParam<Article, ArticleParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
return success(articleService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(articleService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:article:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询文章记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Article> get(@PathVariable("id") Integer id) {
|
||||
// return success(articleService.getById(id));
|
||||
// 使用关联查询
|
||||
Article article = articleService.getByIdRel(id);
|
||||
article.setArticleId(id);
|
||||
article.setVirtualViews(article.getVirtualViews()+1);
|
||||
articleService.saveOrUpdate(article);
|
||||
return success(article);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:article:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加文章记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Article article) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
article.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (articleService.save(article)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:article:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改文章记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Article article) {
|
||||
if (articleService.updateById(article)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:article:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除文章记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (articleService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:article:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加文章记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Article> list) {
|
||||
if (articleService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:article:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改文章记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Article> batchParam) {
|
||||
if (batchParam.update(articleService, "article_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:article:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除文章记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (articleService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.gxwebsoft.cms.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.cms.service.DocsService;
|
||||
import com.gxwebsoft.cms.entity.Docs;
|
||||
import com.gxwebsoft.cms.param.DocsParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文档管理记录表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-16 11:40:27
|
||||
*/
|
||||
@Api(tags = "文档管理记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/cms/docs")
|
||||
public class DocsController extends BaseController {
|
||||
@Resource
|
||||
private DocsService docsService;
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:docs:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询文档管理记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Docs>> page(DocsParam param) {
|
||||
PageParam<Docs, DocsParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc,create_time asc");
|
||||
return success(docsService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
// return success(docsService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:docs:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部文档管理记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Docs>> list(DocsParam param) {
|
||||
PageParam<Docs, DocsParam> page = new PageParam<>(param);
|
||||
// page.setDefaultOrder("sort_number asc,create_time asc");
|
||||
// return success(docsService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
return success(docsService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:docs:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询文档管理记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Docs> get(@PathVariable("id") Integer id) {
|
||||
return success(docsService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(docsService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:docs:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加文档管理记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Docs docs) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
docs.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (docsService.save(docs)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:docs:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改文档管理记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Docs docs) {
|
||||
if (docsService.updateById(docs)) {
|
||||
return success("保存成功");
|
||||
}
|
||||
return fail("保存失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:docs:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除文档管理记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (docsService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:docs:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加文档管理记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Docs> list) {
|
||||
if (docsService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:docs:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改文档管理记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Docs> batchParam) {
|
||||
if (batchParam.update(docsService, "docs_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:docs:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除文档管理记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (docsService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user