|
@@ -0,0 +1,124 @@
|
|
|
+package com.hjy.modlue.portal;
|
|
|
+
|
|
|
+import com.hjy.common.annotation.Log;
|
|
|
+import com.hjy.common.config.ZhbsqConfig;
|
|
|
+import com.hjy.common.constant.Constants;
|
|
|
+import com.hjy.common.core.controller.BaseController;
|
|
|
+import com.hjy.common.core.domain.AjaxResult;
|
|
|
+import com.hjy.common.enums.BusinessType;
|
|
|
+import com.hjy.common.utils.StringUtils;
|
|
|
+import com.hjy.common.utils.file.FileUtils;
|
|
|
+import com.hjy.common.utils.poi.ExcelUtil;
|
|
|
+
|
|
|
+import com.hjy.module.service.portal.ICbOpServiceService;
|
|
|
+import com.hjy.module.vo.portal.CbOpServiceVo;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import com.hjy.common.core.page.TableDataInfo;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import static com.hjy.framework.datasource.DynamicDataSourceContextHolder.log;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 运营服务Controller
|
|
|
+ *
|
|
|
+ * @author Tellsea
|
|
|
+ * @date 2023-08-29
|
|
|
+ */
|
|
|
+@Api(tags = "运营服务Controller")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/OPSERVICE")
|
|
|
+@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
|
|
+public class CbOpServiceController extends BaseController {
|
|
|
+
|
|
|
+ private final ICbOpServiceService cbOpServiceService;
|
|
|
+
|
|
|
+ @ApiOperation("查询运营服务列表")
|
|
|
+ @PreAuthorize("@ss.hasPermi('business:OPSERVICE:list')")
|
|
|
+ @GetMapping("/list")
|
|
|
+ public TableDataInfo<CbOpServiceVo> list(CbOpServiceVo entity) {
|
|
|
+ return cbOpServiceService.queryList(entity);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("查询运营服务所有列表")
|
|
|
+ @GetMapping("/listAll")
|
|
|
+ public AjaxResult listAll(CbOpServiceVo entity) {
|
|
|
+ return AjaxResult.success("查询成功", cbOpServiceService.queryAll(entity));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("导出运营服务列表")
|
|
|
+ @PreAuthorize("@ss.hasPermi('business:OPSERVICE:export')")
|
|
|
+ @Log(title = "运营服务", businessType = BusinessType.EXPORT)
|
|
|
+ @PostMapping("/export")
|
|
|
+ public void export(HttpServletResponse response, CbOpServiceVo entity) {
|
|
|
+ List<CbOpServiceVo> list = cbOpServiceService.queryAll(entity);
|
|
|
+ ExcelUtil<CbOpServiceVo> util = new ExcelUtil<>(CbOpServiceVo.class);
|
|
|
+ util.exportExcel(response, list, "运营服务数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("获取运营服务详细信息")
|
|
|
+ @PreAuthorize("@ss.hasPermi('business:OPSERVICE:query')")
|
|
|
+ @GetMapping(value = "/getInfo/{id}")
|
|
|
+ public AjaxResult getInfo(@PathVariable("id") String id) {
|
|
|
+ return AjaxResult.success("查询成功", cbOpServiceService.queryById(id));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("新增运营服务")
|
|
|
+ @PreAuthorize("@ss.hasPermi('business:OPSERVICE:add')")
|
|
|
+ @Log(title = "运营服务", businessType = BusinessType.INSERT)
|
|
|
+ @PostMapping("add")
|
|
|
+ public AjaxResult add(@RequestBody CbOpServiceVo entity) {
|
|
|
+ return toAjax(cbOpServiceService.save(entity));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("修改运营服务")
|
|
|
+ @PreAuthorize("@ss.hasPermi('business:OPSERVICE:edit')")
|
|
|
+ @Log(title = "运营服务", businessType = BusinessType.UPDATE)
|
|
|
+ @PostMapping("edit")
|
|
|
+ public AjaxResult edit(@RequestBody CbOpServiceVo entity) {
|
|
|
+ return toAjax(cbOpServiceService.updateById(entity));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("删除运营服务")
|
|
|
+ @PreAuthorize("@ss.hasPermi('business:OPSERVICE:remove')")
|
|
|
+ @Log(title = "运营服务", businessType = BusinessType.DELETE)
|
|
|
+ @GetMapping("/remove/{ids}")
|
|
|
+ public AjaxResult remove(@PathVariable String[] ids) {
|
|
|
+ return toAjax(cbOpServiceService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 本地资源通用下载
|
|
|
+ */
|
|
|
+ @ApiOperation("下载")
|
|
|
+ @Log(title = "下载", businessType = BusinessType.DOWNLOAD)
|
|
|
+ @GetMapping("/download")
|
|
|
+ public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) {
|
|
|
+ try {
|
|
|
+ if (!FileUtils.checkAllowDownload(fileName)) {
|
|
|
+ throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
|
|
|
+ }
|
|
|
+ String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
|
|
|
+ String filePath = ZhbsqConfig.getDownloadPath() + fileName;
|
|
|
+
|
|
|
+ response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
|
|
+ FileUtils.setAttachmentResponseHeader(response, realFileName);
|
|
|
+ FileUtils.writeBytes(filePath, response.getOutputStream());
|
|
|
+ if (delete) {
|
|
|
+ FileUtils.deleteFile(filePath);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("下载文件失败", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|