【修改】全局处理Result,去除已放弃的类型,去掉success统一改为OK
【修改】系统公告无法查看的的问题处理
This commit is contained in:
+1
-1
@@ -142,7 +142,7 @@ public class MockController {
|
||||
log.info(map.toString());
|
||||
}
|
||||
res.setResult(list);
|
||||
res.success("查询成功");
|
||||
res.setMessage("查询成功");
|
||||
} catch (Exception e) {
|
||||
res.error500("查询失败"+e.getMessage());
|
||||
}
|
||||
|
||||
+17
-28
@@ -82,16 +82,14 @@ public class JoaDemoController {
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/add")
|
||||
public Result<JoaDemo> add(@RequestBody JoaDemo joaDemo) {
|
||||
Result<JoaDemo> result = new Result<JoaDemo>();
|
||||
public Result<Object> add(@RequestBody JoaDemo joaDemo) {
|
||||
try {
|
||||
joaDemoService.save(joaDemo);
|
||||
result.success("添加成功!");
|
||||
return Result.OK("添加成功!");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
result.error500("操作失败");
|
||||
return Result.error500("操作失败");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,20 +98,18 @@ public class JoaDemoController {
|
||||
* @return
|
||||
*/
|
||||
@PutMapping(value = "/edit")
|
||||
public Result<JoaDemo> edit(@RequestBody JoaDemo joaDemo) {
|
||||
Result<JoaDemo> result = new Result<JoaDemo>();
|
||||
public Result<Object> edit(@RequestBody JoaDemo joaDemo) {
|
||||
JoaDemo joaDemoEntity = joaDemoService.getById(joaDemo.getId());
|
||||
if(joaDemoEntity==null) {
|
||||
result.error500("未找到对应实体");
|
||||
return Result.error500("未找到对应实体");
|
||||
}else {
|
||||
boolean ok = joaDemoService.updateById(joaDemo);
|
||||
//TODO 返回false说明什么?
|
||||
if(ok) {
|
||||
result.success("修改成功!");
|
||||
return Result.OK("修改成功!");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
return Result.OK();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,19 +118,17 @@ public class JoaDemoController {
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<JoaDemo> delete(@RequestParam(name="id",required=true) String id) {
|
||||
Result<JoaDemo> result = new Result<JoaDemo>();
|
||||
public Result<Object> delete(@RequestParam(name="id",required=true) String id) {
|
||||
JoaDemo joaDemo = joaDemoService.getById(id);
|
||||
if(joaDemo==null) {
|
||||
result.error500("未找到对应实体");
|
||||
return Result.error500("未找到对应实体");
|
||||
}else {
|
||||
boolean ok = joaDemoService.removeById(id);
|
||||
if(ok) {
|
||||
result.success("删除成功!");
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return Result.OK();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,15 +137,13 @@ public class JoaDemoController {
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<JoaDemo> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
Result<JoaDemo> result = new Result<JoaDemo>();
|
||||
public Result<Object> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
if(ids==null || "".equals(ids.trim())) {
|
||||
result.error500("参数不识别!");
|
||||
return Result.error500("参数不识别!");
|
||||
}else {
|
||||
this.joaDemoService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
result.success("删除成功!");
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,15 +153,12 @@ public class JoaDemoController {
|
||||
*/
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<JoaDemo> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
Result<JoaDemo> result = new Result<JoaDemo>();
|
||||
JoaDemo joaDemo = joaDemoService.getById(id);
|
||||
if(joaDemo==null) {
|
||||
result.error500("未找到对应实体");
|
||||
return Result.error500("未找到对应实体");
|
||||
}else {
|
||||
result.setResult(joaDemo);
|
||||
result.setSuccess(true);
|
||||
return Result.OK(joaDemo);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user