|
|
@@ -0,0 +1,154 @@
|
|
|
+package com.jeesite.modules.mes.web;
|
|
|
+
|
|
|
+import java.io.InputStream;
|
|
|
+import java.io.OutputStream;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.util.List;
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import com.jeesite.common.collect.ListUtils;
|
|
|
+import com.jeesite.common.lang.ObjectUtils;
|
|
|
+import com.jeesite.modules.file.entity.FileUpload;
|
|
|
+import com.jeesite.modules.file.service.FileUploadService;
|
|
|
+import com.jeesite.modules.mes.resp.CommonResp;
|
|
|
+import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.ui.Model;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+
|
|
|
+import com.jeesite.common.config.Global;
|
|
|
+import com.jeesite.common.entity.Page;
|
|
|
+import com.jeesite.common.web.BaseController;
|
|
|
+import com.jeesite.modules.mes.entity.MesClient;
|
|
|
+import com.jeesite.modules.mes.service.MesClientService;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 客户端版本管理Controller
|
|
|
+ * @author jingbo
|
|
|
+ * @version 2026-05-25
|
|
|
+ */
|
|
|
+@Controller
|
|
|
+@RequestMapping(value = "${adminPath}/mes/mesClient")
|
|
|
+public class MesClientController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MesClientService mesClientService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private FileUploadService fileUploadService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取数据
|
|
|
+ */
|
|
|
+ @ModelAttribute
|
|
|
+ public MesClient get(String id, boolean isNewRecord) {
|
|
|
+ return mesClientService.get(id, isNewRecord);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询列表
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesClient:view")
|
|
|
+ @RequestMapping(value = {"list", ""})
|
|
|
+ public String list(MesClient mesClient, Model model) {
|
|
|
+ model.addAttribute("mesClient", mesClient);
|
|
|
+ return "modules/mes/mesClientList";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询列表数据
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesClient:view")
|
|
|
+ @RequestMapping(value = "listData")
|
|
|
+ @ResponseBody
|
|
|
+ public Page<MesClient> listData(MesClient mesClient, HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ mesClient.setPage(new Page<>(request, response));
|
|
|
+ Page<MesClient> page = mesClientService.findPage(mesClient);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查看编辑表单
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesClient:view")
|
|
|
+ @RequestMapping(value = "form")
|
|
|
+ public String form(MesClient mesClient, Model model) {
|
|
|
+ model.addAttribute("mesClient", mesClient);
|
|
|
+ return "modules/mes/mesClientForm";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存数据
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesClient:edit")
|
|
|
+ @PostMapping(value = "save")
|
|
|
+ @ResponseBody
|
|
|
+ public String save(@Validated MesClient mesClient) {
|
|
|
+ mesClientService.save(mesClient);
|
|
|
+ return renderResult(Global.TRUE, text("保存客户端版本管理成功!"));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除数据
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesClient:edit")
|
|
|
+ @RequestMapping(value = "delete")
|
|
|
+ @ResponseBody
|
|
|
+ public String delete(MesClient mesClient) {
|
|
|
+ mesClientService.delete(mesClient);
|
|
|
+ return renderResult(Global.TRUE, text("删除客户端版本管理成功!"));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取最新版本
|
|
|
+ *
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "findLatestVersion")
|
|
|
+ @ResponseBody
|
|
|
+ public void findLatestVersion(HttpServletRequest request,HttpServletResponse response){
|
|
|
+ try {
|
|
|
+ MesClient mesClient = mesClientService.findLatestVersion();
|
|
|
+ if (ObjectUtils.isEmpty(mesClient)){
|
|
|
+ response.setContentType("text/html;charset=utf-8");
|
|
|
+ response.getWriter().write("暂无版本记录");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取文件
|
|
|
+ FileUpload fu = new FileUpload();
|
|
|
+ fu.setBizKey(mesClient.getId());
|
|
|
+ fu.setBizType("mesClient_file");
|
|
|
+ List<FileUpload> finfo = fileUploadService.findList(fu);
|
|
|
+ if (ListUtils.isEmpty(finfo)){
|
|
|
+ response.setContentType("text/html;charset=utf-8");
|
|
|
+ response.getWriter().write("暂无可下载的文件");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 构建完整的文件URL
|
|
|
+ String host = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/js";
|
|
|
+ String fileUrl = host + finfo.get(0).getFileUrl();
|
|
|
+
|
|
|
+ // 重定向到文件地址进行下载
|
|
|
+ response.sendRedirect(fileUrl);
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("下载客户端版本文件失败", e);
|
|
|
+ try {
|
|
|
+ response.setContentType("text/html;charset=utf-8");
|
|
|
+ response.getWriter().write("下载失败:" + e.getMessage());
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error("响应错误信息失败", ex);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|