|
@@ -0,0 +1,141 @@
|
|
|
|
|
+package com.jeesite.modules.mesclient.web;
|
|
|
|
|
+
|
|
|
|
|
+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.common.shiro.authc.FormToken;
|
|
|
|
|
+import com.jeesite.common.shiro.filter.FormFilter;
|
|
|
|
|
+import com.jeesite.common.shiro.realm.AuthorizingRealm;
|
|
|
|
|
+import com.jeesite.modules.file.entity.FileUpload;
|
|
|
|
|
+import com.jeesite.modules.file.service.FileUploadService;
|
|
|
|
|
+import com.jeesite.modules.mesclient.entity.MesClientVersion;
|
|
|
|
|
+import com.jeesite.modules.mes.resp.CommonResp;
|
|
|
|
|
+import com.jeesite.modules.mesclient.service.MesClientVersionService;
|
|
|
|
|
+import com.jeesite.modules.sys.utils.UserUtils;
|
|
|
|
|
+import org.apache.shiro.authc.AuthenticationException;
|
|
|
|
|
+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;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 瀹夊崜鐗堟湰Controller
|
|
|
|
|
+ * @author hzd
|
|
|
|
|
+ * @version 2023-08-11
|
|
|
|
|
+ */
|
|
|
|
|
+@Controller
|
|
|
|
|
+@RequestMapping(value = "${adminPath}/mes/clientVersion")
|
|
|
|
|
+public class MesClientVersionController extends BaseController {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MesClientVersionService mesClientVersionService;
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private FileUploadService fileUploadService;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 鑾峰彇鏁版嵁
|
|
|
|
|
+ */
|
|
|
|
|
+ @ModelAttribute
|
|
|
|
|
+ public MesClientVersion get(String id, boolean isNewRecord) {
|
|
|
|
|
+ return mesClientVersionService.get(id, isNewRecord);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 鏌ヨ鍒楄〃
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequiresPermissions("mes:clientVersion:view")
|
|
|
|
|
+ @RequestMapping(value = {"list", ""})
|
|
|
|
|
+ public String list(MesClientVersion mesClientVersion, Model model) {
|
|
|
|
|
+ model.addAttribute("mesClientVersion", mesClientVersion);
|
|
|
|
|
+ return "modules/mesclient/mesClientVersionList";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 鏌ヨ鍒楄〃鏁版嵁
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequiresPermissions("mes:clientVersion:view")
|
|
|
|
|
+ @RequestMapping(value = "listData")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public Page<MesClientVersion> listData(MesClientVersion mesClientVersion, HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
|
+ mesClientVersion.setPage(new Page<>(request, response));
|
|
|
|
|
+ Page<MesClientVersion> page = mesClientVersionService.findPage(mesClientVersion);
|
|
|
|
|
+ return page;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 鏌ョ湅缂栬緫琛ㄥ崟
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequiresPermissions("mes:clientVersion:view")
|
|
|
|
|
+ @RequestMapping(value = "form")
|
|
|
|
|
+ public String form(MesClientVersion mesClientVersion, Model model) {
|
|
|
|
|
+ model.addAttribute("mesClientVersion", mesClientVersion);
|
|
|
|
|
+ return "modules/mesclient/mesClientVersionForm";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 淇濆瓨鏁版嵁
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequiresPermissions("mes:clientVersion:edit")
|
|
|
|
|
+ @PostMapping(value = "save")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public String save(@Validated MesClientVersion mesClientVersion) {
|
|
|
|
|
+ mesClientVersionService.save(mesClientVersion);
|
|
|
|
|
+ return renderResult(Global.TRUE, text("Operation succeeded"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 鍒犻櫎鏁版嵁
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequiresPermissions("mes:clientVersion:edit")
|
|
|
|
|
+ @RequestMapping(value = "delete")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public String delete(MesClientVersion mesClientVersion) {
|
|
|
|
|
+ mesClientVersionService.delete(mesClientVersion);
|
|
|
|
|
+ return renderResult(Global.TRUE, text("Operation succeeded"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @RequestMapping(value = "ver")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public CommonResp ver(HttpServletRequest req) {
|
|
|
|
|
+ String host = req.getScheme() + "://" + req.getServerName() + ":" + req.getServerPort() + "/js";
|
|
|
|
|
+ CommonResp<MesClientVersion> resp = new CommonResp<>();
|
|
|
|
|
+ MesClientVersion mesClientVersion = mesClientVersionService.findLatestVersion();
|
|
|
|
|
+ if(ObjectUtils.isEmpty(mesClientVersion)){
|
|
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
|
|
+ resp.setMessage("No available client version");
|
|
|
|
|
+ return resp;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 鑾峰彇鍥剧墖
|
|
|
|
|
+ FileUpload fu = new FileUpload();
|
|
|
|
|
+ fu.setBizKey(mesClientVersion.getId());
|
|
|
|
|
+ fu.setBizType("mesClientVersion_file");
|
|
|
|
|
+ List<FileUpload> finfo = fileUploadService.findList(fu);
|
|
|
|
|
+ if(ListUtils.isEmpty(finfo)){
|
|
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
|
|
+ resp.setMessage("No available client version");
|
|
|
|
|
+ return resp;
|
|
|
|
|
+ }
|
|
|
|
|
+ mesClientVersion.setPath(host + finfo.get(0).getFileUrl());
|
|
|
|
|
+ resp.setData(mesClientVersion);
|
|
|
|
|
+ resp.setResult(Global.TRUE);
|
|
|
|
|
+ return resp;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+}
|