diff --git a/pom.xml b/pom.xml index ae9523c..0552190 100644 --- a/pom.xml +++ b/pom.xml @@ -240,6 +240,7 @@ ruoyi-generator ruoyi-common ruoyi-device + ruoyi-pda pom diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index d154e40..4f30c2f 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -66,9 +66,14 @@ com.ruoyi ruoyi-generator + + + + + com.ruoyi - ruoyi-device + ruoyi-pda 4.8.0 diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index c92d9f2..3800344 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -64,9 +64,9 @@ spring: servlet: multipart: # 单个文件大小 - max-file-size: 10MB + max-file-size: 20MB # 设置总上传的文件大小 - max-request-size: 20MB + max-request-size: 40MB # 服务模块 devtools: restart: diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java index 371e823..52061ab 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java @@ -36,7 +36,7 @@ public class MimeTypeUtils // 视频格式 "mp4", "avi", "rmvb", // pdf - "pdf" }; + "pdf" ,"apk"}; public static String getExtension(String prefix) { diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/security/Md5Utils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/security/Md5Utils.java index ff9937f..db3eae0 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/security/Md5Utils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/security/Md5Utils.java @@ -1,50 +1,48 @@ package com.ruoyi.common.utils.security; -import java.nio.charset.StandardCharsets; -import java.security.MessageDigest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.MappedByteBuffer; +import java.nio.channels.FileChannel; +import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + /** * Md5加密方法 - * + * * @author ruoyi */ -public class Md5Utils -{ +public class Md5Utils { private static final Logger log = LoggerFactory.getLogger(Md5Utils.class); - private static byte[] md5(String s) - { + private static byte[] md5(String s) { MessageDigest algorithm; - try - { + try { algorithm = MessageDigest.getInstance("MD5"); algorithm.reset(); algorithm.update(s.getBytes("UTF-8")); byte[] messageDigest = algorithm.digest(); return messageDigest; - } - catch (Exception e) - { + } catch (Exception e) { log.error("MD5 Error...", e); } return null; } - private static final String toHex(byte hash[]) - { - if (hash == null) - { + private static final String toHex(byte hash[]) { + if (hash == null) { return null; } StringBuffer buf = new StringBuffer(hash.length * 2); int i; - for (i = 0; i < hash.length; i++) - { - if ((hash[i] & 0xff) < 0x10) - { + for (i = 0; i < hash.length; i++) { + if ((hash[i] & 0xff) < 0x10) { buf.append("0"); } buf.append(Long.toString(hash[i] & 0xff, 16)); @@ -52,16 +50,45 @@ public class Md5Utils return buf.toString(); } - public static String hash(String s) - { - try - { + public static String hash(String s) { + try { return new String(toHex(md5(s)).getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8); - } - catch (Exception e) - { + } catch (Exception e) { log.error("not supported charset...{}", e); return s; } } + public static String getFileMD5(File file) { + if (!file.exists()) { + return ""; + } + FileInputStream in = null; + try { + in = new FileInputStream(file); + FileChannel channel = in.getChannel(); + MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, file.length()); + MessageDigest md = MessageDigest.getInstance("MD5"); + md.update(buffer); + return bytes2Hex(md.digest()); + } catch (NoSuchAlgorithmException | IOException e) { + e.printStackTrace(); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException ignored) { + } + } + } + return ""; + } + private static String bytes2Hex(byte[] src) { + char[] res = new char[src.length << 1]; + final char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; + for (int i = 0, j = 0; i < src.length; i++) { + res[j++] = hexDigits[src[i] >>> 4 & 0x0f]; + res[j++] = hexDigits[src[i] & 0x0f]; + } + return new String(res); + } } diff --git a/ruoyi-device/src/main/java/com/ruoyi/device/mapper/BaseInfoMapper.java b/ruoyi-device/src/main/java/com/ruoyi/device/mapper/BaseInfoMapper.java index 2109986..67b60cc 100644 --- a/ruoyi-device/src/main/java/com/ruoyi/device/mapper/BaseInfoMapper.java +++ b/ruoyi-device/src/main/java/com/ruoyi/device/mapper/BaseInfoMapper.java @@ -64,4 +64,6 @@ public interface BaseInfoMapper public int deleteBaseInfoByObjIds(String[] objIds); BaseInfo checkDeviceCode(BaseInfo baseInfo); + + BaseInfo selectDeviceInfo(String deviceCode); } diff --git a/ruoyi-device/src/main/java/com/ruoyi/device/service/IBaseInfoService.java b/ruoyi-device/src/main/java/com/ruoyi/device/service/IBaseInfoService.java index 1961a22..ebe0777 100644 --- a/ruoyi-device/src/main/java/com/ruoyi/device/service/IBaseInfoService.java +++ b/ruoyi-device/src/main/java/com/ruoyi/device/service/IBaseInfoService.java @@ -60,4 +60,6 @@ public interface IBaseInfoService public int deleteBaseInfoByObjId(Long objId); boolean checkDeviceCode(BaseInfo baseInfo); + + BaseInfo selectDeviceInfo(String code); } diff --git a/ruoyi-device/src/main/java/com/ruoyi/device/service/impl/BaseInfoServiceImpl.java b/ruoyi-device/src/main/java/com/ruoyi/device/service/impl/BaseInfoServiceImpl.java index 859e285..2743266 100644 --- a/ruoyi-device/src/main/java/com/ruoyi/device/service/impl/BaseInfoServiceImpl.java +++ b/ruoyi-device/src/main/java/com/ruoyi/device/service/impl/BaseInfoServiceImpl.java @@ -110,4 +110,9 @@ public class BaseInfoServiceImpl implements IBaseInfoService } return false; } + + @Override + public BaseInfo selectDeviceInfo(String code) { + return baseInfoMapper.selectDeviceInfo(code); + } } diff --git a/ruoyi-device/src/main/resources/mapper/device/BaseInfoMapper.xml b/ruoyi-device/src/main/resources/mapper/device/BaseInfoMapper.xml index dd3ca45..3425c0e 100644 --- a/ruoyi-device/src/main/resources/mapper/device/BaseInfoMapper.xml +++ b/ruoyi-device/src/main/resources/mapper/device/BaseInfoMapper.xml @@ -119,9 +119,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{objId} + - + \ No newline at end of file diff --git a/ruoyi-device/src/base_infoMenu.sql b/ruoyi-device/src/main/resources/sql/base_infoMenu.sql similarity index 100% rename from ruoyi-device/src/base_infoMenu.sql rename to ruoyi-device/src/main/resources/sql/base_infoMenu.sql diff --git a/ruoyi-device/base_typeMenu.sql b/ruoyi-device/src/main/resources/sql/base_typeMenu.sql similarity index 100% rename from ruoyi-device/base_typeMenu.sql rename to ruoyi-device/src/main/resources/sql/base_typeMenu.sql diff --git a/ruoyi-device/src/record_useMenu.sql b/ruoyi-device/src/main/resources/sql/record_useMenu.sql similarity index 100% rename from ruoyi-device/src/record_useMenu.sql rename to ruoyi-device/src/main/resources/sql/record_useMenu.sql diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java index 417fdbf..7e6f3e2 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ShiroConfig.java @@ -311,6 +311,7 @@ public class ShiroConfig filterChainDefinitionMap.put("/fonts/**", "anon"); filterChainDefinitionMap.put("/img/**", "anon"); filterChainDefinitionMap.put("/ajax/**", "anon"); + filterChainDefinitionMap.put("/api/**", "anon"); filterChainDefinitionMap.put("/js/**", "anon"); filterChainDefinitionMap.put("/ruoyi/**", "anon"); filterChainDefinitionMap.put("/captcha/captchaImage**", "anon"); diff --git a/ruoyi-pda/pom.xml b/ruoyi-pda/pom.xml new file mode 100644 index 0000000..f4977fd --- /dev/null +++ b/ruoyi-pda/pom.xml @@ -0,0 +1,29 @@ + + + + ruoyi + com.ruoyi + 4.8.0 + + 4.0.0 + + ruoyi-pda + + + + + + + com.ruoyi + ruoyi-framework + + + com.ruoyi + ruoyi-device + 4.8.0 + + + + \ No newline at end of file diff --git a/ruoyi-pda/src/main/java/com/ruoyi/pda/controller/LoginController.java b/ruoyi-pda/src/main/java/com/ruoyi/pda/controller/LoginController.java new file mode 100644 index 0000000..78615e9 --- /dev/null +++ b/ruoyi-pda/src/main/java/com/ruoyi/pda/controller/LoginController.java @@ -0,0 +1,55 @@ +package com.ruoyi.pda.controller; + + + +import com.alibaba.fastjson.JSONObject; + +import com.ruoyi.pda.domain.APKVersion; +import com.ruoyi.pda.service.LoginService; +import org.apache.ibatis.annotations.Param; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by wangh on 2020/7/17-15:18。 + */ +@RestController +@RequestMapping("/api") +public class LoginController { + @Autowired + LoginService service; + + + + @GetMapping("/login/finduser") + public String finduser(String name,String pass){ + System.out.println("登录名称= "+name+" pass= "+pass); + return service.login(name,pass); + } + + @GetMapping("/getVersion") + public String getVersion(){ + APKVersion apkVersion=service.getVersion(); + apkVersion.setCode(0); + apkVersion.setMsg(""); + if (apkVersion==null){ + apkVersion=new APKVersion(); + apkVersion.setUpdateStatus(0); + + + }else { + apkVersion.setUpdateStatus(1); + } + + + String s = JSONObject.toJSONString(apkVersion); + System.out.println("请求版本信息"+s); + return s; + } + + + +} diff --git a/ruoyi-pda/src/main/java/com/ruoyi/pda/controller/PdaApiController.java b/ruoyi-pda/src/main/java/com/ruoyi/pda/controller/PdaApiController.java new file mode 100644 index 0000000..766a917 --- /dev/null +++ b/ruoyi-pda/src/main/java/com/ruoyi/pda/controller/PdaApiController.java @@ -0,0 +1,58 @@ +package com.ruoyi.pda.controller; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.device.domain.BaseInfo; +import com.ruoyi.device.service.IBaseInfoService; +import com.ruoyi.pda.service.IPdaApiService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.URL; + +import static com.ruoyi.common.core.domain.AjaxResult.error; +import static com.ruoyi.common.core.domain.AjaxResult.success; + +@RestController +@RequestMapping("/api") +public class PdaApiController { + @Autowired + private IPdaApiService service; + @Autowired + private IBaseInfoService baseInfoService; + + @PostMapping("/home/selectDeviceInfo") + public AjaxResult selectDeviceInfo(String code) { + BaseInfo baseInfo = baseInfoService.selectDeviceInfo(code); + if (baseInfo == null) return error("查询失败,条码扫描错误"); + String deviceState = baseInfo.getDeviceState(); + String deviceName = baseInfo.getDeviceName(); + if (deviceState.equals("0")) return error(deviceName + "已停用,使用其他设备吧"); + if (deviceState.equals("2")) return error(deviceName + "正在维修,使用其他设备吧"); + if (baseInfo.getUseState().equals("1")) return error(deviceName + "在使用中,更换其他设备吧"); + return success(baseInfo); + } + + + public AjaxResult open() throws IOException { + URL url = new URL("https://api.example.com/data"); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("GET"); + + int responseCode = conn.getResponseCode(); + if (responseCode == 200) { + // BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream())); + // String inputLine; + // StringBuilder response = new StringBuilder(); + // while ((inputLine = in.readLine()) != null) { + // response.append(inputLine); + // } + // in.close(); + // System.out.println(response); + } + return success(conn.getInputStream()); + } +} diff --git a/ruoyi-pda/src/main/java/com/ruoyi/pda/controller/PdaApkVersionController.java b/ruoyi-pda/src/main/java/com/ruoyi/pda/controller/PdaApkVersionController.java new file mode 100644 index 0000000..5ef6dd5 --- /dev/null +++ b/ruoyi-pda/src/main/java/com/ruoyi/pda/controller/PdaApkVersionController.java @@ -0,0 +1,157 @@ +package com.ruoyi.pda.controller; + +import java.io.File; +import java.io.IOException; +import java.util.List; + +import com.ruoyi.common.config.RuoYiConfig; +import com.ruoyi.common.utils.IpUtils; +import com.ruoyi.common.utils.file.FileUploadUtils; +import com.ruoyi.common.utils.security.Md5Utils; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.pda.domain.PdaApkVersion; +import com.ruoyi.pda.service.IPdaApkVersionService; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; +import org.springframework.web.multipart.MultipartFile; + +/** + * 手持版本升级Controller + * + * @author ruoyi + * @date 2023-04-06 + */ +@Controller +@RequestMapping("/pda/pda_version") +public class PdaApkVersionController extends BaseController +{ + private String prefix = "pda/pda_version"; + + @Autowired + private IPdaApkVersionService pdaApkVersionService; + + @RequiresPermissions("pda:pda_version:view") + @GetMapping() + public String pda_version() + { + return prefix + "/pda_version"; + } + + /** + * 查询手持版本升级列表 + */ + @RequiresPermissions("pda:pda_version:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(PdaApkVersion pdaApkVersion) + { + startPage(); + List list = pdaApkVersionService.selectPdaApkVersionList(pdaApkVersion); + return getDataTable(list); + } + + /** + * 导出手持版本升级列表 + */ + @RequiresPermissions("pda:pda_version:export") + @Log(title = "手持版本升级", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(PdaApkVersion pdaApkVersion) + { + List list = pdaApkVersionService.selectPdaApkVersionList(pdaApkVersion); + ExcelUtil util = new ExcelUtil(PdaApkVersion.class); + return util.exportExcel(list, "手持版本升级数据"); + } + + /** + * 新增手持版本升级 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存手持版本升级 + */ + @RequiresPermissions("pda:pda_version:add") + @Log(title = "手持版本升级", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(MultipartFile file, PdaApkVersion pdaApkVersion) + { + + // 上传文件路径 + String filePath = RuoYiConfig.getUploadPath()+"/apk"; + // 上传并返回新文件名称 + try { + String fileName = FileUploadUtils.upload(filePath, file); +// System.out.println("上传路径"+filePath+fileName); +// D:/ruoyi/uploadPath/upload/profile/upload/2023/04/06/app-debug_20230406170208A001.apk + String pathname = filePath + fileName; + System.out.println("地址1"+pathname); + pathname= pathname.replace("/profile/upload/apk",""); + System.out.println("地址2:"+pathname); + File file1=new File(pathname); + System.out.println("文件获取:"+file1.exists()); + System.out.println(file1.length()/1024); + pdaApkVersion.setApkSize(file1.length()/1024); + pdaApkVersion.setApkMd5(Md5Utils.getFileMD5(file1)); + pdaApkVersion.setDownloadUrl("http://10.32.128.150:90"+fileName); + } catch (IOException e) { + e.printStackTrace(); + } + return toAjax(pdaApkVersionService.insertPdaApkVersion(pdaApkVersion)); + + } + + /** + * 修改手持版本升级 + */ + @RequiresPermissions("pda:pda_version:edit") + @GetMapping("/edit/{objid}") + public String edit(@PathVariable("objid") Long objid, ModelMap mmap) + { + PdaApkVersion pdaApkVersion = pdaApkVersionService.selectPdaApkVersionByObjid(objid); + mmap.put("pdaApkVersion", pdaApkVersion); + return prefix + "/edit"; + } + + /** + * 修改保存手持版本升级 + */ + @RequiresPermissions("pda:pda_version:edit") + @Log(title = "手持版本升级", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(PdaApkVersion pdaApkVersion) + { + return toAjax(pdaApkVersionService.updatePdaApkVersion(pdaApkVersion)); + } + + /** + * 删除手持版本升级 + */ + @RequiresPermissions("pda:pda_version:remove") + @Log(title = "手持版本升级", businessType = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(pdaApkVersionService.deletePdaApkVersionByObjids(ids)); + } +} diff --git a/ruoyi-pda/src/main/java/com/ruoyi/pda/domain/APKVersion.java b/ruoyi-pda/src/main/java/com/ruoyi/pda/domain/APKVersion.java new file mode 100644 index 0000000..a1aebb2 --- /dev/null +++ b/ruoyi-pda/src/main/java/com/ruoyi/pda/domain/APKVersion.java @@ -0,0 +1,121 @@ +package com.ruoyi.pda.domain; + +import com.alibaba.fastjson.annotation.JSONField; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 手持版本升级对象 pda_apk_version + * + * @author ruoyi + * @date 2023-04-06 + */ +public class APKVersion { + @JSONField(name = "Code") + private int Code; + @JSONField(name = "Msg") + private String Msg; + @JSONField(name = "UpdateStatus") + private int UpdateStatus; + @JSONField(name = "VersionCode") + private Long VersionCode; + @JSONField(name = "VersionName") + private String VersionName; + @JSONField(name = "ModifyContent") + private String ModifyContent; + @JSONField(name = "DownloadUrl") + private String DownloadUrl; + @JSONField(name = "ApkSize") + private int ApkSize; + @JSONField(name = "ApkMd5") + private String ApkMd5; + + public int getCode() { + return Code; + } + + public void setCode(int code) { + Code = code; + } + + public String getMsg() { + return Msg; + } + + public void setMsg(String msg) { + Msg = msg; + } + + public int getUpdateStatus() { + return UpdateStatus; + } + + public void setUpdateStatus(int updateStatus) { + UpdateStatus = updateStatus; + } + + public Long getVersionCode() { + return VersionCode; + } + + public void setVersionCode(Long versionCode) { + VersionCode = versionCode; + } + + public String getVersionName() { + return VersionName; + } + + public void setVersionName(String versionName) { + VersionName = versionName; + } + + public String getModifyContent() { + return ModifyContent; + } + + public void setModifyContent(String modifyContent) { + ModifyContent = modifyContent; + } + + public String getDownloadUrl() { + return DownloadUrl; + } + + public void setDownloadUrl(String downloadUrl) { + DownloadUrl = downloadUrl; + } + + public int getApkSize() { + return ApkSize; + } + + public void setApkSize(int apkSize) { + ApkSize = apkSize; + } + + public String getApkMd5() { + return ApkMd5; + } + + public void setApkMd5(String apkMd5) { + ApkMd5 = apkMd5; + } + + @Override + public String toString() { + return "APKVersion{" + + "Code=" + Code + + ", Msg='" + Msg + '\'' + + ", UpdateStatus=" + UpdateStatus + + ", VersionCode=" + VersionCode + + ", VersionName='" + VersionName + '\'' + + ", ModifyContent='" + ModifyContent + '\'' + + ", DownloadUrl='" + DownloadUrl + '\'' + + ", ApkSize=" + ApkSize + + ", ApkMd5='" + ApkMd5 + '\'' + + '}'; + } +} diff --git a/ruoyi-pda/src/main/java/com/ruoyi/pda/domain/ApiUser.java b/ruoyi-pda/src/main/java/com/ruoyi/pda/domain/ApiUser.java new file mode 100644 index 0000000..549eac1 --- /dev/null +++ b/ruoyi-pda/src/main/java/com/ruoyi/pda/domain/ApiUser.java @@ -0,0 +1,45 @@ +package com.ruoyi.pda.domain; + +/** + * @author wanghao + * @date 2023/8/23 10:25 + */ +public class ApiUser { + private int id; + private String name; + private int status; + private String role_name; + + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getRole_name() { + return role_name; + } + + public void setRole_name(String role_name) { + this.role_name = role_name; + } +} diff --git a/ruoyi-pda/src/main/java/com/ruoyi/pda/domain/PdaApkVersion.java b/ruoyi-pda/src/main/java/com/ruoyi/pda/domain/PdaApkVersion.java new file mode 100644 index 0000000..d2e25e5 --- /dev/null +++ b/ruoyi-pda/src/main/java/com/ruoyi/pda/domain/PdaApkVersion.java @@ -0,0 +1,122 @@ +package com.ruoyi.pda.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 手持版本升级对象 pda_apk_version + * + * @author ruoyi + * @date 2023-04-06 + */ +public class PdaApkVersion extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键标识 */ + private Long objid; + + /** 版本号 */ + @Excel(name = "版本号") + private Long versionCode; + + /** 版本名 */ + @Excel(name = "版本名") + private String versionName; + + /** 信息 */ + @Excel(name = "信息") + private String modifyContent; + + /** 位置 */ + @Excel(name = "位置") + private String downloadUrl; + + /** 文件大小 */ + @Excel(name = "文件大小") + private Long apkSize; + + /** 文件标识 */ + @Excel(name = "文件标识") + private String apkMd5; + + public void setObjid(Long objid) + { + this.objid = objid; + } + + public Long getObjid() + { + return objid; + } + public void setVersionCode(Long versionCode) + { + this.versionCode = versionCode; + } + + public Long getVersionCode() + { + return versionCode; + } + public void setVersionName(String versionName) + { + this.versionName = versionName; + } + + public String getVersionName() + { + return versionName; + } + public void setModifyContent(String modifyContent) + { + this.modifyContent = modifyContent; + } + + public String getModifyContent() + { + return modifyContent; + } + public void setDownloadUrl(String downloadUrl) + { + this.downloadUrl = downloadUrl; + } + + public String getDownloadUrl() + { + return downloadUrl; + } + public void setApkSize(Long apkSize) + { + this.apkSize = apkSize; + } + + public Long getApkSize() + { + return apkSize; + } + public void setApkMd5(String apkMd5) + { + this.apkMd5 = apkMd5; + } + + public String getApkMd5() + { + return apkMd5; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("objid", getObjid()) + .append("versionCode", getVersionCode()) + .append("versionName", getVersionName()) + .append("modifyContent", getModifyContent()) + .append("downloadUrl", getDownloadUrl()) + .append("apkSize", getApkSize()) + .append("apkMd5", getApkMd5()) + .append("createTime", getCreateTime()) + .toString(); + } +} diff --git a/ruoyi-pda/src/main/java/com/ruoyi/pda/mapper/LoginMapper.java b/ruoyi-pda/src/main/java/com/ruoyi/pda/mapper/LoginMapper.java new file mode 100644 index 0000000..8289928 --- /dev/null +++ b/ruoyi-pda/src/main/java/com/ruoyi/pda/mapper/LoginMapper.java @@ -0,0 +1,26 @@ +package com.ruoyi.pda.mapper; + +import com.ruoyi.pda.domain.APKVersion; +import com.ruoyi.pda.domain.ApiUser; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * Created by wangh on 2021/4/26-9:32。 + */ +@Repository +public interface LoginMapper { + String login_findSalt(String name); + + int login_getUser(@Param("name") String name, @Param("passw") String passw); + + List selectMenuNameByUserID(Integer userID); + + APKVersion getVersion(); + + List selectMenuName(); + + ApiUser apiLogin(@Param("name")String name,@Param("pass") String md5Str); +} diff --git a/ruoyi-pda/src/main/java/com/ruoyi/pda/mapper/PdaApiMapper.java b/ruoyi-pda/src/main/java/com/ruoyi/pda/mapper/PdaApiMapper.java new file mode 100644 index 0000000..e248b36 --- /dev/null +++ b/ruoyi-pda/src/main/java/com/ruoyi/pda/mapper/PdaApiMapper.java @@ -0,0 +1,8 @@ +package com.ruoyi.pda.mapper; + +import org.springframework.stereotype.Repository; +import org.springframework.web.bind.annotation.ResponseBody; + +@Repository +public interface PdaApiMapper { +} diff --git a/ruoyi-pda/src/main/java/com/ruoyi/pda/mapper/PdaApkVersionMapper.java b/ruoyi-pda/src/main/java/com/ruoyi/pda/mapper/PdaApkVersionMapper.java new file mode 100644 index 0000000..2cd5c2f --- /dev/null +++ b/ruoyi-pda/src/main/java/com/ruoyi/pda/mapper/PdaApkVersionMapper.java @@ -0,0 +1,61 @@ +package com.ruoyi.pda.mapper; + +import java.util.List; +import com.ruoyi.pda.domain.PdaApkVersion; + +/** + * 手持版本升级Mapper接口 + * + * @author ruoyi + * @date 2023-04-06 + */ +public interface PdaApkVersionMapper +{ + /** + * 查询手持版本升级 + * + * @param objid 手持版本升级主键 + * @return 手持版本升级 + */ + public PdaApkVersion selectPdaApkVersionByObjid(Long objid); + + /** + * 查询手持版本升级列表 + * + * @param pdaApkVersion 手持版本升级 + * @return 手持版本升级集合 + */ + public List selectPdaApkVersionList(PdaApkVersion pdaApkVersion); + + /** + * 新增手持版本升级 + * + * @param pdaApkVersion 手持版本升级 + * @return 结果 + */ + public int insertPdaApkVersion(PdaApkVersion pdaApkVersion); + + /** + * 修改手持版本升级 + * + * @param pdaApkVersion 手持版本升级 + * @return 结果 + */ + public int updatePdaApkVersion(PdaApkVersion pdaApkVersion); + + /** + * 删除手持版本升级 + * + * @param objid 手持版本升级主键 + * @return 结果 + */ + public int deletePdaApkVersionByObjid(Long objid); + + /** + * 批量删除手持版本升级 + * + * @param objids 需要删除的数据主键集合 + * @return 结果 + */ + public int deletePdaApkVersionByObjids(String[] objids); +} diff --git a/ruoyi-pda/src/main/java/com/ruoyi/pda/service/IPdaApiService.java b/ruoyi-pda/src/main/java/com/ruoyi/pda/service/IPdaApiService.java new file mode 100644 index 0000000..5cb3649 --- /dev/null +++ b/ruoyi-pda/src/main/java/com/ruoyi/pda/service/IPdaApiService.java @@ -0,0 +1,4 @@ +package com.ruoyi.pda.service; + +public interface IPdaApiService { +} diff --git a/ruoyi-pda/src/main/java/com/ruoyi/pda/service/IPdaApkVersionService.java b/ruoyi-pda/src/main/java/com/ruoyi/pda/service/IPdaApkVersionService.java new file mode 100644 index 0000000..332ad00 --- /dev/null +++ b/ruoyi-pda/src/main/java/com/ruoyi/pda/service/IPdaApkVersionService.java @@ -0,0 +1,61 @@ +package com.ruoyi.pda.service; + +import java.util.List; +import com.ruoyi.pda.domain.PdaApkVersion; + +/** + * 手持版本升级Service接口 + * + * @author ruoyi + * @date 2023-04-06 + */ +public interface IPdaApkVersionService +{ + /** + * 查询手持版本升级 + * + * @param objid 手持版本升级主键 + * @return 手持版本升级 + */ + public PdaApkVersion selectPdaApkVersionByObjid(Long objid); + + /** + * 查询手持版本升级列表 + * + * @param pdaApkVersion 手持版本升级 + * @return 手持版本升级集合 + */ + public List selectPdaApkVersionList(PdaApkVersion pdaApkVersion); + + /** + * 新增手持版本升级 + * + * @param pdaApkVersion 手持版本升级 + * @return 结果 + */ + public int insertPdaApkVersion(PdaApkVersion pdaApkVersion); + + /** + * 修改手持版本升级 + * + * @param pdaApkVersion 手持版本升级 + * @return 结果 + */ + public int updatePdaApkVersion(PdaApkVersion pdaApkVersion); + + /** + * 批量删除手持版本升级 + * + * @param objids 需要删除的手持版本升级主键集合 + * @return 结果 + */ + public int deletePdaApkVersionByObjids(String objids); + + /** + * 删除手持版本升级信息 + * + * @param objid 手持版本升级主键 + * @return 结果 + */ + public int deletePdaApkVersionByObjid(Long objid); +} diff --git a/ruoyi-pda/src/main/java/com/ruoyi/pda/service/LoginService.java b/ruoyi-pda/src/main/java/com/ruoyi/pda/service/LoginService.java new file mode 100644 index 0000000..00b7f53 --- /dev/null +++ b/ruoyi-pda/src/main/java/com/ruoyi/pda/service/LoginService.java @@ -0,0 +1,90 @@ +package com.ruoyi.pda.service; + + +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.pda.domain.APKVersion; +import com.ruoyi.pda.domain.ApiUser; +import com.ruoyi.pda.mapper.LoginMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.io.UnsupportedEncodingException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.List; + +/** + * Created by wangh on 2021/4/26-9:27。 + */ +@Service +public class LoginService { + + @Autowired + LoginMapper mapper; + + public String login(String name, String pass) { + try { + String salt = mapper.login_findSalt(name); + Integer userID = mapper.login_getUser(name, getMD5Str(name + pass + salt)); + if (userID != null) { + // List menuNameList=name.equals("admin")? + // mapper.selectMenuName(): + // mapper.selectMenuNameByUserID(userID); + // if (menuNameList==null||menuNameList.isEmpty()){ + // return "isEmpty"; + // } + // return JSONObject.toJSONString(menuNameList); + return "ok"; + } else { + return "Error"; + } + }catch (Exception e){ + return "Error"; + } + + } + + private static String getMD5Str(String str) { + MessageDigest messageDigest = null; + + try { + messageDigest = MessageDigest.getInstance("MD5"); + + messageDigest.reset(); + + messageDigest.update(str.getBytes("UTF-8")); + } catch (NoSuchAlgorithmException e) { + System.out.println("NoSuchAlgorithmException caught!"); + System.exit(-1); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + byte[] byteArray = messageDigest.digest(); + + StringBuffer md5StrBuff = new StringBuffer(); + + for (int i = 0; i < byteArray.length; i++) { + if (Integer.toHexString(0xFF & byteArray[i]).length() == 1) { + + + md5StrBuff.append("0").append(Integer.toHexString(0xFF & byteArray[i])); + } else { + + + md5StrBuff.append(Integer.toHexString(0xFF & byteArray[i])); + } + } + + return md5StrBuff.toString(); + } + + public APKVersion getVersion() { + return mapper.getVersion(); + } + + public ApiUser apiLogin(String name, String pass) { + String salt = mapper.login_findSalt(name); + return mapper.apiLogin(name, getMD5Str(name + pass + salt)); + } +} diff --git a/ruoyi-pda/src/main/java/com/ruoyi/pda/service/impl/PdaApkVersionServiceImpl.java b/ruoyi-pda/src/main/java/com/ruoyi/pda/service/impl/PdaApkVersionServiceImpl.java new file mode 100644 index 0000000..c4a8065 --- /dev/null +++ b/ruoyi-pda/src/main/java/com/ruoyi/pda/service/impl/PdaApkVersionServiceImpl.java @@ -0,0 +1,96 @@ +package com.ruoyi.pda.service.impl; + +import java.util.List; +import com.ruoyi.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.pda.mapper.PdaApkVersionMapper; +import com.ruoyi.pda.domain.PdaApkVersion; +import com.ruoyi.pda.service.IPdaApkVersionService; +import com.ruoyi.common.core.text.Convert; + +/** + * 手持版本升级Service业务层处理 + * + * @author ruoyi + * @date 2023-04-06 + */ +@Service +public class PdaApkVersionServiceImpl implements IPdaApkVersionService +{ + @Autowired + private PdaApkVersionMapper pdaApkVersionMapper; + + /** + * 查询手持版本升级 + * + * @param objid 手持版本升级主键 + * @return 手持版本升级 + */ + @Override + public PdaApkVersion selectPdaApkVersionByObjid(Long objid) + { + return pdaApkVersionMapper.selectPdaApkVersionByObjid(objid); + } + + /** + * 查询手持版本升级列表 + * + * @param pdaApkVersion 手持版本升级 + * @return 手持版本升级 + */ + @Override + public List selectPdaApkVersionList(PdaApkVersion pdaApkVersion) + { + return pdaApkVersionMapper.selectPdaApkVersionList(pdaApkVersion); + } + + /** + * 新增手持版本升级 + * + * @param pdaApkVersion 手持版本升级 + * @return 结果 + */ + @Override + public int insertPdaApkVersion(PdaApkVersion pdaApkVersion) + { + pdaApkVersion.setCreateTime(DateUtils.getNowDate()); + return pdaApkVersionMapper.insertPdaApkVersion(pdaApkVersion); + } + + /** + * 修改手持版本升级 + * + * @param pdaApkVersion 手持版本升级 + * @return 结果 + */ + @Override + public int updatePdaApkVersion(PdaApkVersion pdaApkVersion) + { + return pdaApkVersionMapper.updatePdaApkVersion(pdaApkVersion); + } + + /** + * 批量删除手持版本升级 + * + * @param objids 需要删除的手持版本升级主键 + * @return 结果 + */ + @Override + public int deletePdaApkVersionByObjids(String objids) + { + return pdaApkVersionMapper.deletePdaApkVersionByObjids(Convert.toStrArray(objids)); + } + + /** + * 删除手持版本升级信息 + * + * @param objid 手持版本升级主键 + * @return 结果 + */ + @Override + public int deletePdaApkVersionByObjid(Long objid) + { + return pdaApkVersionMapper.deletePdaApkVersionByObjid(objid); + } +} diff --git a/ruoyi-pda/src/main/java/com/ruoyi/pda/service/impl/PdaServiceImpl.java b/ruoyi-pda/src/main/java/com/ruoyi/pda/service/impl/PdaServiceImpl.java new file mode 100644 index 0000000..e47327e --- /dev/null +++ b/ruoyi-pda/src/main/java/com/ruoyi/pda/service/impl/PdaServiceImpl.java @@ -0,0 +1,12 @@ +package com.ruoyi.pda.service.impl; + +import com.ruoyi.pda.mapper.PdaApiMapper; +import com.ruoyi.pda.service.IPdaApiService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class PdaServiceImpl implements IPdaApiService { + @Autowired + private PdaApiMapper mapper; +} diff --git a/ruoyi-pda/src/main/resources/mapper/LoginMapper.xml b/ruoyi-pda/src/main/resources/mapper/LoginMapper.xml new file mode 100644 index 0000000..6bc4daf --- /dev/null +++ b/ruoyi-pda/src/main/resources/mapper/LoginMapper.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ruoyi-pda/src/main/resources/mapper/PdaApiMapper.xml b/ruoyi-pda/src/main/resources/mapper/PdaApiMapper.xml new file mode 100644 index 0000000..8ec90d8 --- /dev/null +++ b/ruoyi-pda/src/main/resources/mapper/PdaApiMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/ruoyi-pda/src/main/resources/mapper/pda/PdaApkVersionMapper.xml b/ruoyi-pda/src/main/resources/mapper/pda/PdaApkVersionMapper.xml new file mode 100644 index 0000000..6e9e4c8 --- /dev/null +++ b/ruoyi-pda/src/main/resources/mapper/pda/PdaApkVersionMapper.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + select objid, version_code, version_name, modify_content, download_url, apk_size, apk_md5, create_time from pda_apk_version + + + + + + + + insert into pda_apk_version + + version_code, + version_name, + modify_content, + download_url, + apk_size, + apk_md5, + create_time, + + + #{versionCode}, + #{versionName}, + #{modifyContent}, + #{downloadUrl}, + #{apkSize}, + #{apkMd5}, + #{createTime}, + + + + + update pda_apk_version + + version_code = #{versionCode}, + version_name = #{versionName}, + modify_content = #{modifyContent}, + download_url = #{downloadUrl}, + apk_size = #{apkSize}, + apk_md5 = #{apkMd5}, + create_time = #{createTime}, + + where objid = #{objid} + + + + delete from pda_apk_version where objid = #{objid} + + + + delete from pda_apk_version where objid in + + #{objid} + + + + \ No newline at end of file diff --git a/ruoyi-pda/src/main/resources/mapper/sql/pda_versionMenu.sql b/ruoyi-pda/src/main/resources/mapper/sql/pda_versionMenu.sql new file mode 100644 index 0000000..0935581 --- /dev/null +++ b/ruoyi-pda/src/main/resources/mapper/sql/pda_versionMenu.sql @@ -0,0 +1,36 @@ +-- 菜单 SQL +insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) +values('手持版本升级', '3', '1', '/pda/pda_version', 'C', '0', 'pda:pda_version:view', '#', 'admin', sysdate(), '', null, '手持版本升级菜单'); + +-- 按钮父菜单ID +SELECT @parentId := LAST_INSERT_ID(); + +-- 按钮 SQL +insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) +values('手持版本升级查询', @parentId, '1', '#', 'F', '0', 'pda:pda_version:list', '#', 'admin', sysdate(), '', null, ''); + +insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) +values('手持版本升级新增', @parentId, '2', '#', 'F', '0', 'pda:pda_version:add', '#', 'admin', sysdate(), '', null, ''); + +insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) +values('手持版本升级修改', @parentId, '3', '#', 'F', '0', 'pda:pda_version:edit', '#', 'admin', sysdate(), '', null, ''); + +insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) +values('手持版本升级删除', @parentId, '4', '#', 'F', '0', 'pda:pda_version:remove', '#', 'admin', sysdate(), '', null, ''); + +insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark) +values('手持版本升级导出', @parentId, '5', '#', 'F', '0', 'pda:pda_version:export', '#', 'admin', sysdate(), '', null, ''); +-- auto-generated definition +create table pda_apk_version +( + objid int auto_increment comment '主键标识' + primary key, + version_code int null comment '版本号', + version_name varchar(20) null comment '版本名', + modify_content varchar(100) null comment '信息', + download_url varchar(200) null comment '位置', + apk_size int null comment '文件大小', + apk_md5 varchar(200) null comment '文件标识', + create_time datetime default CURRENT_TIMESTAMP null comment '创建时间' +) + comment '手持版本升级' charset = utf8mb3; diff --git a/ruoyi-pda/src/main/resources/templates/pda/pda_version/add.html b/ruoyi-pda/src/main/resources/templates/pda/pda_version/add.html new file mode 100644 index 0000000..41c00d3 --- /dev/null +++ b/ruoyi-pda/src/main/resources/templates/pda/pda_version/add.html @@ -0,0 +1,125 @@ + + + + + + + + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+ + + + + +
+
+
+
+ + + + + + \ No newline at end of file diff --git a/ruoyi-pda/src/main/resources/templates/pda/pda_version/edit.html b/ruoyi-pda/src/main/resources/templates/pda/pda_version/edit.html new file mode 100644 index 0000000..ea7536f --- /dev/null +++ b/ruoyi-pda/src/main/resources/templates/pda/pda_version/edit.html @@ -0,0 +1,114 @@ + + + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+ +
+ +
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/ruoyi-pda/src/main/resources/templates/pda/pda_version/pda_version.html b/ruoyi-pda/src/main/resources/templates/pda/pda_version/pda_version.html new file mode 100644 index 0000000..97d7537 --- /dev/null +++ b/ruoyi-pda/src/main/resources/templates/pda/pda_version/pda_version.html @@ -0,0 +1,112 @@ + + + + + + +
+
+
+
+
+ +
+
+
+ + +
+
+
+
+
+ + + + \ No newline at end of file