提交信息

This commit is contained in:
Your Name 2021-08-19 16:14:23 +08:00
父節點 9e03b00796
當前提交 2fc965d285
共有 7 個檔案被更改,包括 49 行新增56 行删除

查看文件

@ -12,6 +12,7 @@ import com.update.update.service.impl.freshServiceImpl;
import com.update.update.service.impl.refreshServiceImpl;
import com.update.update.util.ServletUtil;
import com.update.update.util.StringUtil;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
@ -21,49 +22,25 @@ import javax.servlet.http.HttpServletResponse;
public class freshController {
@Autowired
freshServiceImpl freshS = new freshServiceImpl();
@Autowired
refreshServiceImpl refreshService = new refreshServiceImpl();
@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();
String VersionId = request.getParameter("VersionId");
String apkUrl = request.getParameter("apkUrl");
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) {
int index = freshS.add (VersionId, apkUrl, updateDescription);
if (index != 400) {
result.put("message", "信息添加成功!");
result.put("flag", true);
} else {
result.put("message", "信息添加失败!");
result.put("message", "信息添加失败,请检查是否完整!");
result.put("flag", false);
}
ServletUtil.createSuccessResponse(200, result, response);
return ServletUtil.createSuccessResponse(200, result);
}
@RequestMapping(value = "/updating", method = RequestMethod.POST)
public void updating(HttpServletRequest request, HttpServletResponse response) throws Exception {
String oldVersionId = request.getParameter("oldVersionId");
ServletUtil.createSuccessResponse(200, GJson.toJson(new refreshServiceImpl().new_version(oldVersionId)), response);
public String updating(@RequestParam("VersionId")String oldVersionId) throws Exception {
return GJson.toJson(refreshService.new_version(oldVersionId));
}
}

查看文件

@ -3,7 +3,6 @@ package com.update.update.dao;
import com.update.update.entity.fresh;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.stereotype.Component;
@ -16,8 +15,7 @@ public interface freshMapper {
@Insert("insert into fresh(VersionId,apkUrl,updateDescription) values(#{VersionId},#{apkUrl},#{updateDescription})")
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 updateDescription;
public fresh() {
}
public fresh(String versionId, String apkUrl, String updateDescription) {
VersionId = versionId;
this.apkUrl = apkUrl;
this.updateDescription = updateDescription;
}
public String getVersionId() {
return VersionId;
}

查看文件

@ -1,9 +1,10 @@
package com.update.update.service;
import com.update.update.entity.fresh;
import org.json.JSONException;
public interface freshService {
int add(fresh version);
int add(String VersionId,String apkUrl,String updateDescription) throws JSONException;
fresh query();
}

查看文件

@ -4,23 +4,43 @@ package com.update.update.service.impl;
import com.update.update.entity.fresh;
import com.update.update.dao.freshMapper;
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.stereotype.Service;
import java.util.List;
@Service
public class freshServiceImpl implements freshService {
@Autowired
freshMapper f;
@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);
}
@Override
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 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();
}
}
}