Skip to content

Commit

Permalink
user测试完毕
Browse files Browse the repository at this point in the history
  • Loading branch information
bz51 committed Nov 15, 2017
1 parent 521315e commit cf5d800
Show file tree
Hide file tree
Showing 15 changed files with 545 additions and 145 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public enum ExpCodeEnum implements Serializable {
PARAM_NULL(ComExpPrefix + "002", "参数为空"),
NO_REPEAT(ComExpPrefix + "003", "请勿重复提交"),
SESSION_NULL(ComExpPrefix + "004", "请求头中SessionId不存在"),
HTTP_REQ_METHOD_ERROR(ComExpPrefix + "005", "HTTP请求方法不正确"),

/** User模块异常 */
USERNAME_NULL(UserExpPrefix + "000", "用户名为空"),
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public interface OrderController {
*/
@GetMapping("/sellerOrders")
@Login
@Permission("orders:query")
Result<List<OrdersEntity>> findOrdersForSeller(OrderQueryReq orderQueryReq, HttpServletRequest httpReq);

/**
Expand Down Expand Up @@ -78,7 +77,6 @@ public interface OrderController {
*/
@PutMapping("/delivery")
@Login
@Permission("order:delivery")
Result confirmDelivery(String orderId, String expressNo, HttpServletRequest httpReq);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public interface ProductController {
* @return 是否创建成功
*/
@PostMapping("product")
// @Login
// @Permission("product:create")
@Login
@Permission("product:create")
public Result createProduct(ProdInsertReq prodInsertReq);

/**
Expand All @@ -42,7 +42,7 @@ public interface ProductController {
*/
@PostMapping("image")
@Login
// @Permission("image:upload")
@Permission("image:upload")
public Result<ProdImageEntity> uploadImage(MultipartFile file);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public interface UserController {
* @return 注册是否成功
*/
@PostMapping("/register")
// TODO not test
public Result register(RegisterReq registerReq, HttpServletResponse httpRsp);


Expand All @@ -60,6 +61,7 @@ public interface UserController {
@PutMapping("/userState")
@Login
@Permission("userState:update")
// TODO not test
public Result batchUpdateUserState(BatchReq<UserStateReq> userStateReqs);

/**
Expand All @@ -81,6 +83,8 @@ public interface UserController {
@Permission("role:query")
public Result<List<RoleEntity>> findRoles();

// TODO 添加创建角色

/**
* 删除指定角色
* @param roleId 角色ID
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.gaoxi.handle;

import com.gaoxi.exception.ExpCodeEnum;
import com.gaoxi.rsp.Result;
import com.gaoxi.exception.CommonBizException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
Expand All @@ -30,6 +32,16 @@ public <T> Result<T> exceptionHandler(CommonBizException exception) {
return Result.newFailureResult(exception);
}

/**
* 请求方法不正确
* @param exception
* @return
*/
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public Result HttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException exception) {
throw new CommonBizException(ExpCodeEnum.HTTP_REQ_METHOD_ERROR);
}

/**
* 系统异常处理
* @param exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
@Component
public class InitAuth implements CommandLineRunner {

private final Logger logger = LoggerFactory.getLogger(this.getClass());

/** Redis工具包 */
@Reference(version = "1.0.0")
Expand Down
5 changes: 4 additions & 1 deletion Gaoxi-Controller/src/main/java/com/gaoxi/util/UserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.gaoxi.exception.CommonBizException;
import com.gaoxi.exception.ExpCodeEnum;
import com.gaoxi.facade.redis.RedisService;
import com.gaoxi.redis.RedisServiceTemp;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

Expand Down Expand Up @@ -43,7 +44,9 @@ public UserEntity getUser(HttpServletRequest httpServletReq) {
}

// 获取UserEntity
Object userEntity = redisService.get(sessionID);
// Object userEntity = redisService.get(sessionID);
// TODO 暂时使用本地redis
Object userEntity = RedisServiceTemp.userMap.get(sessionID);
if (userEntity == null) {
return null;
}
Expand Down
48 changes: 0 additions & 48 deletions Gaoxi-User/src/main/java/com/gaoxi/user/dao/DemoDAO.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ private void checkParam(RolePermissionReq rolePermissionReq) {
throw new CommonBizException(ExpCodeEnum.PARAM_NULL);
}

// roleId不能为空
// roleId不能为空 & TODO roleId 必须存在
if (StringUtils.isEmpty(rolePermissionReq.getRoleId())) {
throw new CommonBizException(ExpCodeEnum.ROLEID_NULL);
}

// 权限Id列表不能为空
// 权限Id列表不能为空 & 权限Id必须都存在
if (CollectionUtils.isEmpty(rolePermissionReq.getPermissionIdList())) {
throw new CommonBizException(ExpCodeEnum.PERMISSIONIDLIST_NULL);
}
Expand All @@ -216,11 +216,12 @@ private void checkParam(RoleMenuReq roleMenuReq) {
}

// roleId不能为空
// TODO 确保roleId存在
if (StringUtils.isEmpty(roleMenuReq.getRoleId())) {
throw new CommonBizException(ExpCodeEnum.ROLEID_NULL);
}

// menuId列表不能为空
// menuId列表不能为空 & TODO menuId必须存在
if (CollectionUtils.isEmpty(roleMenuReq.getMenuIdList())) {
throw new CommonBizException(ExpCodeEnum.MENUIDLIST_NULL);
}
Expand Down Expand Up @@ -262,17 +263,20 @@ private void checkParam(AdminCreateReq adminCreateReq) {
}

// 用户名不能为空
// TODO 用户名不能重复
if (StringUtils.isEmpty(adminCreateReq.getUsername())) {
throw new CommonBizException(ExpCodeEnum.USERNAME_NULL);
}

// 电话不能为空
// TODO 电话不能重复
if (StringUtils.isEmpty(adminCreateReq.getPhone())) {
throw new CommonBizException(ExpCodeEnum.PHONE_NULL);
}

// 角色不能为空
if (adminCreateReq.getRoleId() == null) {
// TODO 角色必须已存在
if (StringUtils.isEmpty(adminCreateReq.getRoleId())) {
throw new CommonBizException(ExpCodeEnum.ROLE_NULL);
}

Expand Down
4 changes: 3 additions & 1 deletion Gaoxi-User/src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ spring.dubbo.protocol.name=dubbo
spring.dubbo.protocol.port=20883
spring.dubbo.scan=com.gaoxi.user.service

server.port=8083
server.port=8083

logging.level.com.gaoxi.user.dao.UserDAO=debug
17 changes: 15 additions & 2 deletions Gaoxi-User/src/main/resources/mybatis/mapper/UserMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,30 +83,43 @@

<where>
<if test="userQueryReq.id != null">
id = #{userQueryReq.id}
user.id = #{userQueryReq.id}
</if>
<if test="userQueryReq.username != null">
username like CONCAT('%',#{userQueryReq.username},'%')
AND

username = #{userQueryReq.username}
</if>
<if test="userQueryReq.password != null">
AND
password = #{userQueryReq.password}
</if>
<if test="userQueryReq.phone != null">
AND
phone = #{userQueryReq.phone}
</if>
<if test="userQueryReq.mail != null">
AND
mail = #{userQueryReq.mail}
</if>
<if test="userQueryReq.registerTimeStart != null">
AND
register_time &gt; #{userQueryReq.registerTimeStart}
</if>
<if test="userQueryReq.registerTimeEnd != null">
AND
register_time &lt; #{userQueryReq.registerTimeEnd}
</if>
<if test="userQueryReq.userType != null">
AND
user_type = #{userQueryReq.userType}
</if>
<if test="userQueryReq.userState != null">
AND
user_state = #{userQueryReq.userState}
</if>
<if test="userQueryReq.roleId != null">
AND
role_id = #{userQueryReq.roleId}
</if>
</where>
Expand Down
Loading

0 comments on commit cf5d800

Please sign in to comment.