比較提交

..

沒有共同的提交。「0f841262e911d7b20a4f59d16fcb652f57bff7be」和「8a4f05f7a7df7343cdedb415240a88efd1c5d68f」的歷史完全不同。

共有 7 個檔案被更改,包括 56 行新增49 行删除

查看文件

@ -12,7 +12,6 @@ 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;
@ -22,25 +21,49 @@ 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 String addVersion(@RequestParam("VersionId")String VersionId,@RequestParam("apkUrl")String apkUrl,@RequestParam("updateDescription")String updateDescription ) throws JSONException { public void addVersion(HttpServletRequest request, HttpServletResponse response) throws JSONException {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
int index = freshS.add (VersionId, apkUrl, updateDescription); String VersionId = request.getParameter("VersionId");
if (index != 400) { 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) {
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);
} }
return ServletUtil.createSuccessResponse(200, result); ServletUtil.createSuccessResponse(200, result, response);
} }
@RequestMapping(value = "/updating", method = RequestMethod.POST) @RequestMapping(value = "/updating", method = RequestMethod.POST)
public String updating(@RequestParam("VersionId")String oldVersionId) throws Exception { public void updating(HttpServletRequest request, HttpServletResponse response) throws Exception {
return GJson.toJson(refreshService.new_version(oldVersionId)); String oldVersionId = request.getParameter("oldVersionId");
ServletUtil.createSuccessResponse(200, GJson.toJson(new refreshServiceImpl().new_version(oldVersionId)), response);
} }
} }

查看文件

@ -3,6 +3,7 @@ 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;
@ -15,7 +16,8 @@ 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,15 +5,6 @@ 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,10 +1,9 @@
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(String VersionId,String apkUrl,String updateDescription) throws JSONException; int add(fresh version);
fresh query(); fresh query();
} }

查看文件

@ -4,43 +4,23 @@ 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(String VersionId, String apkUrl, String updateDescription) throws JSONException { public int add(fresh newOne) {
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() {
List<fresh> s = this.f.query(); return this.f.query();
return s.get(s.size() - 1);
} }
} }

查看文件

@ -179,10 +179,11 @@ public class ServletUtil {
* 生成成功报文 * 生成成功报文
* @param httpCode * @param httpCode
* @param result * @param result
* @param response
*/ */
public static String createSuccessResponse(Integer httpCode, Object result){ public static String createSuccessResponse(Integer httpCode, Object result, HttpServletResponse response){
return createSuccessResponse(httpCode, result, SerializerFeature.WriteMapNullValue,null); return createSuccessResponse(httpCode, result, SerializerFeature.WriteMapNullValue,null,response);
} }

查看文件

@ -17,4 +17,15 @@ 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();
}
}
} }