Skip to content

Commit

Permalink
完善core包
Browse files Browse the repository at this point in the history
  • Loading branch information
houko committed May 10, 2017
1 parent c4fa55b commit 9bc6b38
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ public Result<UserModel> findByName(@PathVariable String name) {
@ApiOperation(value = "根据名字删除数据", notes = "根据名字删除数据", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Override
public Result<Boolean> delByName(@PathVariable String name) {
boolean b = service.delByName(name);
boolean b = service.deleteByName(name);
return new Result<>(b);
}

@RequestMapping(value = "delById/{id}", method = RequestMethod.GET)
@ApiOperation(value = "根据id删除数据", notes = "根据id删除数据", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Override
public Result<Boolean> delById(@PathVariable Long id) {
boolean b = service.delById(id);
boolean b = service.deleteById(id);
return new Result<>(b);
}

Expand All @@ -100,7 +100,7 @@ public Result<Boolean> update(@RequestBody UserModel model) {
@ApiOperation(value = "根据ids批量删除数据", notes = "根据ids批量删除数据", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Override
public Result<Boolean> delByIds(@PathVariable List<Long> ids) {
boolean b = service.delByIds(ids);
boolean b = service.deleteByIds(ids);
return new Result<>(b);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public Page<UserModel> findAll(int start, int pageSize) {
}

@Override
public boolean delById(Long id) {
public boolean deleteById(Long id) {
try {
userDao.delete(id);
} catch (Exception e) {
Expand All @@ -61,7 +61,7 @@ public boolean delById(Long id) {
}

@Override
public boolean delByName(String name) {
public boolean deleteByName(String name) {
return userDao.deleteByName(name);
}

Expand Down Expand Up @@ -99,7 +99,7 @@ public boolean update(UserModel model) {
}

@Override
public boolean delByIds(List<Long> ids) {
public boolean deleteByIds(List<Long> ids) {
for (Long id : ids) {
userDao.delete(id);
}
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/info/xiaomo/core/base/BaseService.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ public interface BaseService<T> {

Page<T> findAll(int start, int pageSize);

boolean delById(Long id);
boolean deleteById(Long id);

boolean delByName(String name);
boolean deleteByName(String name);

boolean add(T model);

boolean update(T model);

boolean delByIds(List<Long> ids);
boolean deleteByIds(List<Long> ids);
}
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public Result<Boolean> update(@RequestBody UserModel user) {
*/
@Override
public Result<Boolean> delByIds(@PathVariable List<Long> ids) {
Boolean aBoolean = service.delByIds(ids);
Boolean aBoolean = service.deleteByIds(ids);
return new Result<>(aBoolean);
}

Expand Down Expand Up @@ -256,7 +256,7 @@ public Result<Page<UserModel>> findAll(@PathVariable int start, @PathVariable in
@ApiImplicitParam(name = "id", value = "唯一id", required = true, dataType = "Long", paramType = "path"),
})
public Result<Boolean> deleteUserById(@PathVariable("id") Long id) throws UserNotFoundException {
boolean userModel = service.delById(id);
boolean userModel = service.deleteById(id);
if (!userModel) {
return new Result<>(Code.USER_NOT_FOUND.getResultCode(), Code.USER_NOT_FOUND.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,58 +61,50 @@ public UserModel updateUser(UserModel model) throws UserNotFoundException {
}

@Override
public Page<UserModel> findAll(int start, int pageSize) {
Sort sort = new Sort(Sort.Direction.DESC, "createTime");
return dao.findAll(new PageRequest(start - 1, pageSize, sort));
public UserModel findById(Long id) {
return null;
}

@Override
public boolean delById(Long id) {
return false;
public UserModel findByName(String name) {
return null;
}

@Override
public boolean delByName(String name) {
return false;
public List<UserModel> findAll() {
return null;
}

@Override
public boolean add(UserModel model) {
return false;
public Page<UserModel> findAll(int start, int pageSize) {
Sort sort = new Sort(Sort.Direction.DESC, "createTime");
return dao.findAll(new PageRequest(start - 1, pageSize, sort));
}

@Override
public boolean update(UserModel model) {
public boolean deleteById(Long id) {
return false;
}

@Override
public boolean delByIds(List<Long> ids) {
public boolean deleteByName(String name) {
return false;
}

@Override
public UserModel findById(Long id) {
return null;
public boolean add(UserModel model) {
return false;
}

@Override
public UserModel findByName(String name) {
return null;
public boolean update(UserModel model) {
return false;
}

@Override
public List<UserModel> findAll() {
return dao.findAll();
public boolean deleteByIds(List<Long> ids) {
return false;
}

public UserModel deleteUserById(Long id) throws UserNotFoundException {
UserModel userModel = dao.findOne(id);
if (userModel == null) {
throw new UserNotFoundException();
}
dao.delete(userModel.getId());
return userModel;
}

}

0 comments on commit 9bc6b38

Please sign in to comment.