1.remove entity package in common 2.uniform response status code for gathering/recruit component

main
Gary 11 months ago
parent 91a8962550
commit cac494fb93

@ -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;

@ -1,31 +0,0 @@
package entity;
import java.util.List;
public class PageResult<T> {
private Long total;
private List<T> rows;
public PageResult(Long total, List<T> rows) {
super();
this.total = total;
this.rows = rows;
}
public Long getTotal() {
return total;
}
public void setTotal(Long total) {
this.total = total;
}
public List<T> getRows() {
return rows;
}
public void setRows(List<T> rows) {
this.rows = rows;
}
}

@ -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;
}
}

@ -1,62 +0,0 @@
package entity;
public class ResultVO<T>{
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 <T> ResultVO<T> success(T data){
return new ResultVO<>(true,200,"操作成功", data);
}
public static ResultVO<Void> success(String message){
return new ResultVO<>(true,200,message);
}
}

@ -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;// 重复提交
}

@ -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<Void> error(Exception e){
e.printStackTrace();
return Result.failed();
}
}

@ -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<List<Gathering>> 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<Gathering> 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<PageResult<Gathering>> findSearch(@RequestBody Map searchMap, @PathVariable int page,
@PathVariable int size) {
Page<Gathering> pageList = gatheringService.findSearch(searchMap, page, size);
return new Result(true,StatusCode.OK,"查询成功", new PageResult<Gathering>(pageList.getTotalElements(), pageList.getContent()) );
return Result.success(new PageResult<Gathering>(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<Void> 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<Void> 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<Void> delete(@PathVariable String id) {
gatheringService.deleteById(id);
return new Result(true,StatusCode.OK,"删除成功");
return Result.success();
}
}

@ -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<Void> error(Exception e){
e.printStackTrace();
return Result.failed(StatusCode.RECRUIT_COMMON_FAILED);
}
}

@ -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<List<Enterprise>> 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<Enterprise> 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<PageResult<Enterprise>> findSearch(@RequestBody Map searchMap, @PathVariable int page,
@PathVariable int size) {
Page<Enterprise> pageList = enterpriseService.findSearch(searchMap, page, size);
return new Result(true,StatusCode.OK,"查询成功", new PageResult<Enterprise>(pageList.getTotalElements(), pageList.getContent()) );
return Result.success(new PageResult<Enterprise>(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<List<Enterprise>> 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<Void> 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<Void> 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<Void> delete(@PathVariable String id) {
enterpriseService.deleteById(id);
return new Result(true,StatusCode.OK,"删除成功");
return Result.success();
}
}

@ -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<List<Recruit>> 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<Recruit> 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<PageResult<Recruit>> findSearch(@RequestBody Map searchMap, @PathVariable int page,
@PathVariable int size) {
Page<Recruit> pageList = recruitService.findSearch(searchMap, page, size);
return new Result(true,StatusCode.OK,"查询成功", new PageResult<Recruit>(pageList.getTotalElements(), pageList.getContent()) );
return Result.success(new PageResult<Recruit>(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<List<Recruit>> 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<Void> 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<Void> 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<Void> delete(@PathVariable String id) {
recruitService.deleteById(id);
return new Result(true,StatusCode.OK,"删除成功");
return Result.success();
}
}

@ -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;

@ -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;

Loading…
Cancel
Save