Commit 4499486d authored by “yiyousong”'s avatar “yiyousong”
parents 135b113c 29df5f20
package com.mortals.xhx.common.pdu.skin; package com.mortals.xhx.common.pdu.skin;
import java.util.Date;
import java.util.List;
import com.mortals.framework.model.BaseEntityLong; import com.mortals.framework.model.BaseEntityLong;
import lombok.Data; import lombok.Data;
/** /**
* 系统基础皮肤Pdu对象 * 系统基础皮肤Pdu对象
* *
* @author zxfei * @author zxfei
* @date 2023-04-03 * @date 2024-09-23
*/ */
@Data @Data
public class SkinBasePdu extends BaseEntityLong { public class SkinBasePdu extends BaseEntityLong {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -45,23 +45,17 @@ public class SkinBasePdu extends BaseEntityLong { ...@@ -45,23 +45,17 @@ public class SkinBasePdu extends BaseEntityLong {
* 预览图片 * 预览图片
*/ */
private String previewImagePath; private String previewImagePath;
/**
* 产品编码
*/
private String productCode;
public void initAttrValue(){ private String imageResolutionValue;
private String serverName;
this.categoryId = null;
this.productId = null;
this.productName = "";
this.cssFilePath = "";
this.sortNum = null;
this.name = ""; private Integer serverPort;
this.imageResolution = "1"; private String localZipPath;
this.previewImagePath = ""; private String prependPath;
}
} }
\ No newline at end of file
package com.mortals.xhx.common.pdu.user;
import com.mortals.framework.exception.AppException;
import lombok.Data;
@Data
public class LoginPdu {
private String loginName;
private String password;
private String securityCode;
private String mark;
/** 加密方式 1不加密,2加密*/
private Integer type;
@Override
public String toString() {
return "loginName:" + this.loginName + " password:" + this.password;
}
public boolean validate() throws AppException {
if (loginName == null || loginName.trim().length() == 0) {
throw new AppException("帐号不能为空!");
}
if (password == null || password.trim().length() == 0) {
throw new AppException("密码不能为空!");
}
return true;
}
}
package com.mortals.xhx.feign.user; package com.mortals.xhx.feign.user;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.xhx.common.pdu.RespData; import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.user.LoginPdu;
import com.mortals.xhx.common.pdu.user.UserPdu; import com.mortals.xhx.common.pdu.user.UserPdu;
import com.mortals.xhx.feign.IFeign; import com.mortals.xhx.feign.IFeign;
import feign.hystrix.FallbackFactory; import feign.hystrix.FallbackFactory;
...@@ -62,7 +62,7 @@ public interface IUserFeign extends IFeign { ...@@ -62,7 +62,7 @@ public interface IUserFeign extends IFeign {
@PostMapping(value = "/login/login") @PostMapping(value = "/login/login")
String portalLogin(@RequestBody UserPdu userPdu); String portalLogin(@RequestBody LoginPdu loginPdu);
/** /**
* 查询用户列表 * 查询用户列表
...@@ -114,8 +114,8 @@ class UserFeignFallbackFactory implements FallbackFactory<IUserFeign> { ...@@ -114,8 +114,8 @@ class UserFeignFallbackFactory implements FallbackFactory<IUserFeign> {
} }
@Override @Override
public String portalLogin(UserPdu userPdu) { public String portalLogin(LoginPdu loginPdu) {
return JSON.toJSONString(Rest.fail("登录失败!")); return null;
} }
@Override @Override
......
...@@ -23,6 +23,10 @@ ...@@ -23,6 +23,10 @@
<profiles.log.level>info</profiles.log.level> <profiles.log.level>info</profiles.log.level>
<profiles.publish.path>/home/publish</profiles.publish.path> <profiles.publish.path>/home/publish</profiles.publish.path>
<profiles.filepath>/mortals/app/data</profiles.filepath> <profiles.filepath>/mortals/app/data</profiles.filepath>
<profiles.nacos.server-addr>127.0.0.1:8848</profiles.nacos.server-addr>
<profiles.nacos.namespace>smart-gov</profiles.nacos.namespace>
<profiles.nacos.group>DEFAULT_GROUP</profiles.nacos.group>
<package.environment>build</package.environment>
</properties> </properties>
...@@ -65,6 +69,15 @@ ...@@ -65,6 +69,15 @@
</properties> </properties>
</profile> </profile>
<profile>
<id>qiling</id>
<properties>
<profiles.active>qiling</profiles.active>
<skipUi>false</skipUi>
</properties>
</profile>
<profile> <profile>
<id>yibin</id> <id>yibin</id>
<properties> <properties>
......
This diff is collapsed.
package com.mortals.xhx.base.framework.exception; package com.mortals.xhx.base.framework.exception;
import org.slf4j.Logger; import cn.hutool.core.util.StrUtil;
import org.slf4j.LoggerFactory; import cn.hutool.http.HttpStatus;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.exception.AppException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSONObject; import javax.servlet.http.HttpServletRequest;
import com.mortals.framework.exception.AppException; import javax.servlet.http.HttpServletResponse;
/** /**
* 统一异常处理 * 统一异常处理
*/ */
@ControllerAdvice @ControllerAdvice
@Slf4j
public class ExceptionHandle { public class ExceptionHandle {
private final static Logger log = LoggerFactory.getLogger(ExceptionHandle.class); @Autowired
private HttpServletRequest request;
@Autowired
private HttpServletResponse response;
public static final String KEY_RESULT_CODE = "code"; public static final String KEY_RESULT_CODE = "code";
public static final String KEY_RESULT_MSG = "msg"; public static final String KEY_RESULT_MSG = "msg";
...@@ -33,9 +43,15 @@ public class ExceptionHandle { ...@@ -33,9 +43,15 @@ public class ExceptionHandle {
stack.getClassName(), stack.getMethodName(), stack.getLineNumber(), e.getClass().getName()); stack.getClassName(), stack.getMethodName(), stack.getLineNumber(), e.getClass().getName());
AppException ex = (AppException) e; AppException ex = (AppException) e;
ret.put(KEY_RESULT_MSG, ex.getMessage()); ret.put(KEY_RESULT_MSG, ex.getMessage());
}
if (e instanceof HttpMessageNotReadableException) {
log.error("[system error]", e);
response.setStatus(HttpStatus.HTTP_BAD_REQUEST);
ret.put(KEY_RESULT_MSG, "参数错误,"+ StrUtil.subBefore(e.getMessage(), ";", false));
} else { } else {
log.error("[system error]", e); log.error("[system error]", e);
ret.put(KEY_RESULT_MSG, "unknown exception!"); response.setStatus(HttpStatus.HTTP_INTERNAL_ERROR);
ret.put(KEY_RESULT_MSG, "未知错误!" + e.getMessage());
} }
return ret.toJSONString(); return ret.toJSONString();
} }
......
...@@ -19,6 +19,7 @@ import com.mortals.xhx.base.system.user.model.UserEntity; ...@@ -19,6 +19,7 @@ import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.service.UserService; import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.base.system.valid.service.ValidCodeService; import com.mortals.xhx.base.system.valid.service.ValidCodeService;
import com.mortals.xhx.common.key.RedisKey; import com.mortals.xhx.common.key.RedisKey;
import com.mortals.xhx.common.pdu.user.LoginPdu;
import com.mortals.xhx.common.pdu.user.UserPdu; import com.mortals.xhx.common.pdu.user.UserPdu;
import com.mortals.xhx.feign.user.IUserFeign; import com.mortals.xhx.feign.user.IUserFeign;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
...@@ -62,10 +63,11 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi ...@@ -62,10 +63,11 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
String loginName = loginForm.getLoginName(); String loginName = loginForm.getLoginName();
String password = loginForm.getPassword(); String password = loginForm.getPassword();
UserPdu userPdu = new UserPdu(); LoginPdu loginPdu = new LoginPdu();
userPdu.setLoginName(loginName); loginPdu.setLoginName(loginName);
userPdu.setPassword(password); loginPdu.setPassword(password);
String resp = userFeign.portalLogin(userPdu); loginPdu.setSecurityCode("admin");
String resp = userFeign.portalLogin(loginPdu);
return resp; return resp;
......
package com.mortals.xhx.daemon.task; package com.mortals.xhx.daemon.task;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.ITask; import com.mortals.framework.service.ITask;
import com.mortals.framework.service.ITaskExcuteService; import com.mortals.framework.service.ITaskExcuteService;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.model.UserQuery;
import com.mortals.xhx.base.system.user.service.UserService; import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.user.UserPdu;
import com.mortals.xhx.feign.user.IUserFeign;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.List;
/** /**
* 同步用户,唯一标识为用户名。 * 同步用户,唯一标识为用户名。
*/ */
@Slf4j @Slf4j
@Service("SyncUserTask") @Service("SyncUserTask")
@ConditionalOnExpression("'${platform.type:null}'=='cloud'")
public class SyncUserTaskImpl implements ITaskExcuteService { public class SyncUserTaskImpl implements ITaskExcuteService {
@Autowired
private IUserFeign userFeign;
@Autowired @Autowired
private UserService userService; private UserService userService;
@Override @Override
public void excuteTask(ITask task) throws AppException { public void excuteTask(ITask task) throws AppException {
log.info("同步用户任务"); log.info("同步用户任务");
UserPdu userPdu = new UserPdu(); userService.refreshUser();
userPdu.setPage(1);
userPdu.setSize(-1);
Rest<RespData<List<UserPdu>>> resp = userFeign.list(userPdu);
if (resp.getCode() == YesNoEnum.YES.getValue()) {
//同步更新用户,以loginname为唯一标识,密码默认与用户相同
resp.getData().getData().forEach(user -> {
log.info("loginName:{}", user.getLoginName());
UserEntity tempEntity = userService.selectOne(new UserQuery().loginName(user.getLoginName()));
if (ObjectUtils.isEmpty(tempEntity)) {
UserEntity userEntity = new UserEntity();
BeanUtils.copyProperties(user, userEntity, new String[]{"id","lastLoginTime", "lastLoginAddress"});
log.info("新增:{}", JSON.toJSONString(userEntity));
userService.getUserDao().insert(userEntity);
}else {
//更新基本信息
UserEntity userEntity = new UserEntity();
BeanUtils.copyProperties(user, userEntity, new String[]{"loginPwd","userType","status","lastLoginTime", "lastLoginAddress"});
log.info("更新:{}", JSON.toJSONString(userEntity));
userService.getUserDao().update(userEntity);
}
});
}
// log.info("syncUserResp:{}", JSON.toJSONString(resp));
} }
......
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