use autowired to fetch freshserviceimpl instance

This commit is contained in:
juzeon 2021-08-18 18:06:56 +08:00
父節點 2546987df5
當前提交 9e03b00796
共有 2 個檔案被更改,包括 7 行新增7 行删除

查看文件

@ -60,9 +60,10 @@ public class freshController {
}
ServletUtil.createSuccessResponse(200, result, response);
}
@RequestMapping(value = "/updating",method = RequestMethod.POST)
@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);
}
ServletUtil.createSuccessResponse(200, GJson.toJson(new refreshServiceImpl().new_version(oldVersionId)), response);
}
}

查看文件

@ -10,8 +10,8 @@ import org.springframework.stereotype.Service;
@Service
public class refreshServiceImpl implements refreshService {
freshServiceImpl ser=new freshServiceImpl();
@Autowired
freshServiceImpl ser = new freshServiceImpl();
//version1大返回一个正数小返回一个负数相等返回0
public static int compareVersion(String version1, String version2) throws Exception {
@ -35,9 +35,8 @@ public class refreshServiceImpl implements refreshService {
@Override
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 null;