比較提交
2 次程式碼提交
8a4f05f7a7
...
0f841262e9
作者 | SHA1 | 日期 | |
---|---|---|---|
|
0f841262e9 | ||
|
2fc965d285 |
@ -12,6 +12,7 @@ import com.update.update.service.impl.freshServiceImpl;
|
|||||||
import com.update.update.service.impl.refreshServiceImpl;
|
import com.update.update.service.impl.refreshServiceImpl;
|
||||||
import com.update.update.util.ServletUtil;
|
import com.update.update.util.ServletUtil;
|
||||||
import com.update.update.util.StringUtil;
|
import com.update.update.util.StringUtil;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@ -21,49 +22,25 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
public class freshController {
|
public class freshController {
|
||||||
@Autowired
|
@Autowired
|
||||||
freshServiceImpl freshS = new freshServiceImpl();
|
freshServiceImpl freshS = new freshServiceImpl();
|
||||||
|
@Autowired
|
||||||
|
refreshServiceImpl refreshService = new refreshServiceImpl();
|
||||||
|
|
||||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||||
public void addVersion(HttpServletRequest request, HttpServletResponse response) throws JSONException {
|
public String addVersion(@RequestParam("VersionId")String VersionId,@RequestParam("apkUrl")String apkUrl,@RequestParam("updateDescription")String updateDescription ) throws JSONException {
|
||||||
JSONObject result = new JSONObject();
|
JSONObject result = new JSONObject();
|
||||||
String VersionId = request.getParameter("VersionId");
|
int index = freshS.add (VersionId, apkUrl, updateDescription);
|
||||||
String apkUrl = request.getParameter("apkUrl");
|
if (index != 400) {
|
||||||
String updateDescription = request.getParameter("updateDescription");
|
|
||||||
if (StringUtil.isNull(VersionId)) {
|
|
||||||
result.put("message", "不能为空!");
|
|
||||||
result.put("flag", false);
|
|
||||||
ServletUtil.createSuccessResponse(200, result, response);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (StringUtil.isNull(apkUrl)) {
|
|
||||||
result.put("message", "不能为空!");
|
|
||||||
result.put("flag", false);
|
|
||||||
ServletUtil.createSuccessResponse(200, result, response);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (StringUtil.isNull(updateDescription)) {
|
|
||||||
result.put("message", "不能为空!");
|
|
||||||
result.put("flag", false);
|
|
||||||
ServletUtil.createSuccessResponse(200, result, response);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fresh f = new fresh();
|
|
||||||
f.setVersionId(VersionId);
|
|
||||||
f.setApkUrl(apkUrl);
|
|
||||||
f.setUpdateDescription(updateDescription);
|
|
||||||
int index = freshS.add(f);
|
|
||||||
if (index > 0) {
|
|
||||||
result.put("message", "信息添加成功!");
|
result.put("message", "信息添加成功!");
|
||||||
result.put("flag", true);
|
result.put("flag", true);
|
||||||
} else {
|
} else {
|
||||||
result.put("message", "信息添加失败!");
|
result.put("message", "信息添加失败,请检查是否完整!");
|
||||||
result.put("flag", false);
|
result.put("flag", false);
|
||||||
}
|
}
|
||||||
ServletUtil.createSuccessResponse(200, result, response);
|
return ServletUtil.createSuccessResponse(200, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/updating", method = RequestMethod.POST)
|
@RequestMapping(value = "/updating", method = RequestMethod.POST)
|
||||||
public void updating(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
public String updating(@RequestParam("VersionId")String oldVersionId) throws Exception {
|
||||||
String oldVersionId = request.getParameter("oldVersionId");
|
return GJson.toJson(refreshService.new_version(oldVersionId));
|
||||||
ServletUtil.createSuccessResponse(200, GJson.toJson(new refreshServiceImpl().new_version(oldVersionId)), response);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package com.update.update.dao;
|
|||||||
import com.update.update.entity.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.apache.ibatis.jdbc.SQL;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@ -16,8 +15,7 @@ public interface freshMapper {
|
|||||||
@Insert("insert into fresh(VersionId,apkUrl,updateDescription) values(#{VersionId},#{apkUrl},#{updateDescription})")
|
@Insert("insert into fresh(VersionId,apkUrl,updateDescription) values(#{VersionId},#{apkUrl},#{updateDescription})")
|
||||||
int add(fresh learnResouce);
|
int add(fresh learnResouce);
|
||||||
|
|
||||||
|
@Select("SELECT * FROM fresh")
|
||||||
|
List<fresh> query();
|
||||||
|
}
|
||||||
|
|
||||||
@Select("SELECT * FROM fresh ORDER BY id DESC LIMIT 1")
|
|
||||||
fresh query();
|
|
||||||
|
|
||||||
}
|
|
@ -5,6 +5,15 @@ public class fresh {
|
|||||||
public String apkUrl;
|
public String apkUrl;
|
||||||
public String updateDescription;
|
public String updateDescription;
|
||||||
|
|
||||||
|
public fresh() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public fresh(String versionId, String apkUrl, String updateDescription) {
|
||||||
|
VersionId = versionId;
|
||||||
|
this.apkUrl = apkUrl;
|
||||||
|
this.updateDescription = updateDescription;
|
||||||
|
}
|
||||||
|
|
||||||
public String getVersionId() {
|
public String getVersionId() {
|
||||||
return VersionId;
|
return VersionId;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package com.update.update.service;
|
package com.update.update.service;
|
||||||
|
|
||||||
import com.update.update.entity.fresh;
|
import com.update.update.entity.fresh;
|
||||||
|
import org.json.JSONException;
|
||||||
|
|
||||||
public interface freshService {
|
public interface freshService {
|
||||||
int add(fresh version);
|
int add(String VersionId,String apkUrl,String updateDescription) throws JSONException;
|
||||||
fresh query();
|
fresh query();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,23 +4,43 @@ package com.update.update.service.impl;
|
|||||||
import com.update.update.entity.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 com.update.update.util.ServletUtil;
|
||||||
|
import com.update.update.util.StringUtil;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class freshServiceImpl implements freshService {
|
public class freshServiceImpl implements freshService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
freshMapper f;
|
freshMapper f;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int add(fresh newOne) {
|
public int add(String VersionId, String apkUrl, String updateDescription) throws JSONException {
|
||||||
|
if (StringUtil.isNull(VersionId)) {
|
||||||
|
return 400;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (StringUtil.isNull(apkUrl)) {
|
||||||
|
return 400;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (StringUtil.isNull(updateDescription)) {
|
||||||
|
return 400;
|
||||||
|
}
|
||||||
|
fresh newOne = new fresh(VersionId, apkUrl, updateDescription);
|
||||||
|
|
||||||
return this.f.add(newOne);
|
return this.f.add(newOne);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public fresh query() {
|
public fresh query() {
|
||||||
return this.f.query();
|
List<fresh> s = this.f.query();
|
||||||
|
return s.get(s.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -179,11 +179,10 @@ public class ServletUtil {
|
|||||||
* 生成成功报文
|
* 生成成功报文
|
||||||
* @param httpCode
|
* @param httpCode
|
||||||
* @param result
|
* @param result
|
||||||
* @param response
|
|
||||||
*/
|
*/
|
||||||
public static String createSuccessResponse(Integer httpCode, Object result, HttpServletResponse response){
|
public static String createSuccessResponse(Integer httpCode, Object result){
|
||||||
|
|
||||||
return createSuccessResponse(httpCode, result, SerializerFeature.WriteMapNullValue,null,response);
|
return createSuccessResponse(httpCode, result, SerializerFeature.WriteMapNullValue,null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,15 +17,4 @@ class freshControllerTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@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