diff --git a/luoo_common/src/main/java/api/StatusCode.java b/luoo_common/src/main/java/api/StatusCode.java index ce17ac1..32f8763 100644 --- a/luoo_common/src/main/java/api/StatusCode.java +++ b/luoo_common/src/main/java/api/StatusCode.java @@ -9,21 +9,29 @@ public enum StatusCode implements IErrorCode { FORBIDDEN(403, "没有相关权限"), //user 模块错误码以10XXX,不足5位补0; - USER_COMMON_FAILED(10000, "用户模块失败"), + USER_COMMON_FAILED(10000, "用户模块错误"), USER_VERIFICATION_CODE_EXPIRED(10001, "验证码过期,请重新获取"), USER_VERIFICATION_CODE_MISMATCH(10002, "验证码校验失败,请输入正确的验证码"), USER_NAME_OR_PASSWORD_FAILED(10003, "用户名或密码错误"), + // music 模块错误码以20XXX,不足5位补0; - MUSIC_COMMON_FAILED(20000, "歌曲模块失败"), + MUSIC_COMMON_FAILED(20000, "歌曲模块错误"), + // comment 模块错误码以30XXX,不足5位补0; - COMMENT_COMMON_FAILED(30000, "评论模块失败"), + COMMENT_COMMON_FAILED(30000, "评论模块错误"), COMMENT_REPEAT_SUBMIT(30001, "评论重复提交"), + // friend 模块错误码以40XXX,不足5位补0; - FRIEND_COMMON_FAILED(40000, "交友模块失败"), + FRIEND_COMMON_FAILED(40000, "交友模块错误"), FRIEND_CAN_NOT_REPEAT_ADD_FRIEND(40001, "不能重复添加好友"), FRIEND_CAN_NOT_REPEAT_ADD_NON_FRIEND(40002, "不能重复添加非好友"), + // tag 模块错误码以50XXX,不足5位补0; - TAG_COMMON_FAILED(50000, "标签模块失败"); + TAG_COMMON_FAILED(50000, "标签模块错误"), + + // recruit 模块错误码以50XXX,不足5位补0; + RECRUIT_COMMON_FAILED(60000, "招聘模块错误"); + private int code; private String message; diff --git a/luoo_common/src/main/java/entity/PageResult.java b/luoo_common/src/main/java/entity/PageResult.java deleted file mode 100644 index 1bcff74..0000000 --- a/luoo_common/src/main/java/entity/PageResult.java +++ /dev/null @@ -1,31 +0,0 @@ -package entity; - -import java.util.List; - -public class PageResult { - - private Long total; - private List rows; - - public PageResult(Long total, List rows) { - super(); - this.total = total; - this.rows = rows; - } - - public Long getTotal() { - return total; - } - public void setTotal(Long total) { - this.total = total; - } - public List getRows() { - return rows; - } - public void setRows(List rows) { - this.rows = rows; - } - - - -} diff --git a/luoo_common/src/main/java/entity/Result.java b/luoo_common/src/main/java/entity/Result.java deleted file mode 100644 index 9b18b6e..0000000 --- a/luoo_common/src/main/java/entity/Result.java +++ /dev/null @@ -1,56 +0,0 @@ -package entity; - -public class Result { - - - private boolean flag; - private Integer code; - private String message; - private Object data; - - public Result() { - } - - public Result(boolean flag, Integer code, String message, Object data) { - super(); - this.flag = flag; - this.code = code; - this.message = message; - this.data = data; - } - - public Result(boolean flag, Integer code, String message) { - super(); - this.flag = flag; - this.code = code; - this.message = message; - } - - public boolean isFlag() { - return flag; - } - public void setFlag(boolean flag) { - this.flag = flag; - } - public Integer getCode() { - return code; - } - public void setCode(Integer code) { - this.code = code; - } - public String getMessage() { - return message; - } - public void setMessage(String message) { - this.message = message; - } - public Object getData() { - return data; - } - public void setData(Object data) { - this.data = data; - } - - - -} diff --git a/luoo_common/src/main/java/entity/ResultVO.java b/luoo_common/src/main/java/entity/ResultVO.java deleted file mode 100644 index 0bbb950..0000000 --- a/luoo_common/src/main/java/entity/ResultVO.java +++ /dev/null @@ -1,62 +0,0 @@ -package entity; - -public class ResultVO{ - - - private boolean flag; - private Integer code; - private String message; - private T data; - - public ResultVO() { - } - - public ResultVO(boolean flag, Integer code, String message, T data) { - super(); - this.flag = flag; - this.code = code; - this.message = message; - this.data = data; - } - - public ResultVO(boolean flag, Integer code, String message) { - super(); - this.flag = flag; - this.code = code; - this.message = message; - } - - public boolean isFlag() { - return flag; - } - public void setFlag(boolean flag) { - this.flag = flag; - } - public Integer getCode() { - return code; - } - public void setCode(Integer code) { - this.code = code; - } - public String getMessage() { - return message; - } - public void setMessage(String message) { - this.message = message; - } - public T getData() { - return data; - } - public void setData(T data) { - this.data = data; - } - - public static ResultVO success(T data){ - return new ResultVO<>(true,200,"操作成功", data); - } - - public static ResultVO success(String message){ - return new ResultVO<>(true,200,message); - } - -} diff --git a/luoo_common/src/main/java/entity/StatusCode.java b/luoo_common/src/main/java/entity/StatusCode.java deleted file mode 100644 index 7b86391..0000000 --- a/luoo_common/src/main/java/entity/StatusCode.java +++ /dev/null @@ -1,16 +0,0 @@ -package entity; - -/** - * 状态 - */ -public class StatusCode { - - public static final int OK=200;//成功 - public static final int ERROR=20001;// 失败 - public static final int LOGINERROR=20002;// 用户名或密码错误 - - public static final int ACCESSERROR=20003;// 无权访问 - - public static final int REPERROR=20009;// 重复提交 - -} diff --git a/luoo_gathering/src/main/java/com/luoo/gathering/controller/BaseExceptionHandler.java b/luoo_gathering/src/main/java/com/luoo/gathering/controller/BaseExceptionHandler.java index aebd74f..add93e7 100644 --- a/luoo_gathering/src/main/java/com/luoo/gathering/controller/BaseExceptionHandler.java +++ b/luoo_gathering/src/main/java/com/luoo/gathering/controller/BaseExceptionHandler.java @@ -1,12 +1,8 @@ package com.luoo.gathering.controller; -import entity.Result; -import entity.StatusCode; +import api.Result; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; /** * 统一异常处理类 */ @@ -15,8 +11,8 @@ public class BaseExceptionHandler { @ExceptionHandler(value = Exception.class) @ResponseBody - public Result error(Exception e){ - e.printStackTrace(); - return new Result(false, StatusCode.ERROR, "执行出错"); + public Result error(Exception e){ + e.printStackTrace(); + return Result.failed(); } } diff --git a/luoo_gathering/src/main/java/com/luoo/gathering/controller/GatheringController.java b/luoo_gathering/src/main/java/com/luoo/gathering/controller/GatheringController.java index 1341eaa..0e22d81 100644 --- a/luoo_gathering/src/main/java/com/luoo/gathering/controller/GatheringController.java +++ b/luoo_gathering/src/main/java/com/luoo/gathering/controller/GatheringController.java @@ -1,4 +1,5 @@ package com.luoo.gathering.controller; + import java.util.List; import java.util.Map; @@ -14,11 +15,12 @@ import org.springframework.web.bind.annotation.RestController; import com.luoo.gathering.pojo.Gathering; import com.luoo.gathering.service.GatheringService; -import entity.PageResult; -import entity.Result; -import entity.StatusCode; +import api.PageResult; +import api.Result; + /** * 控制器层 + * * @author Administrator * */ @@ -29,80 +31,86 @@ public class GatheringController { @Autowired private GatheringService gatheringService; - - + /** * 查询全部数据 + * * @return */ - @RequestMapping(method= RequestMethod.GET) - public Result findAll(){ - return new Result(true,StatusCode.OK,"查询成功",gatheringService.findAll()); + @RequestMapping(method = RequestMethod.GET) + public Result> findAll() { + return Result.success(gatheringService.findAll()); } - + /** * 根据ID查询 + * * @param id ID * @return */ - @RequestMapping(value="/{id}",method= RequestMethod.GET) - public Result findById(@PathVariable String id){ - return new Result(true,StatusCode.OK,"查询成功",gatheringService.findById(id)); + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + public Result findById(@PathVariable String id) { + return Result.success(gatheringService.findById(id)); } - /** * 分页+多条件查询 + * * @param searchMap 查询条件封装 - * @param page 页码 - * @param size 页大小 + * @param page 页码 + * @param size 页大小 * @return 分页结果 */ - @RequestMapping(value="/search/{page}/{size}",method=RequestMethod.POST) - public Result findSearch(@RequestBody Map searchMap , @PathVariable int page, @PathVariable int size){ + @RequestMapping(value = "/search/{page}/{size}", method = RequestMethod.POST) + public Result> findSearch(@RequestBody Map searchMap, @PathVariable int page, + @PathVariable int size) { Page pageList = gatheringService.findSearch(searchMap, page, size); - return new Result(true,StatusCode.OK,"查询成功", new PageResult(pageList.getTotalElements(), pageList.getContent()) ); + return Result.success(new PageResult(pageList.getTotalElements(), pageList.getContent())); } /** - * 根据条件查询 - * @param searchMap - * @return - */ - @RequestMapping(value="/search",method = RequestMethod.POST) - public Result findSearch( @RequestBody Map searchMap){ - return new Result(true,StatusCode.OK,"查询成功",gatheringService.findSearch(searchMap)); - } - + * 根据条件查询 + * + * @param searchMap + * @return + */ + @RequestMapping(value = "/search", method = RequestMethod.POST) + public Result findSearch(@RequestBody Map searchMap) { + return Result.success(gatheringService.findSearch(searchMap)); + } + /** * 增加 + * * @param gathering */ - @RequestMapping(method=RequestMethod.POST) - public Result add(@RequestBody Gathering gathering ){ + @RequestMapping(method = RequestMethod.POST) + public Result add(@RequestBody Gathering gathering) { gatheringService.add(gathering); - return new Result(true,StatusCode.OK,"增加成功"); + return Result.success(); } - + /** * 修改 + * * @param gathering */ - @RequestMapping(value="/{id}",method= RequestMethod.PUT) - public Result update(@RequestBody Gathering gathering, @PathVariable String id ){ + @RequestMapping(value = "/{id}", method = RequestMethod.PUT) + public Result update(@RequestBody Gathering gathering, @PathVariable String id) { gathering.setId(id); - gatheringService.update(gathering); - return new Result(true,StatusCode.OK,"修改成功"); + gatheringService.update(gathering); + return Result.success(); } - + /** * 删除 + * * @param id */ - @RequestMapping(value="/{id}",method= RequestMethod.DELETE) - public Result delete(@PathVariable String id ){ + @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) + public Result delete(@PathVariable String id) { gatheringService.deleteById(id); - return new Result(true,StatusCode.OK,"删除成功"); + return Result.success(); } - + } diff --git a/luoo_recruit/src/main/java/com/luoo/recruit/controller/BaseExceptionHandler.java b/luoo_recruit/src/main/java/com/luoo/recruit/controller/BaseExceptionHandler.java index 1f11fff..257ea19 100644 --- a/luoo_recruit/src/main/java/com/luoo/recruit/controller/BaseExceptionHandler.java +++ b/luoo_recruit/src/main/java/com/luoo/recruit/controller/BaseExceptionHandler.java @@ -1,12 +1,9 @@ package com.luoo.recruit.controller; -import entity.Result; -import entity.StatusCode; +import api.Result; +import api.StatusCode; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; /** * 统一异常处理类 */ @@ -15,8 +12,8 @@ public class BaseExceptionHandler { @ExceptionHandler(value = Exception.class) @ResponseBody - public Result error(Exception e){ - e.printStackTrace(); - return new Result(false, StatusCode.ERROR, "执行出错"); + public Result error(Exception e){ + e.printStackTrace(); + return Result.failed(StatusCode.RECRUIT_COMMON_FAILED); } } diff --git a/luoo_recruit/src/main/java/com/luoo/recruit/controller/EnterpriseController.java b/luoo_recruit/src/main/java/com/luoo/recruit/controller/EnterpriseController.java index 2a90ff8..fddb78e 100644 --- a/luoo_recruit/src/main/java/com/luoo/recruit/controller/EnterpriseController.java +++ b/luoo_recruit/src/main/java/com/luoo/recruit/controller/EnterpriseController.java @@ -1,4 +1,5 @@ package com.luoo.recruit.controller; + import java.util.List; import java.util.Map; @@ -14,10 +15,12 @@ import org.springframework.web.bind.annotation.RestController; import com.luoo.recruit.pojo.Enterprise; import com.luoo.recruit.service.EnterpriseService; -import entity.*; +import api.PageResult; +import api.Result; /** * 控制器层 + * * @author Administrator * */ @@ -28,80 +31,86 @@ public class EnterpriseController { @Autowired private EnterpriseService enterpriseService; - - + /** * 查询全部数据 + * * @return */ - @RequestMapping(method= RequestMethod.GET) - public Result findAll(){ - return new Result(true,StatusCode.OK,"查询成功",enterpriseService.findAll()); + @RequestMapping(method = RequestMethod.GET) + public Result> findAll() { + return Result.success(enterpriseService.findAll()); } - + /** * 根据ID查询 + * * @param id ID * @return */ - @RequestMapping(value="/{id}",method= RequestMethod.GET) - public Result findById(@PathVariable String id){ - return new Result(true,StatusCode.OK,"查询成功",enterpriseService.findById(id)); + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + public Result findById(@PathVariable String id) { + return Result.success(enterpriseService.findById(id)); } - /** * 分页+多条件查询 + * * @param searchMap 查询条件封装 - * @param page 页码 - * @param size 页大小 + * @param page 页码 + * @param size 页大小 * @return 分页结果 */ - @RequestMapping(value="/search/{page}/{size}",method=RequestMethod.POST) - public Result findSearch(@RequestBody Map searchMap , @PathVariable int page, @PathVariable int size){ + @RequestMapping(value = "/search/{page}/{size}", method = RequestMethod.POST) + public Result> findSearch(@RequestBody Map searchMap, @PathVariable int page, + @PathVariable int size) { Page pageList = enterpriseService.findSearch(searchMap, page, size); - return new Result(true,StatusCode.OK,"查询成功", new PageResult(pageList.getTotalElements(), pageList.getContent()) ); + return Result.success(new PageResult(pageList.getTotalElements(), pageList.getContent())); } /** - * 根据条件查询 - * @param searchMap - * @return - */ - @RequestMapping(value="/search",method = RequestMethod.POST) - public Result findSearch( @RequestBody Map searchMap){ - return new Result(true,StatusCode.OK,"查询成功",enterpriseService.findSearch(searchMap)); - } - + * 根据条件查询 + * + * @param searchMap + * @return + */ + @RequestMapping(value = "/search", method = RequestMethod.POST) + public Result> findSearch(@RequestBody Map searchMap) { + return Result.success(enterpriseService.findSearch(searchMap)); + } + /** * 增加 + * * @param enterprise */ - @RequestMapping(method=RequestMethod.POST) - public Result add(@RequestBody Enterprise enterprise ){ + @RequestMapping(method = RequestMethod.POST) + public Result add(@RequestBody Enterprise enterprise) { enterpriseService.add(enterprise); - return new Result(true,StatusCode.OK,"增加成功"); + return Result.success(); } - + /** * 修改 + * * @param enterprise */ - @RequestMapping(value="/{id}",method= RequestMethod.PUT) - public Result update(@RequestBody Enterprise enterprise, @PathVariable String id ){ + @RequestMapping(value = "/{id}", method = RequestMethod.PUT) + public Result update(@RequestBody Enterprise enterprise, @PathVariable String id) { enterprise.setId(id); - enterpriseService.update(enterprise); - return new Result(true,StatusCode.OK,"修改成功"); + enterpriseService.update(enterprise); + return Result.success(); } - + /** * 删除 + * * @param id */ - @RequestMapping(value="/{id}",method= RequestMethod.DELETE) - public Result delete(@PathVariable String id ){ + @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) + public Result delete(@PathVariable String id) { enterpriseService.deleteById(id); - return new Result(true,StatusCode.OK,"删除成功"); + return Result.success(); } - + } diff --git a/luoo_recruit/src/main/java/com/luoo/recruit/controller/RecruitController.java b/luoo_recruit/src/main/java/com/luoo/recruit/controller/RecruitController.java index 19f202c..b3d6e41 100644 --- a/luoo_recruit/src/main/java/com/luoo/recruit/controller/RecruitController.java +++ b/luoo_recruit/src/main/java/com/luoo/recruit/controller/RecruitController.java @@ -1,4 +1,5 @@ package com.luoo.recruit.controller; + import java.util.List; import java.util.Map; @@ -14,11 +15,12 @@ import org.springframework.web.bind.annotation.RestController; import com.luoo.recruit.pojo.Recruit; import com.luoo.recruit.service.RecruitService; -import entity.PageResult; -import entity.Result; -import entity.StatusCode; +import api.PageResult; +import api.Result; + /** * 控制器层 + * * @author Administrator * */ @@ -29,80 +31,86 @@ public class RecruitController { @Autowired private RecruitService recruitService; - - + /** * 查询全部数据 + * * @return */ - @RequestMapping(method= RequestMethod.GET) - public Result findAll(){ - return new Result(true,StatusCode.OK,"查询成功",recruitService.findAll()); + @RequestMapping(method = RequestMethod.GET) + public Result> findAll() { + return Result.success(recruitService.findAll()); } - + /** * 根据ID查询 + * * @param id ID * @return */ - @RequestMapping(value="/{id}",method= RequestMethod.GET) - public Result findById(@PathVariable String id){ - return new Result(true,StatusCode.OK,"查询成功",recruitService.findById(id)); + @RequestMapping(value = "/{id}", method = RequestMethod.GET) + public Result findById(@PathVariable String id) { + return Result.success(recruitService.findById(id)); } - /** * 分页+多条件查询 + * * @param searchMap 查询条件封装 - * @param page 页码 - * @param size 页大小 + * @param page 页码 + * @param size 页大小 * @return 分页结果 */ - @RequestMapping(value="/search/{page}/{size}",method=RequestMethod.POST) - public Result findSearch(@RequestBody Map searchMap , @PathVariable int page, @PathVariable int size){ + @RequestMapping(value = "/search/{page}/{size}", method = RequestMethod.POST) + public Result> findSearch(@RequestBody Map searchMap, @PathVariable int page, + @PathVariable int size) { Page pageList = recruitService.findSearch(searchMap, page, size); - return new Result(true,StatusCode.OK,"查询成功", new PageResult(pageList.getTotalElements(), pageList.getContent()) ); + return Result.success(new PageResult(pageList.getTotalElements(), pageList.getContent())); } /** - * 根据条件查询 - * @param searchMap - * @return - */ - @RequestMapping(value="/search",method = RequestMethod.POST) - public Result findSearch( @RequestBody Map searchMap){ - return new Result(true,StatusCode.OK,"查询成功",recruitService.findSearch(searchMap)); - } - + * 根据条件查询 + * + * @param searchMap + * @return + */ + @RequestMapping(value = "/search", method = RequestMethod.POST) + public Result> findSearch(@RequestBody Map searchMap) { + return Result.success(recruitService.findSearch(searchMap)); + } + /** * 增加 + * * @param recruit */ - @RequestMapping(method=RequestMethod.POST) - public Result add(@RequestBody Recruit recruit ){ + @RequestMapping(method = RequestMethod.POST) + public Result add(@RequestBody Recruit recruit) { recruitService.add(recruit); - return new Result(true,StatusCode.OK,"增加成功"); + return Result.success(); } - + /** * 修改 + * * @param recruit */ - @RequestMapping(value="/{id}",method= RequestMethod.PUT) - public Result update(@RequestBody Recruit recruit, @PathVariable String id ){ + @RequestMapping(value = "/{id}", method = RequestMethod.PUT) + public Result update(@RequestBody Recruit recruit, @PathVariable String id) { recruit.setId(id); - recruitService.update(recruit); - return new Result(true,StatusCode.OK,"修改成功"); + recruitService.update(recruit); + return Result.success(); } - + /** * 删除 + * * @param id */ - @RequestMapping(value="/{id}",method= RequestMethod.DELETE) - public Result delete(@PathVariable String id ){ + @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) + public Result delete(@PathVariable String id) { recruitService.deleteById(id); - return new Result(true,StatusCode.OK,"删除成功"); + return Result.success(); } - + } diff --git a/luoo_user/src/main/java/com/luoo/user/service/AdminService.java b/luoo_user/src/main/java/com/luoo/user/service/AdminService.java index 1c7394f..2088f79 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/AdminService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/AdminService.java @@ -1,22 +1,18 @@ package com.luoo.user.service; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import java.util.Map; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; -import javax.persistence.criteria.Selection; import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Sort; import org.springframework.data.jpa.domain.Specification; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.stereotype.Service; diff --git a/luoo_user/src/main/java/com/luoo/user/service/UserService.java b/luoo_user/src/main/java/com/luoo/user/service/UserService.java index 8a08606..f8416c6 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/UserService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/UserService.java @@ -5,24 +5,16 @@ import java.util.concurrent.TimeUnit; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Expression; import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; -import javax.persistence.criteria.Selection; import javax.servlet.http.HttpServletRequest; -import entity.Result; -import entity.StatusCode; -import io.jsonwebtoken.Claims; import org.apache.commons.lang3.RandomStringUtils; -import org.apache.commons.lang3.RandomUtils; -import org.springframework.amqp.rabbit.core.RabbitMessagingTemplate; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Sort; import org.springframework.data.jpa.domain.Specification; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;