/*
|
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
*
|
* Redistribution and use in source and binary forms, with or without
|
* modification, are permitted provided that the following conditions are met:
|
*
|
* Redistributions of source code must retain the above copyright notice,
|
* this list of conditions and the following disclaimer.
|
* Redistributions in binary form must reproduce the above copyright
|
* notice, this list of conditions and the following disclaimer in the
|
* documentation and/or other materials provided with the distribution.
|
* Neither the name of the dreamlu.net developer nor the names of its
|
* contributors may be used to endorse or promote products derived from
|
* this software without specific prior written permission.
|
* Author: Chill 庄骞 (smallchill@163.com)
|
*/
|
package org.springblade.modules.community.controller;
|
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiParam;
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
import lombok.AllArgsConstructor;
|
import javax.validation.Valid;
|
|
import org.springblade.core.excel.util.ExcelUtil;
|
import org.springblade.core.secure.BladeUser;
|
import org.springblade.core.mp.support.Condition;
|
import org.springblade.core.mp.support.Query;
|
import org.springblade.core.tool.api.R;
|
import org.springblade.core.tool.utils.Func;
|
import org.springblade.modules.community.excel.CommunityExcel;
|
import org.springblade.modules.community.excel.CommunityImporter;
|
import org.springblade.modules.grid.excel.GridExcel;
|
import org.springblade.modules.grid.excel.GridImporter;
|
import org.springframework.web.bind.annotation.*;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import org.springblade.modules.community.entity.CommunityEntity;
|
import org.springblade.modules.community.vo.CommunityVO;
|
import org.springblade.modules.community.wrapper.CommunityWrapper;
|
import org.springblade.modules.community.service.ICommunityService;
|
import org.springblade.core.boot.ctrl.BladeController;
|
import org.springframework.web.multipart.MultipartFile;
|
|
/**
|
* 社区表 控制器
|
*
|
* @author BladeX
|
* @since 2023-12-21
|
*/
|
@RestController
|
@AllArgsConstructor
|
@RequestMapping("blade-community/community")
|
@Api(value = "社区表", tags = "社区表接口")
|
public class CommunityController {
|
|
private final ICommunityService communityService;
|
|
/**
|
* 社区表 详情
|
*/
|
@GetMapping("/detail")
|
@ApiOperationSupport(order = 1)
|
@ApiOperation(value = "详情", notes = "传入community")
|
public R<CommunityVO> detail(CommunityEntity community) {
|
CommunityEntity detail = communityService.getOne(Condition.getQueryWrapper(community));
|
return R.data(CommunityWrapper.build().entityVO(detail));
|
}
|
|
/**
|
* 社区表 自定义详情
|
*/
|
@GetMapping("/getDetail")
|
public R<CommunityVO> getDetail(CommunityEntity community) {
|
return R.data(communityService.getDetail(community));
|
}
|
|
/**
|
* 社区表 分页
|
*/
|
@GetMapping("/list")
|
@ApiOperationSupport(order = 2)
|
@ApiOperation(value = "分页", notes = "传入community")
|
public R<IPage<CommunityVO>> list(CommunityEntity community, Query query) {
|
IPage<CommunityEntity> pages = communityService.page(Condition.getPage(query), Condition.getQueryWrapper(community));
|
return R.data(CommunityWrapper.build().pageVO(pages));
|
}
|
|
/**
|
* 社区表 自定义分页
|
*/
|
@GetMapping("/page")
|
@ApiOperationSupport(order = 3)
|
@ApiOperation(value = "分页", notes = "传入community")
|
public R<IPage<CommunityVO>> page(CommunityVO community, Query query) {
|
IPage<CommunityVO> pages = communityService.selectCommunityPage(Condition.getPage(query), community);
|
return R.data(pages);
|
}
|
|
/**
|
* 社区表 新增
|
*/
|
@PostMapping("/save")
|
@ApiOperationSupport(order = 4)
|
@ApiOperation(value = "新增", notes = "传入community")
|
public R save(@Valid @RequestBody CommunityEntity community) {
|
return R.status(communityService.save(community));
|
}
|
|
/**
|
* 社区表 修改
|
*/
|
@PostMapping("/update")
|
@ApiOperationSupport(order = 5)
|
@ApiOperation(value = "修改", notes = "传入community")
|
public R update(@Valid @RequestBody CommunityEntity community) {
|
return R.status(communityService.updateById(community));
|
}
|
|
/**
|
* 社区表 新增或修改
|
*/
|
@PostMapping("/submit")
|
@ApiOperationSupport(order = 6)
|
@ApiOperation(value = "新增或修改", notes = "传入community")
|
public R submit(@Valid @RequestBody CommunityEntity community) {
|
return R.status(communityService.saveOrUpdate(community));
|
}
|
|
/**
|
* 社区表 自定义新增或修改
|
*/
|
@PostMapping("/saveOrUpdate")
|
public R saveOrUpdate(@Valid @RequestBody CommunityEntity community) {
|
return R.status(communityService.saveOrUpdateCommunityEntity(community));
|
}
|
|
/**
|
* 社区表 删除
|
*/
|
@PostMapping("/remove")
|
@ApiOperationSupport(order = 7)
|
@ApiOperation(value = "逻辑删除", notes = "传入ids")
|
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
return R.status(communityService.removeByIds(Func.toLongList(ids)));
|
}
|
|
/**
|
* 导入社区数据
|
*/
|
@PostMapping("/import-community")
|
public R importCommunity(MultipartFile file, Integer isCovered) {
|
CommunityImporter communityImporter = new CommunityImporter(communityService, isCovered == 1);
|
ExcelUtil.save(file, communityImporter, CommunityExcel.class);
|
return R.success("操作成功");
|
}
|
|
|
}
|