Commit 134043df authored by 赵啸非's avatar 赵啸非

添加校验

parent c5b3e86e
Pipeline #2837 canceled with stages
......@@ -59,72 +59,14 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
@RequestMapping("login")
public String login( @RequestBody LoginForm loginForm) throws Exception {
String loginName = loginForm.getLoginName();
String password = loginForm.getPassword();
LoginPdu loginPdu = new LoginPdu();
loginPdu.setLoginName(loginName);
loginPdu.setPassword(password);
loginPdu.setSecurityCode("admin");
String resp = userFeign.portalLogin(loginPdu);
return resp;
/*JSONObject ret = new JSONObject();
String loginName = loginForm.getLoginName();
String password = loginForm.getPassword();
//String securityCode = loginForm.getSecurityCode();
String ip = super.getRequestIP(request);
if (StringUtils.isEmpty(loginName) || StringUtils.isEmpty(password)) {
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, "未获取到用户信息,请重新登录");
return ret.toJSONString();
}
UserEntity userEntity = null;
try {
loginForm.validate();
userEntity = userService.doLogin(loginName, password, ip);
userEntity.setLastLoginAddress(ip);
//saveCurrUser(request, response, userEntity);
recordSysLog(request, userEntity, "用户登录系统成功!");
// 返回拥有的菜单数据
Set<String> urls = resourceService.findUrlSetByUserId(userEntity.getId());
List<MenuEntity> outlookBarList = menuService.findTreeMenu(userEntity, urls);
String currUserName = userEntity.getRealName();
if (currUserName == null || currUserName.trim().length() == 0) {
currUserName = "管理员";
}
userEntity.setLoginTime(System.currentTimeMillis());
userEntity.setToken(IdUtil.fastSimpleUUID());
userEntity.setExpireTime(DateUtils.addCurrDate(7).getTime());
String token = authTokenService.createToken(userEntity);
JSONObject data = new JSONObject();
data.put("token", token);
data.put("currUserName", currUserName);
data.put("barList", outlookBarList);
data.put("id", userEntity.getId());
data.put("userType", userEntity.getUserType());
//this.generateBlackCookie(request, response, loginName, urls);
ret.put(KEY_RESULT_DATA, data);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
ret.put(KEY_RESULT_MSG, "用户登录系统成功!");
ret.put("resources", urls);
return ret.toJSONString();
} catch (Exception e) {
log.error("login error ", e);
if (userEntity == null) {
userEntity = new UserEntity();
userEntity.setLoginName(loginName);
}
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, super.convertException(e));
return ret.toJSONString();
}*/
}
@RequestMapping("logout")
......@@ -159,29 +101,6 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
return ret.toJSONString();
}
private void generateBlackCookie(HttpServletRequest request, HttpServletResponse response, String loginName, Set<String> urls) {
try {
String cacheKey = RedisKey.KEY_MENU_CACHE + loginName;
String securityKey = GlobalSysInfo.getPropertyValue(SysConstains.PROP_COOKIE_SECURITY_KEY);
//应为Cookie会超长,所以改为仅存储key将值放入redis
//CookieService.setCookieForAuth(request, response, securityKey, null);
StringBuilder sb = new StringBuilder();
if (urls != null && urls.size() > 0) {
for (String url : urls) {
int index = url.hashCode() & (Integer.MAX_VALUE - 1);
sb.append(index).append(",");
}
}
String menuUrl = sb.toString();
menuUrl = AESUtil.encrypt(menuUrl, securityKey);
cacheService.set(cacheKey, menuUrl, 604800);
HttpUtil.setCookieValue(request, response, SysConstains.COOKIE_MENU, cacheKey, -1);
} catch (Throwable e) {
}
}
@RequestMapping("validcode")
public String validCode(HttpServletRequest request, HttpServletResponse response, LoginForm loginForm) {
JSONObject ret = new JSONObject();
......
package com.mortals.xhx.daemon.task;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
......@@ -10,16 +9,12 @@ import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.device.DevicePdu;
import com.mortals.xhx.common.pdu.site.SitePdu;
import com.mortals.xhx.common.pdu.skin.SkinBasePdu;
import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.feign.device.IDeviceFeign;
import com.mortals.xhx.feign.site.ISiteFeign;
import com.mortals.xhx.feign.skin.ISkinBaseFeign;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.model.DeviceQuery;
import com.mortals.xhx.module.device.service.DeviceService;
import com.mortals.xhx.module.skin.model.SkinEntity;
import com.mortals.xhx.module.skin.model.SkinQuery;
import com.mortals.xhx.module.skin.service.SkinService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
......@@ -47,8 +42,6 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
private DeviceService deviceService;
@Autowired
private SkinService skinService;
@Autowired
private ISkinBaseFeign skinBaseFeign;
@Override
public void excuteTask(ITask task) throws AppException {
......@@ -148,78 +141,6 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
}
private void syncSkin() {
SkinBasePdu skinBasePdu = new SkinBasePdu();
skinBasePdu.setProductName("填单机");
skinBasePdu.setSize(-1);
Rest<RespData<List<SkinBasePdu>>> skinBaseRest = skinBaseFeign.list(skinBasePdu);
if (skinBaseRest.getCode() == YesNoEnum.YES.getValue()) {
List<SkinBasePdu> skinBasePduList = skinBaseRest.getData().getData();
log.info("填单机皮肤总数量:{}", skinBasePduList.size());
if (!ObjectUtils.isEmpty(skinBasePduList)) {
List<SkinEntity> newSkinList = skinBasePduList.stream().map(newSkin -> {
SkinEntity skinEntity = new SkinEntity();
skinEntity.initAttrValue();
newSkin.setCssFilePath("/" + StrUtil.subAfter(newSkin.getCssFilePath(), "/", true));
newSkin.setPreviewImagePath("/" + StrUtil.subAfter(newSkin.getPreviewImagePath(), "/", true));
BeanUtils.copyProperties(newSkin, skinEntity, BeanUtil.getNullPropertyNames(newSkin));
return skinEntity;
}).collect(Collectors.toList());
List<SkinEntity> oldSkinList = skinService.find(new SkinQuery());
Map<Long, SkinEntity> oldSkinMap = oldSkinList.stream().collect(Collectors.toMap(x -> x.getId(), y -> y, (o, n) -> n));
Map<Long, SkinEntity> newSkinMap = newSkinList.stream().collect(Collectors.toMap(x -> x.getId(), y -> y, (o, n) -> n));
List<SkinEntity> updateSkinLsit = newSkinList.stream().map(item -> {
if (oldSkinMap.containsKey(item.getId())) {
item.setUsed(oldSkinMap.get(item.getId()).getUsed());
item.setUpdateTime(new Date());
return item;
}
return null;
}).filter(f -> f != null).collect(Collectors.toList());
List<SkinEntity> saveSkinList = newSkinList.stream().map(item -> {
if (!oldSkinMap.containsKey(item.getId())) {
item.setCreateUserId(1L);
item.setCreateUserName("系统管理员");
item.setCreateTime(new Date());
return item;
}
return null;
}).filter(f -> f != null).collect(Collectors.toList());
//做差集
List<Long> delSkinList = oldSkinList.stream().map(item -> {
if (!newSkinMap.containsKey(item.getId())) {
return item.getId();
}
return null;
}).filter(f -> f != null).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(updateSkinLsit)) {
log.info("皮肤更新,size:{}", updateSkinLsit.size());
// skinService.update(updateSkinLsit);
}
if (!ObjectUtils.isEmpty(saveSkinList)) {
log.info("皮肤新增,size:{}", saveSkinList.size());
skinService.save(saveSkinList);
}
if (!ObjectUtils.isEmpty(delSkinList)) {
log.info("皮肤删除,size:{}", delSkinList.size());
//skinService.remove(delSkinList,null);
}
}
}
}
@Override
public void stopTask(ITask task) throws AppException {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment