Browse Source

安品APP版本控制

lazhaoqian 3 năm trước cách đây
mục cha
commit
bb6e9c74c6

+ 110 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/appVersion/TAppVersionController.java

@@ -0,0 +1,110 @@
+package com.ruoyi.web.controller.appVersion;
+
+import java.util.List;
+
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.appVersion.domain.TAppVersion;
+import com.ruoyi.appVersion.service.ITAppVersionService;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.page.TableDataInfo;
+
+/**
+ * APP版本信息Controller
+ *
+ * @author ruoyi
+ * @date 2021-06-16
+ */
+@RestController
+@RequestMapping("/appVersion/version")
+public class TAppVersionController extends BaseController {
+    @Autowired
+    private ITAppVersionService tAppVersionService;
+
+    /**
+     * 查询APP版本信息列表
+     */
+    @PreAuthorize("@ss.hasPermi('appVersion:version:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(TAppVersion tAppVersion) {
+        startPage();
+        List<TAppVersion> list = tAppVersionService.selectTAppVersionList(tAppVersion);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出APP版本信息列表
+     */
+    @PreAuthorize("@ss.hasPermi('appVersion:version:export')")
+    @Log(title = "APP版本信息", businessType = BusinessType.EXPORT)
+    @GetMapping("/export")
+    public AjaxResult export(TAppVersion tAppVersion) {
+        List<TAppVersion> list = tAppVersionService.selectTAppVersionList(tAppVersion);
+        ExcelUtil<TAppVersion> util = new ExcelUtil<TAppVersion>(TAppVersion.class);
+        return util.exportExcel(list, "version");
+    }
+
+    /**
+     * 获取APP版本信息详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('appVersion:version:query')")
+    @GetMapping(value = "/{fId}")
+    public AjaxResult getInfo(@PathVariable("fId") Long fId) {
+        return AjaxResult.success(tAppVersionService.selectTAppVersionById(fId));
+    }
+
+    /**
+     * 新增APP版本信息
+     */
+    @PreAuthorize("@ss.hasPermi('appVersion:version:add')")
+    @Log(title = "APP版本信息", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody TAppVersion tAppVersion) {
+        return toAjax(tAppVersionService.insertTAppVersion(tAppVersion));
+    }
+
+    /**
+     * 修改APP版本信息
+     */
+    @PreAuthorize("@ss.hasPermi('appVersion:version:edit')")
+    @Log(title = "APP版本信息", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody TAppVersion tAppVersion) {
+        return toAjax(tAppVersionService.updateTAppVersion(tAppVersion));
+    }
+
+    /**
+     * 删除APP版本信息
+     */
+    @PreAuthorize("@ss.hasPermi('appVersion:version:remove')")
+    @Log(title = "APP版本信息", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{fIds}")
+    public AjaxResult remove(@PathVariable Long[] fIds) {
+        return toAjax(tAppVersionService.deleteTAppVersionByIds(fIds));
+    }
+
+    /**
+     * 获取app版本信息
+     * @return
+     */
+    @Log(title = "获取APP版本信息", businessType = BusinessType.DELETE)
+    @GetMapping("getAppVersion")
+    public AjaxResult getAppVersion(Integer integer){
+        if (integer == null){
+            return AjaxResult.error("参数不能为空");
+        }
+        return tAppVersionService.getAppVersion(integer);
+    }
+}

+ 4 - 0
ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java

@@ -121,6 +121,10 @@ public class Constants
      * 字典管理 cache key
      */
     public static final String SYS_DICT_KEY = "sys_dict:";
+    /**
+     * app版本管理 cache key
+     */
+    public static final String SYS_VERSION_KEY = "sys_version:";
 
     /**
      * 资源映射路径 前缀

+ 69 - 0
ruoyi-common/src/main/java/com/ruoyi/common/utils/wechat/VersionUtil.java

@@ -0,0 +1,69 @@
+package com.ruoyi.common.utils.wechat;
+
+import com.ruoyi.common.constant.Constants;
+import com.ruoyi.common.core.redis.RedisCache;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.spring.SpringUtils;
+
+import java.util.Collection;
+
+/**
+ * @Author ZhaoQian La
+ * @Date 2021/6/16 9:40
+ * @Version 1.0
+ */
+
+/**
+ * 版本控制工具类
+ */
+public class VersionUtil {
+    /**
+     * 分隔符
+     */
+    public static final String SEPARATOR = ",";
+
+    /**
+     * 设置版本信息缓存
+     *
+     * @param key 参数键
+     * @param dictDatas 版本信息数据列表
+     */
+    public static void setDictCache(String key, String dictDatas)
+    {
+        SpringUtils.getBean(RedisCache.class).setCacheObject(getCacheKey(key), dictDatas);
+    }
+
+    /**
+     * 获取字版本信息缓存
+     *
+     * @param key 参数键
+     * @return dictDatas 版本信息数据列表
+     */
+    public static String getDictCache(String key)
+    {
+        String cacheObject = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
+        if (StringUtils.isNotEmpty(cacheObject)){
+            return cacheObject;
+        }
+        return null;
+    }
+    /**
+     * 清空版本缓存
+     */
+    public static void clearDictCache(String configKey)
+    {
+        Collection<String> keys = SpringUtils.getBean(RedisCache.class).keys(Constants.SYS_VERSION_KEY + configKey);
+        SpringUtils.getBean(RedisCache.class).deleteObject(keys);
+    }
+
+    /**
+     * 设置cache key
+     *
+     * @param configKey 参数键
+     * @return 缓存键key
+     */
+    public static String getCacheKey(String configKey)
+    {
+        return Constants.SYS_VERSION_KEY + configKey;
+    }
+}

+ 109 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/appVersion/domain/TAppVersion.java

@@ -0,0 +1,109 @@
+package com.ruoyi.appVersion.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;
+
+/**
+ * APP版本信息对象 t_app_version
+ * 
+ * @author ruoyi
+ * @date 2021-06-16
+ */
+public class TAppVersion extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 主键 */
+    private Long fId;
+
+    /** key */
+    @Excel(name = "key")
+    private String fParamkey;
+
+    /** value */
+    @Excel(name = "value")
+    private String fParamvalue;
+
+    /** 0 正常 1 停用 */
+    @Excel(name = "0 正常 1 停用")
+    private Integer fStatus;
+
+    /** 扩展 */
+    @Excel(name = "扩展")
+    private String fParamlabel;
+    //状态中文名
+    private String fStatusName;
+
+    public String getfStatusName() {
+        return fStatusName;
+    }
+
+    public void setfStatusName(String fStatusName) {
+        this.fStatusName = fStatusName;
+    }
+
+    public void setfId(Long fId)
+    {
+        this.fId = fId;
+    }
+
+    public Long getfId() 
+    {
+        return fId;
+    }
+    public void setfParamkey(String fParamkey) 
+    {
+        this.fParamkey = fParamkey;
+    }
+
+    public String getfParamkey() 
+    {
+        return fParamkey;
+    }
+    public void setfParamvalue(String fParamvalue) 
+    {
+        this.fParamvalue = fParamvalue;
+    }
+
+    public String getfParamvalue() 
+    {
+        return fParamvalue;
+    }
+    public void setfStatus(Integer fStatus) 
+    {
+        this.fStatus = fStatus;
+    }
+
+    public Integer getfStatus() 
+    {
+        return fStatus;
+    }
+    public void setfParamlabel(String fParamlabel) 
+    {
+        this.fParamlabel = fParamlabel;
+    }
+
+    public String getfParamlabel() 
+    {
+        return fParamlabel;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("fId", getfId())
+            .append("fParamkey", getfParamkey())
+            .append("fParamvalue", getfParamvalue())
+            .append("fStatus", getfStatus())
+            .append("fParamlabel", getfParamlabel())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .append("remark", getRemark())
+            .append("fStatusName", getfStatusName())
+            .toString();
+    }
+}

+ 68 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/appVersion/mapper/TAppVersionMapper.java

@@ -0,0 +1,68 @@
+package com.ruoyi.appVersion.mapper;
+
+import java.util.List;
+import com.ruoyi.appVersion.domain.TAppVersion;
+
+/**
+ * APP版本信息Mapper接口
+ * 
+ * @author ruoyi
+ * @date 2021-06-16
+ */
+public interface TAppVersionMapper 
+{
+    /**
+     * 查询APP版本信息
+     * 
+     * @param fId APP版本信息ID
+     * @return APP版本信息
+     */
+    public TAppVersion selectTAppVersionById(Long fId);
+
+    /**
+     * 查询APP版本信息列表
+     * 
+     * @param tAppVersion APP版本信息
+     * @return APP版本信息集合
+     */
+    public List<TAppVersion> selectTAppVersionList(TAppVersion tAppVersion);
+
+    /**
+     * 新增APP版本信息
+     * 
+     * @param tAppVersion APP版本信息
+     * @return 结果
+     */
+    public int insertTAppVersion(TAppVersion tAppVersion);
+
+    /**
+     * 修改APP版本信息
+     * 
+     * @param tAppVersion APP版本信息
+     * @return 结果
+     */
+    public int updateTAppVersion(TAppVersion tAppVersion);
+
+    /**
+     * 删除APP版本信息
+     * 
+     * @param fId APP版本信息ID
+     * @return 结果
+     */
+    public int deleteTAppVersionById(Long fId);
+
+    /**
+     * 批量删除APP版本信息
+     * 
+     * @param fIds 需要删除的数据ID
+     * @return 结果
+     */
+    public int deleteTAppVersionByIds(Long[] fIds);
+    /**
+     * 批量修改APP版本信息
+     *
+     * @param fIds 需要删除的数据ID
+     * @return 结果
+     */
+    public int updateTAppVersionFstatus(Long[] fIds);
+}

+ 64 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/appVersion/service/ITAppVersionService.java

@@ -0,0 +1,64 @@
+package com.ruoyi.appVersion.service;
+
+import java.util.List;
+import com.ruoyi.appVersion.domain.TAppVersion;
+import com.ruoyi.common.core.domain.AjaxResult;
+
+/**
+ * APP版本信息Service接口
+ * 
+ * @author ruoyi
+ * @date 2021-06-16
+ */
+public interface ITAppVersionService 
+{
+    /**
+     * 查询APP版本信息
+     * 
+     * @param fId APP版本信息ID
+     * @return APP版本信息
+     */
+    public TAppVersion selectTAppVersionById(Long fId);
+
+    /**
+     * 查询APP版本信息列表
+     * 
+     * @param tAppVersion APP版本信息
+     * @return APP版本信息集合
+     */
+    public List<TAppVersion> selectTAppVersionList(TAppVersion tAppVersion);
+
+    /**
+     * 新增APP版本信息
+     * 
+     * @param tAppVersion APP版本信息
+     * @return 结果
+     */
+    public int insertTAppVersion(TAppVersion tAppVersion);
+
+    /**
+     * 修改APP版本信息
+     * 
+     * @param tAppVersion APP版本信息
+     * @return 结果
+     */
+    public int updateTAppVersion(TAppVersion tAppVersion);
+
+    /**
+     * 批量删除APP版本信息
+     * 
+     * @param fIds 需要删除的APP版本信息ID
+     * @return 结果
+     */
+    public int deleteTAppVersionByIds(Long[] fIds);
+
+    /**
+     * 删除APP版本信息信息
+     * 
+     * @param fId APP版本信息ID
+     * @return 结果
+     */
+    public int deleteTAppVersionById(Long fId);
+
+    public AjaxResult getAppVersion(Integer integer);
+}

+ 144 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/appVersion/service/impl/TAppVersionServiceImpl.java

@@ -0,0 +1,144 @@
+package com.ruoyi.appVersion.service.impl;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.wechat.VersionUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.appVersion.mapper.TAppVersionMapper;
+import com.ruoyi.appVersion.domain.TAppVersion;
+import com.ruoyi.appVersion.service.ITAppVersionService;
+
+/**
+ * APP版本信息Service业务层处理
+ * 
+ * @author ruoyi
+ * @date 2021-06-16
+ */
+@Service
+public class TAppVersionServiceImpl implements ITAppVersionService 
+{
+    @Autowired
+    private TAppVersionMapper tAppVersionMapper;
+
+    /**
+     * 查询APP版本信息
+     * 
+     * @param fId APP版本信息ID
+     * @return APP版本信息
+     */
+    @Override
+    public TAppVersion selectTAppVersionById(Long fId)
+    {
+        return tAppVersionMapper.selectTAppVersionById(fId);
+    }
+
+    /**
+     * 查询APP版本信息列表
+     * 
+     * @param tAppVersion APP版本信息
+     * @return APP版本信息
+     */
+    @Override
+    public List<TAppVersion> selectTAppVersionList(TAppVersion tAppVersion)
+    {
+        return tAppVersionMapper.selectTAppVersionList(tAppVersion);
+    }
+
+    /**
+     * 新增APP版本信息
+     * 
+     * @param tAppVersion APP版本信息
+     * @return 结果
+     */
+    @Override
+    public int insertTAppVersion(TAppVersion tAppVersion)
+    {
+        tAppVersion.setCreateTime(DateUtils.getNowDate());
+        tAppVersion.setCreateBy(SecurityUtils.getUsername());
+        int i = tAppVersionMapper.insertTAppVersion(tAppVersion);
+        if (i > 0){
+            VersionUtil.setDictCache(tAppVersion.getfParamkey(),tAppVersion.getfParamvalue());
+        }
+        return i;
+    }
+
+    /**
+     * 修改APP版本信息
+     * 
+     * @param tAppVersion APP版本信息
+     * @return 结果
+     */
+    @Override
+    public int updateTAppVersion(TAppVersion tAppVersion)
+    {
+        tAppVersion.setUpdateTime(DateUtils.getNowDate());
+        tAppVersion.setUpdateBy(SecurityUtils.getUsername());
+        int i = tAppVersionMapper.updateTAppVersion(tAppVersion);
+        if (i > 0){
+            VersionUtil.clearDictCache(tAppVersion.getfParamkey());
+            VersionUtil.setDictCache(tAppVersion.getfParamkey(),tAppVersion.getfParamvalue());
+        }
+        return i;
+    }
+
+    /**
+     * 批量删除APP版本信息
+     * 
+     * @param fIds 需要删除的APP版本信息ID
+     * @return 结果
+     */
+    @Override
+    public int deleteTAppVersionByIds(Long[] fIds)
+    {
+        int i = tAppVersionMapper.updateTAppVersionFstatus(fIds);
+        if (i > 0){
+            for (Long fId : fIds) {
+                TAppVersion tAppVersion = tAppVersionMapper.selectTAppVersionById(fId);
+                VersionUtil.clearDictCache(tAppVersion.getfParamkey());
+            }
+        }
+        return i;
+    }
+
+    /**
+     * 删除APP版本信息信息
+     * 
+     * @param fId APP版本信息ID
+     * @return 结果
+     */
+    @Override
+    public int deleteTAppVersionById(Long fId)
+    {
+        TAppVersion tAppVersion = tAppVersionMapper.selectTAppVersionById(fId);
+        int i = tAppVersionMapper.deleteTAppVersionById(fId);
+        if (i > 0){
+            VersionUtil.clearDictCache(tAppVersion.getfParamkey());
+        }
+        return i;
+    }
+
+    @Override
+    public AjaxResult getAppVersion(Integer integer) {
+        Map<String,Object> map = new HashMap<>();
+        if (integer == 1){  //1 安卓
+            map.put("version",VersionUtil.getDictCache("android_version"));
+            map.put("url",VersionUtil.getDictCache("android_url"));
+            map.put("plus_msg",VersionUtil.getDictCache("android_plus_msg"));
+            map.put("minimum_Version",VersionUtil.getDictCache("android_minimum_Version"));
+            return AjaxResult.success("success",map);
+        }else if (integer == 2){ //2 ios
+            map.put("version",VersionUtil.getDictCache("ios_version"));
+            map.put("url",VersionUtil.getDictCache("ios_url"));
+            map.put("plus_msg",VersionUtil.getDictCache("ios_plus_msg"));
+            map.put("minimum_Version",VersionUtil.getDictCache("ios_minimum_Version"));
+            return AjaxResult.success("success",map);
+        }
+        return AjaxResult.success();
+    }
+}

+ 109 - 0
ruoyi-warehouse/src/main/resources/mapper/appVersion/TAppVersionMapper.xml

@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.appVersion.mapper.TAppVersionMapper">
+    
+    <resultMap type="TAppVersion" id="TAppVersionResult">
+        <result property="fId"    column="f_id"    />
+        <result property="fParamkey"    column="f_paramKey"    />
+        <result property="fParamvalue"    column="f_paramValue"    />
+        <result property="fStatus"    column="f_status"    />
+        <result property="fParamlabel"    column="f_paramLabel"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="remark"    column="remark"    />
+    </resultMap>
+
+    <sql id="selectTAppVersionVo">
+        select f_id, f_paramKey, f_paramValue, f_status,
+               CASE
+                   WHEN f_status = '0' THEN
+                       '正常'
+                   WHEN f_status = '1' THEN
+                       '停用'
+                   END AS fStatusName,
+               f_paramLabel, create_by, create_time, update_by, update_time, remark from t_app_version
+    </sql>
+
+    <select id="selectTAppVersionList" parameterType="TAppVersion" resultMap="TAppVersionResult">
+        <include refid="selectTAppVersionVo"/>
+        <where>  
+            <if test="fParamkey != null  and fParamkey != ''"> and f_paramKey = #{fParamkey}</if>
+            <if test="fParamvalue != null  and fParamvalue != ''"> and f_paramValue = #{fParamvalue}</if>
+            <if test="fStatus != null "> and f_status = #{fStatus}</if>
+            <if test="fParamlabel != null  and fParamlabel != ''"> and f_paramLabel = #{fParamlabel}</if>
+        </where>
+    </select>
+    
+    <select id="selectTAppVersionById" parameterType="Long" resultMap="TAppVersionResult">
+        <include refid="selectTAppVersionVo"/>
+        where f_id = #{fId}
+    </select>
+        
+    <insert id="insertTAppVersion" parameterType="TAppVersion">
+        insert into t_app_version
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="fId != null">f_id,</if>
+            <if test="fParamkey != null">f_paramKey,</if>
+            <if test="fParamvalue != null">f_paramValue,</if>
+            <if test="fStatus != null">f_status,</if>
+            <if test="fParamlabel != null">f_paramLabel,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="remark != null">remark,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="fId != null">#{fId},</if>
+            <if test="fParamkey != null">#{fParamkey},</if>
+            <if test="fParamvalue != null">#{fParamvalue},</if>
+            <if test="fStatus != null">#{fStatus},</if>
+            <if test="fParamlabel != null">#{fParamlabel},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="remark != null">#{remark},</if>
+         </trim>
+    </insert>
+
+    <update id="updateTAppVersion" parameterType="TAppVersion">
+        update t_app_version
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="fParamkey != null">f_paramKey = #{fParamkey},</if>
+            <if test="fParamvalue != null">f_paramValue = #{fParamvalue},</if>
+            <if test="fStatus != null">f_status = #{fStatus},</if>
+            <if test="fParamlabel != null">f_paramLabel = #{fParamlabel},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="remark != null">remark = #{remark},</if>
+        </trim>
+        where f_id = #{fId}
+    </update>
+
+    <delete id="deleteTAppVersionById" parameterType="Long">
+        delete from t_app_version where f_id = #{fId}
+    </delete>
+    <update id="updateTAppVersionFstatus" parameterType="TAppVersion">
+        update t_app_version
+        set f_status = 1
+        where f_id in
+        <foreach item="fId" collection="array" open="(" separator="," close=")">
+            #{fId}
+        </foreach>
+    </update>
+
+    <delete id="deleteTAppVersionByIds" parameterType="String">
+        delete from t_app_version where f_id in 
+        <foreach item="fId" collection="array" open="(" separator="," close=")">
+            #{fId}
+        </foreach>
+    </delete>
+    
+</mapper>