rev:手持登入接口位置更改

This commit is contained in:
zhangzhiqiang
2023-05-29 13:06:39 +08:00
parent 298b5b1e1d
commit 1c3905141f
4 changed files with 5 additions and 158 deletions

View File

@@ -85,7 +85,6 @@ public class AcsToWmsController {
}
@PostMapping("/feedDeviceStatusType")
@Log("向wms反馈设备状态")
@ApiOperation("向wms反馈设备状态")
@SaIgnore
public ResponseEntity<Object> feedDeviceStatusType(@RequestBody JSONObject param) {
@@ -95,7 +94,6 @@ public class AcsToWmsController {
@PostMapping("/feedDeviceQty")
@Log("向wms反馈设备实时数量")
@ApiOperation("向wms反馈设备实时数量")
@SaIgnore
public ResponseEntity<Object> feedDeviceRealQty(@RequestBody Map param) {
@@ -124,18 +122,9 @@ public class AcsToWmsController {
@PostMapping("/testDemo")
@Log("向wms反实施数量")
@ApiOperation("向wms反订单实施数量")
@SaIgnore
public ResponseEntity<Object> test(@RequestBody JSONObject param) {
// taskScheduleService.taskPublish();
washMachineryTask.createTask(new JSONObject(MapOf.of("device_code","QX03")));
return null;
}
@GetMapping("/taskPublish")
@Log("向wms反实施数量")
@ApiOperation("向wms反订单实施数量")
@Log("taskPublish")
@ApiOperation("taskPublish")
@SaIgnore
public void taskScheduleService(){
taskScheduleService.taskPublish();

View File

@@ -1,22 +0,0 @@
package org.nl.wms.ext.login.service;
import java.util.Map;
public interface HandLoginService {
/**
* 手持登陆
*
* @param jsonObject 条件
* @return Map<String, Object>
*/
Map<String, Object> handleLogin(Map<String, String> jsonObject);
/**
* 手持登陆查询权限
*
* @param jsonObject 条件
* @return Map<String, Object>
*/
Map<String, Object> queryAuthority(Map<String, String> jsonObject);
}

View File

@@ -1,121 +0,0 @@
package org.nl.wms.ext.login.service.impl;
import cn.dev33.satoken.secure.SaSecureUtil;
import cn.dev33.satoken.stp.SaLoginModel;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.common.utils.RedisUtils;
import org.nl.modules.wql.WQL;
import org.nl.wms.system_manage.service.role.ISysRoleService;
import org.nl.wms.system_manage.service.user.ISysUserService;
import org.nl.wms.system_manage.service.user.dao.SysUser;
import org.nl.wms.system_manage.service.user.dto.CurrentUser;
import org.nl.common.utils.SecurityUtils;
import org.nl.wms.ext.login.service.HandLoginService;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@RequiredArgsConstructor
@Slf4j
public class HandLoginServiceImpl implements HandLoginService {
private final RedisUtils redisUtils;
private final ISysUserService userService;
private final ISysRoleService roleService;
@SneakyThrows
@Override
public Map<String, Object> handleLogin(Map<String, String> param) {
JSONObject resultJson = new JSONObject();
MapUtil.getStr(param, "user");
String userName = MapUtil.getStr(param, "user");
String password = MapUtil.getStr(param, "password");
if (StrUtil.isEmpty(userName)) {
throw new BadRequestException("用户不能为空");
}
if (StrUtil.isEmpty("device_id")) {
resultJson.put("code", "0");
resultJson.put("desc", "设备不能为空");
}
if (StrUtil.isEmpty(password)) {
throw new BadRequestException("密码不能为空!");
}
SysUser userInfo = userService.getOne(new QueryWrapper<SysUser>().eq("username", userName));// 拿不到已经抛出异常
if(!SaSecureUtil.md5BySalt(userInfo.getPassword(), "salt").equals(SaSecureUtil.md5BySalt(password, "salt"))){
throw new org.nl.modules.common.exception.BadRequestException("密码错误");
}
// 获取权限列表 - 登录查找权限
List<String> permissionList = roleService.getPermissionList(JSONObject.parseObject(JSON.toJSONString(userInfo)));
// 登录输入,登出删除
CurrentUser user = new CurrentUser();
user.setId(userInfo.getUser_id());
user.setUsername(userInfo.getUsername());
user.setPresonName(userInfo.getPerson_name());
user.setUser(userInfo);
user.setPermissions(permissionList);
// SaLoginModel 配置登录相关参数
StpUtil.login(userInfo.getUser_id(), new SaLoginModel()
.setDevice("PE") // 此次登录的客户端设备类型, 用于[同端互斥登录]时指定此次登录的设备类型
.setExtra("loginInfo", user) // Token挂载的扩展参数 此方法只有在集成jwt插件时才会生效
);
// 返回 token 与 用户信息
JSONObject jsonObject = new JSONObject();
jsonObject.put("user", userInfo);
Map<String, Object> authInfo = new HashMap<String, Object>(2) {{
put("token", StpUtil.getTokenValue());
put("user", jsonObject);
}};
redisUtils.set("pe-satoken", StpUtil.getTokenValue(), StpUtil.getTokenTimeout());
return resultJson;
}
@Override
public Map<String, Object> queryAuthority(Map<String, String> jsonObject) {
String accountId = String.valueOf(SecurityUtils.getCurrentUserId());
JSONObject returnjo = new JSONObject();
if (StrUtil.isEmpty(accountId)) {
returnjo.put("code", "0");
returnjo.put("desc", "用户id不能为空");
returnjo.put("result", new JSONArray());
}
//查询一级
JSONObject result = WQL.getWO("QPADSTSETSERVICE").addParam("flag", "4").addParam("accountId", accountId).addParam("component", "0").process().uniqueResult(0);
//查询二级
JSONArray SecondResults = WQL.getWO("QPADSTSETSERVICE").addParam("flag", "4").addParam("accountId", accountId).addParam("component", "1").process().getResultJSONArray(0);
//查询三级
JSONArray roleTree = new JSONArray();
for (int i = 0; i < SecondResults.size(); i++) {
JSONObject row = SecondResults.getJSONObject(i);
String menu_id = row.getString("menu_id");
JSONArray ThirdResults = WQL.getWO("QPADSTSETSERVICE").addParam("flag", "4").addParam("accountId", accountId).addParam("component", "2").addParam("pid", menu_id).process().getResultJSONArray(0);
row.put("sonTree", ThirdResults);
roleTree.add(row);
}
result.put("sonTree", roleTree);
returnjo.put("code", "1");
returnjo.put("desc", "查询成功!");
returnjo.put("result", result);
return returnjo;
}
}

View File

@@ -1,5 +1,5 @@
package org.nl.wms.ext.login.rest;
package org.nl.wms.system_manage.controller.secutiry;
@@ -10,8 +10,9 @@ import org.nl.common.anno.Log;
import lombok.extern.slf4j.Slf4j;
import com.alibaba.fastjson.JSONObject;
import org.nl.modules.common.utils.RedisUtils;
import org.nl.wms.system_manage.service.secutiry.HandLoginService;
import org.nl.wms.system_manage.service.user.ISysUserService;
import org.nl.wms.ext.login.service.HandLoginService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;