Browse Source

新增客户端和移动端版本号

wangliang 4 years ago
parent
commit
3eae501207

+ 50 - 0
themis-admin/src/main/java/com/qmth/themis/admin/api/TBAppVersionController.java

@@ -0,0 +1,50 @@
+package com.qmth.themis.admin.api;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmth.themis.business.constant.SystemConstant;
+import com.qmth.themis.business.entity.TBAppVersion;
+import com.qmth.themis.business.service.TBAppVersionService;
+import com.qmth.themis.common.util.Result;
+import com.qmth.themis.common.util.ResultUtil;
+import io.swagger.annotations.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.Collections;
+
+/**
+ * @Description: 移动端 前端控制器
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2020/11/20
+ */
+@Api(tags = "移动端Controller")
+@RestController
+@RequestMapping("/${prefix.url.admin}/app")
+public class TBAppVersionController {
+    private final static Logger log = LoggerFactory.getLogger(TBAppVersionController.class);
+
+    @Resource
+    TBAppVersionService tbAppVersionService;
+
+    @ApiOperation(value = "移动端版本新增/编辑接口")
+    @RequestMapping(value = "/save", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    public Result save(@ApiParam(value = "移动端版本信息", required = true) @RequestBody TBAppVersion tbAppVersion) {
+        tbAppVersionService.saveOrUpdate(tbAppVersion);
+        QueryWrapper<TBAppVersion> tbAppVersionQueryWrapper = new QueryWrapper<>();
+        return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
+    }
+
+    @ApiOperation(value = "移动端版本查询接口")
+    @RequestMapping(value = "/query", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "移动端信息", response = TBAppVersion.class)})
+    public Result query(@ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber,
+                        @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
+        return ResultUtil.ok(tbAppVersionService.appVersionQuery(new Page<>(pageNumber, pageSize)));
+    }
+}

+ 48 - 0
themis-admin/src/main/java/com/qmth/themis/admin/api/TBClientVersionController.java

@@ -0,0 +1,48 @@
+package com.qmth.themis.admin.api;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmth.themis.business.constant.SystemConstant;
+import com.qmth.themis.business.entity.TBClientVersion;
+import com.qmth.themis.business.service.TBClientVersionService;
+import com.qmth.themis.common.util.Result;
+import com.qmth.themis.common.util.ResultUtil;
+import io.swagger.annotations.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.Collections;
+
+/**
+ * @Description: 客户端 前端控制器
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2020/11/20
+ */
+@Api(tags = "客户端Controller")
+@RestController
+@RequestMapping("/${prefix.url.admin}/client")
+public class TBClientVersionController {
+    private final static Logger log = LoggerFactory.getLogger(TBClientVersionController.class);
+
+    @Resource
+    TBClientVersionService tbClientVersionService;
+
+    @ApiOperation(value = "客户端版本新增/编辑接口")
+    @RequestMapping(value = "/save", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    public Result save(@ApiParam(value = "客户端版本信息", required = true) @RequestBody TBClientVersion tbClientVersion) {
+        tbClientVersionService.saveOrUpdate(tbClientVersion);
+        return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
+    }
+
+    @ApiOperation(value = "客户端版本查询接口")
+    @RequestMapping(value = "/query", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "客户端信息", response = TBClientVersion.class)})
+    public Result query(@ApiParam(value = "分页页码", required = true) @RequestParam int pageNumber,
+                        @ApiParam(value = "分页数", required = true) @RequestParam int pageSize) {
+        return ResultUtil.ok(tbClientVersionService.clientVersionQuery(new Page<>(pageNumber, pageSize)));
+    }
+}

+ 36 - 0
themis-business/src/main/java/com/qmth/themis/business/dao/TBAppVersionMapper.java

@@ -0,0 +1,36 @@
+package com.qmth.themis.business.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.qmth.themis.business.entity.TBAppVersion;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Map;
+
+/**
+ * @Description: 移动端版本 Mapper 接口
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2020/11/20
+ */
+@Mapper
+public interface TBAppVersionMapper extends BaseMapper<TBAppVersion> {
+
+    /**
+     * 移动端版本查询
+     *
+     * @param iPage
+     * @return
+     */
+    IPage<TBAppVersion> appVersionQuery(IPage<Map> iPage);
+
+    /**
+     * 获取移动端最大版本号记录
+     *
+     * @param type
+     * @return
+     */
+    TBAppVersion getMaxAppVersion(@Param("type") String type);
+}

+ 17 - 0
themis-business/src/main/java/com/qmth/themis/business/dao/TBClientVersionMapper.java

@@ -1,9 +1,12 @@
 package com.qmth.themis.business.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.qmth.themis.business.entity.TBClientVersion;
 import org.apache.ibatis.annotations.Mapper;
 
+import java.util.Map;
+
 /**
  * @Description: 客户端版本 Mapper 接口
  * @Param:
@@ -14,4 +17,18 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface TBClientVersionMapper extends BaseMapper<TBClientVersion> {
 
+    /**
+     * 客户端版本查询
+     *
+     * @param iPage
+     * @return
+     */
+    IPage<TBClientVersion> clientVersionQuery(IPage<Map> iPage);
+
+    /**
+     * 获取客户端最大版本号记录
+     *
+     * @return
+     */
+    TBClientVersion getMaxClientVersion();
 }

+ 89 - 0
themis-business/src/main/java/com/qmth/themis/business/entity/TBAppVersion.java

@@ -0,0 +1,89 @@
+package com.qmth.themis.business.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.qmth.themis.business.base.BaseEntity;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Description: 移动端版本
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2020/11/20
+ */
+@ApiModel(value = "t_b_app_version", description = "移动端版本")
+public class TBAppVersion extends BaseEntity {
+
+    @ApiModelProperty(value = "版本名")
+    @TableField(value = "name")
+    private String name;
+
+    @ApiModelProperty(value = "版本号")
+    @TableField(value = "value")
+    private Integer value;
+
+    @ApiModelProperty(value = "版本详情链接")
+    @TableField(value = "url")
+    private String url;
+
+    @ApiModelProperty(value = "版本描述")
+    @TableField(value = "description")
+    private String description;
+
+    @ApiModelProperty(value = "类型:IOS/ANDROID")
+    @TableField(value = "type")
+    private String type;
+
+    @ApiModelProperty(value = "是否启用,0:停用,1:启用")
+    @TableField(value = "enable")
+    private Integer enable;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Integer getValue() {
+        return value;
+    }
+
+    public void setValue(Integer value) {
+        this.value = value;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public Integer getEnable() {
+        return enable;
+    }
+
+    public void setEnable(Integer enable) {
+        this.enable = enable;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+}

+ 33 - 0
themis-business/src/main/java/com/qmth/themis/business/service/TBAppVersionService.java

@@ -0,0 +1,33 @@
+package com.qmth.themis.business.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.themis.business.entity.TBAppVersion;
+
+import java.util.Map;
+
+/**
+ * @Description: 移动端版本 服务类
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2020/11/20
+ */
+public interface TBAppVersionService extends IService<TBAppVersion> {
+
+    /**
+     * 移动端版本查询
+     *
+     * @param iPage
+     * @return
+     */
+    IPage<TBAppVersion> appVersionQuery(IPage<Map> iPage);
+
+    /**
+     * 获取移动端最大版本号记录
+     *
+     * @param type
+     * @return
+     */
+    TBAppVersion getMaxAppVersion(String type);
+}

+ 17 - 0
themis-business/src/main/java/com/qmth/themis/business/service/TBClientVersionService.java

@@ -1,8 +1,11 @@
 package com.qmth.themis.business.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.themis.business.entity.TBClientVersion;
 
+import java.util.Map;
+
 /**
  * @Description: 客户端版本 服务类
  * @Param:
@@ -12,4 +15,18 @@ import com.qmth.themis.business.entity.TBClientVersion;
  */
 public interface TBClientVersionService extends IService<TBClientVersion> {
 
+    /**
+     * 客户端版本查询
+     *
+     * @param iPage
+     * @return
+     */
+    IPage<TBClientVersion> clientVersionQuery(IPage<Map> iPage);
+
+    /**
+     * 获取客户端最大版本号记录
+     *
+     * @return
+     */
+    TBClientVersion getMaxClientVersion();
 }

+ 47 - 0
themis-business/src/main/java/com/qmth/themis/business/service/impl/TBAppVersionServiceImpl.java

@@ -0,0 +1,47 @@
+package com.qmth.themis.business.service.impl;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.themis.business.dao.TBAppVersionMapper;
+import com.qmth.themis.business.entity.TBAppVersion;
+import com.qmth.themis.business.service.TBAppVersionService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Map;
+
+/**
+ * @Description: 移动端版本 服务实现类
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2020/11/20
+ */
+@Service
+public class TBAppVersionServiceImpl extends ServiceImpl<TBAppVersionMapper, TBAppVersion> implements TBAppVersionService {
+
+    @Resource
+    TBAppVersionMapper tbAppVersionMapper;
+
+    /**
+     * 移动端版本查询
+     *
+     * @param iPage
+     * @return
+     */
+    @Override
+    public IPage<TBAppVersion> appVersionQuery(IPage<Map> iPage) {
+        return tbAppVersionMapper.appVersionQuery(iPage);
+    }
+
+    /**
+     * 获取移动端最大版本号记录
+     *
+     * @param type
+     * @return
+     */
+    @Override
+    public TBAppVersion getMaxAppVersion(String type) {
+        return tbAppVersionMapper.getMaxAppVersion(type);
+    }
+}

+ 27 - 0
themis-business/src/main/java/com/qmth/themis/business/service/impl/TBClientVersionServiceImpl.java

@@ -1,11 +1,15 @@
 package com.qmth.themis.business.service.impl;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.themis.business.dao.TBClientVersionMapper;
 import com.qmth.themis.business.entity.TBClientVersion;
 import com.qmth.themis.business.service.TBClientVersionService;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import java.util.Map;
+
 /**
  * @Description: 客户端版本 服务实现类
  * @Param:
@@ -16,4 +20,27 @@ import org.springframework.stereotype.Service;
 @Service
 public class TBClientVersionServiceImpl extends ServiceImpl<TBClientVersionMapper, TBClientVersion> implements TBClientVersionService {
 
+    @Resource
+    TBClientVersionMapper tbClientVersionMapper;
+
+    /**
+     * 客户端版本查询
+     *
+     * @param iPage
+     * @return
+     */
+    @Override
+    public IPage<TBClientVersion> clientVersionQuery(IPage<Map> iPage) {
+        return tbClientVersionMapper.clientVersionQuery(iPage);
+    }
+
+    /**
+     * 获取客户端最大版本号
+     *
+     * @return
+     */
+    @Override
+    public TBClientVersion getMaxClientVersion() {
+        return tbClientVersionMapper.getMaxClientVersion();
+    }
 }

+ 34 - 0
themis-business/src/main/resources/mapper/TBAppVersionMapper.xml

@@ -0,0 +1,34 @@
+<?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.qmth.themis.business.dao.TBAppVersionMapper">
+
+    <select id="appVersionQuery" resultType="com.qmth.themis.business.entity.TBAppVersion">
+        select * from t_b_app_version t
+    </select>
+
+    <select id="getMaxAppVersion" resultType="com.qmth.themis.business.entity.TBAppVersion">
+        select
+        t.*
+        from
+        t_b_app_version t
+        <where>
+            EXISTS (
+            select
+            t1.id
+            from
+            (
+            select
+            max(tbav.id) as id
+            from
+            t_b_app_version tbav
+            <where>1 = 1
+                <if test="type != null and type != ''">
+                    and tbav.type = #{type}
+                </if>
+                and tbav.enable = 1
+            </where>
+            ) t1
+            where t1.id = t.id)
+        </where>
+    </select>
+</mapper>

+ 26 - 0
themis-business/src/main/resources/mapper/TBClientVersionMapper.xml

@@ -2,4 +2,30 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.qmth.themis.business.dao.TBClientVersionMapper">
 
+    <select id="clientVersionQuery" resultType="com.qmth.themis.business.entity.TBClientVersion">
+        select * from t_b_client_version t
+    </select>
+
+    <select id="getMaxClientVersion" resultType="com.qmth.themis.business.entity.TBClientVersion">
+        select
+        t.*
+        from
+        t_b_client_version t
+        <where>
+            EXISTS (
+            select
+            t1.id
+            from
+            (
+            select
+            max(tbcv.id) as id
+            from
+            t_b_client_version tbcv
+            <where>1 = 1
+                and tbcv.enable = 1
+            </where>
+            ) t1
+            where t1.id = t.id)
+        </where>
+    </select>
 </mapper>