登录菜单问题

dev2.0
anthonywj 2 years ago
parent 23bbe2166c
commit 3847e021b2

@ -36,6 +36,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.*;
import java.util.stream.Collectors;
/**
*
@ -125,6 +126,85 @@ public class LoginController extends BaseController {
return ResultVOUtils.success(loginResponse);
}
/**
*
*
* @return
*/
@PostMapping(value = "/pda/login")
public BaseResponse pdaLogin(@RequestBody @Valid LoginRequest loginRequest,
BindingResult bindingResult,
HttpServletRequest request) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
AuthAdmin authAdmin = authAdminService.findByUserName(loginRequest.getUsername());
if (authAdmin == null) {
throw new JsonException(ResultEnum.DATA_NOT, "用户名或密码错误");
}
if (!PasswordUtils.authAdminPwd(loginRequest.getPassword()).equals(authAdmin.getPassWord())) {
throw new JsonException(ResultEnum.DATA_NOT, "用户名或密码错误");
}
if (authAdmin.getUserFlag() == 0) {
throw new JsonException(ResultEnum.DATA_NOT, "该用户已被禁用!");
}
SysPdaKeyEntity sysPdaKeyEntity = sysPdaKeyService.findDeviceByImei(loginRequest.getImei());
if (sysPdaKeyEntity == null) {
return ResultVOUtils.error(410, "该设备未注册");
} else if (sysPdaKeyEntity.getIsCheck() == 0) {
return ResultVOUtils.error(411, "该设备登记审核中,请等待,或联系管理员");
} else if (sysPdaKeyEntity.getIsCheck() == 2) {
return ResultVOUtils.error(412, "该设备被拒绝登录,请联系管理员!");
}
// 更新登录状态
AuthAdmin authAdminUp = new AuthAdmin();
authAdminUp.setId(authAdmin.getId());
authAdminUp.setLastLoginTime(new Date());
authAdminUp.setLastLoginIp(IpUtils.getIpAddr(request));
authAdminService.updateAuthAdmin(authAdminUp);
// 登录成功后获取权限,这里面会设置到缓存
// authLoginService.listRuleByAdminId(authAdmin.getId());
Map<String, Object> claims = new HashMap<>();
claims.put("admin_id", authAdmin.getId());
String token = JwtUtils.createToken(claims, 86400L); // 一天后过期
Map<String, Object> map = new HashMap<>();
map.put("id", authAdmin.getId());
map.put("token", token);
map.put("time", MsDateUtil.getDateTime());
LoginResponse loginResponse = new LoginResponse();
loginResponse.setId(authAdmin.getId() + "");
loginResponse.setToken(token);
loginResponse.setDept(authAdmin.getLocDeptCode());
loginResponse.setDeptName(authAdmin.getDeptName());
List<SysMenu> sysMenus = menuService.selectMenuList(authAdmin.getId());
// .stream().filter(item -> item.getMenuName().equals("单据管理")).findFirst().get().getChildren().
List<PdaMainItemEntity> menus = sysMenus.stream().filter(
item ->
item.getComponent() != null && (item.getComponent().equals("inout/IoCreateScanOrder")
|| item.getComponent().equals("inout/IoDealOrder")
|| item.getComponent().equals("inout/IoDealCheckOrder")
|| item.getComponent().equals("inout/IoCheckSuccessOrder")
|| item.getComponent().equals("inout/IoCheckAuditOrder")
)
).distinct().map(item ->
new PdaMainItemEntity(item.getMenuName(), item.getComponent())
).collect(Collectors.toList());
loginResponse.setMenus(menus);
logininforService.recordLogininfor(authAdmin.getEmployeeName(), Constant.LOGIN_SUCCESS, "登录成功!", request);
return ResultVOUtils.success(loginResponse);
}
/**
*
*

@ -288,21 +288,16 @@ public class IoOrderReviewController extends BaseController {
redisUtil.del(ConstantStatus.REDIS_BILLNO_CODES + orderEntity.getBillNo());
return ResultVOUtils.success("验收成功!");
} else {
if (orderEntity.getFromType() == ConstantStatus.FROM_UDISP) {
ReviewFinishRequest reviewFinishRequest = new ReviewFinishRequest();
BeanUtil.copyProperties(updateExportStatusRequest, reviewFinishRequest);
updateSpmsStauts(reviewFinishRequest);
}
ReviewFinishRequest reviewFinishRequest = new ReviewFinishRequest();
BeanUtil.copyProperties(updateExportStatusRequest, reviewFinishRequest);
updateSpmsStauts(reviewFinishRequest);
return updateReview(authAdmin, orderEntity);
}
}
} else {
if (orderEntity.getFromType() == ConstantStatus.FROM_UDISP) {
ReviewFinishRequest reviewFinishRequest = new ReviewFinishRequest();
BeanUtil.copyProperties(updateExportStatusRequest, reviewFinishRequest);
updateSpmsStauts(reviewFinishRequest);
}
ReviewFinishRequest reviewFinishRequest = new ReviewFinishRequest();
BeanUtil.copyProperties(updateExportStatusRequest, reviewFinishRequest);
updateSpmsStauts(reviewFinishRequest);
return updateReview(authAdmin, orderEntity);
}

@ -0,0 +1,15 @@
package com.glxp.api.entity.auth;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PdaMainItemEntity {
private String name;
private String key;
}

@ -1,7 +1,10 @@
package com.glxp.api.res.auth;
import com.glxp.api.entity.auth.PdaMainItemEntity;
import lombok.Data;
import java.util.List;
@Data
public class LoginResponse {
@ -12,4 +15,15 @@ public class LoginResponse {
private String dept;
private String deptName;
/**
* inout/IoCreateScanOrder
* inout/IoDealOrder
* inout/IoDealCheckOrder
* inout/IoCheckSuccessOrder
* inout/IoCheckAuditOrder
*
*/
private List<PdaMainItemEntity> menus;
}

@ -84,7 +84,7 @@
select *
FROM auth_menu
order by order_num
order by parent_id, order_num
</select>
@ -95,6 +95,7 @@
select *
FROM auth_menu
where menu_name =#{menu_name}
</select>
<select id="selectMenuList" parameterType="com.glxp.api.req.auth.FilterMenuRequest"

Loading…
Cancel
Save