提交信息
This commit is contained in:
父節點
be6ea0f41c
當前提交
2546987df5
14
pom.xml
14
pom.xml
@ -41,13 +41,7 @@
|
|||||||
<artifactId>pagehelper</artifactId>
|
<artifactId>pagehelper</artifactId>
|
||||||
<version>5.2.0</version>
|
<version>5.2.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/com.google.android/android -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.android</groupId>
|
|
||||||
<artifactId>android</artifactId>
|
|
||||||
<version>4.1.1.4</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
|
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.code.gson</groupId>
|
<groupId>com.google.code.gson</groupId>
|
||||||
@ -74,6 +68,12 @@
|
|||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j</artifactId>
|
||||||
<version>1.2.12</version>
|
<version>1.2.12</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.vaadin.external.google</groupId>
|
||||||
|
<artifactId>android-json</artifactId>
|
||||||
|
<version>0.0.20131108.vaadin1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
package com.update.update;
|
package com.update.update;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@MapperScan("com.update.update.dao.freshMapper")
|
@MapperScan("com.update.update.dao.freshMapper")
|
||||||
|
|
||||||
@ -15,4 +20,5 @@ public class UpdateApplication {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.update.update.controller;
|
package com.update.update.controller;
|
||||||
|
|
||||||
|
|
||||||
import com.update.update.bean.fresh;
|
import com.update.update.entity.fresh;
|
||||||
import com.update.update.util.GJson;
|
import com.update.update.util.GJson;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@ -62,6 +62,7 @@ public class freshController {
|
|||||||
}
|
}
|
||||||
@RequestMapping(value = "/updating",method = RequestMethod.POST)
|
@RequestMapping(value = "/updating",method = RequestMethod.POST)
|
||||||
public void updating(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
public void updating(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
ServletUtil.createSuccessResponse(200, GJson.toJson(new refreshServiceImpl().new_version()),response);
|
String oldVersionId = request.getParameter("oldVersionId");
|
||||||
|
ServletUtil.createSuccessResponse(200, GJson.toJson(new refreshServiceImpl().new_version(oldVersionId)),response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
package com.update.update.dao;
|
package com.update.update.dao;
|
||||||
|
|
||||||
import com.update.update.bean.fresh;
|
import com.update.update.entity.fresh;
|
||||||
import org.apache.ibatis.annotations.*;
|
import org.apache.ibatis.annotations.*;
|
||||||
|
|
||||||
|
|
||||||
|
import org.apache.ibatis.jdbc.SQL;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Mapper
|
@Mapper
|
||||||
@ -14,16 +17,7 @@ public interface freshMapper {
|
|||||||
int add(fresh learnResouce);
|
int add(fresh learnResouce);
|
||||||
|
|
||||||
|
|
||||||
@DeleteProvider(type = fresh.class, method = "deleteByids")
|
|
||||||
int deleteByIds(@Param("ids") String[] ids);
|
|
||||||
|
|
||||||
|
|
||||||
@Select("SELECT * FROM fresh ORDER BY id DESC LIMIT 1")
|
@Select("SELECT * FROM fresh ORDER BY id DESC LIMIT 1")
|
||||||
@Results(value = {
|
|
||||||
@Result(column = "VersionId", property = "VersionId", javaType = String.class),
|
|
||||||
@Result(property = "apkUrl", column = "apkUrl", javaType = String.class),
|
|
||||||
@Result(property = "updateDescription", column = "updateDescription", javaType = String.class)
|
|
||||||
})
|
|
||||||
fresh query();
|
fresh query();
|
||||||
|
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.update.update.bean;
|
package com.update.update.entity;
|
||||||
|
|
||||||
public class fresh {
|
public class fresh {
|
||||||
public String VersionId;
|
public String VersionId;
|
@ -1,6 +1,6 @@
|
|||||||
package com.update.update.service;
|
package com.update.update.service;
|
||||||
|
|
||||||
import com.update.update.bean.fresh;
|
import com.update.update.entity.fresh;
|
||||||
|
|
||||||
public interface freshService {
|
public interface freshService {
|
||||||
int add(fresh version);
|
int add(fresh version);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.update.update.service.impl;
|
package com.update.update.service.impl;
|
||||||
|
|
||||||
|
|
||||||
import com.update.update.bean.fresh;
|
import com.update.update.entity.fresh;
|
||||||
import com.update.update.dao.freshMapper;
|
import com.update.update.dao.freshMapper;
|
||||||
import com.update.update.service.freshService;
|
import com.update.update.service.freshService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class freshServiceImpl implements freshService {
|
public class freshServiceImpl implements freshService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
freshMapper f;
|
freshMapper f;
|
||||||
@Override
|
@Override
|
||||||
public int add(fresh newOne) {
|
public int add(fresh newOne) {
|
||||||
|
@ -1,20 +1,17 @@
|
|||||||
package com.update.update.service.impl;
|
package com.update.update.service.impl;
|
||||||
|
|
||||||
|
|
||||||
import android.app.Application;
|
import com.update.update.entity.fresh;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import com.update.update.bean.fresh;
|
|
||||||
import com.update.update.service.refreshService;
|
import com.update.update.service.refreshService;
|
||||||
import com.update.update.util.APKVersionCodeUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class refreshServiceImpl implements refreshService {
|
public class refreshServiceImpl implements refreshService {
|
||||||
|
|
||||||
@Autowired
|
|
||||||
freshServiceImpl ser;
|
freshServiceImpl ser=new freshServiceImpl();
|
||||||
|
|
||||||
//version1大返回一个正数,小返回一个负数,相等返回0
|
//version1大返回一个正数,小返回一个负数,相等返回0
|
||||||
public static int compareVersion(String version1, String version2) throws Exception {
|
public static int compareVersion(String version1, String version2) throws Exception {
|
||||||
@ -36,12 +33,10 @@ public class refreshServiceImpl implements refreshService {
|
|||||||
return diff;
|
return diff;
|
||||||
}
|
}
|
||||||
|
|
||||||
Application application = new Application();
|
|
||||||
Context ass = application.getApplicationContext();
|
|
||||||
String oldVersion = APKVersionCodeUtils.getVerName(ass);
|
|
||||||
String newVersion = ser.query().VersionId;
|
|
||||||
@Override
|
@Override
|
||||||
public fresh new_version() throws Exception {
|
public fresh new_version(String oldVersion) throws Exception {
|
||||||
|
freshServiceImpl ser=new freshServiceImpl();
|
||||||
|
String newVersion = ser.query().VersionId;
|
||||||
if (compareVersion(oldVersion, newVersion) < 0){
|
if (compareVersion(oldVersion, newVersion) < 0){
|
||||||
return ser.query();
|
return ser.query();
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.update.update.service;
|
package com.update.update.service;
|
||||||
|
|
||||||
import com.update.update.bean.fresh;
|
import com.update.update.entity.fresh;
|
||||||
|
|
||||||
public interface refreshService {
|
public interface refreshService {
|
||||||
//判断是否需要更新,比对是否有新的版本
|
//判断是否需要更新,比对是否有新的版本
|
||||||
public fresh new_version() throws Exception;
|
public fresh new_version(String old_version) throws Exception;
|
||||||
}
|
}
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
package com.update.update.util;
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
public class APKVersionCodeUtils {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取版本号名称
|
|
||||||
*
|
|
||||||
* @param context 上下文
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String getVerName(Context context) {
|
|
||||||
String verName = "";
|
|
||||||
try {
|
|
||||||
verName = context.getPackageManager().
|
|
||||||
getPackageInfo(context.getPackageName(), 0).versionName;
|
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return verName;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,11 +1,31 @@
|
|||||||
package com.update.update.controller;
|
package com.update.update.controller;
|
||||||
|
|
||||||
|
import com.update.update.dao.freshMapper;
|
||||||
|
import com.update.update.entity.fresh;
|
||||||
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
class freshControllerTest {
|
|
||||||
|
|
||||||
|
class freshControllerTest {
|
||||||
|
private static SqlSessionFactory sqlSessionFactory;
|
||||||
|
public SqlSession getSqlSession(){
|
||||||
|
return sqlSessionFactory.openSession();
|
||||||
|
}
|
||||||
@Test
|
@Test
|
||||||
void addVersion() {
|
void addVersion() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void updating() {
|
||||||
|
SqlSession sqlSession = getSqlSession();
|
||||||
|
try{
|
||||||
|
freshMapper sysUserMapper = sqlSession.getMapper(freshMapper.class);
|
||||||
|
fresh a= sysUserMapper.query();
|
||||||
|
System.out.println(a);
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
載入中…
x
新增問題並參考
Block a user