Commit 4499486d authored by “yiyousong”'s avatar “yiyousong”
parents 135b113c 29df5f20
package com.mortals.xhx.common.pdu.skin;
import java.util.Date;
import java.util.List;
import com.mortals.framework.model.BaseEntityLong;
import lombok.Data;
/**
* 系统基础皮肤Pdu对象
*
* @author zxfei
* @date 2023-04-03
*/
* 系统基础皮肤Pdu对象
*
* @author zxfei
* @date 2024-09-23
*/
@Data
public class SkinBasePdu extends BaseEntityLong {
private static final long serialVersionUID = 1L;
/**
* 所属种类,来源种类
*/
* 所属种类,来源种类
*/
private Long categoryId;
/**
* 产品id
*/
* 产品id
*/
private Long productId;
/**
* 产品名称
*/
* 产品名称
*/
private String productName;
/**
* css模板合成后文件地址
*/
* css模板合成后文件地址
*/
private String cssFilePath;
/**
* 排序编号
*/
* 排序编号
*/
private Integer sortNum;
/**
* 产品皮肤名称,唯一且不为空
*/
* 产品皮肤名称,唯一且不为空
*/
private String name;
/**
* 分辨率 (1.1920*1080,2.1080*1920,3.1280*1280)
*/
* 分辨率 (1.1920*1080,2.1080*1920,3.1280*1280)
*/
private String imageResolution;
/**
* 预览图片
*/
* 预览图片
*/
private String previewImagePath;
/**
* 产品编码
*/
private String productCode;
public void initAttrValue(){
this.categoryId = null;
this.productId = null;
this.productName = "";
this.cssFilePath = "";
this.sortNum = null;
private String imageResolutionValue;
private String serverName;
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;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.common.Rest;
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.feign.IFeign;
import feign.hystrix.FallbackFactory;
......@@ -62,7 +62,7 @@ public interface IUserFeign extends IFeign {
@PostMapping(value = "/login/login")
String portalLogin(@RequestBody UserPdu userPdu);
String portalLogin(@RequestBody LoginPdu loginPdu);
/**
* 查询用户列表
......@@ -114,8 +114,8 @@ class UserFeignFallbackFactory implements FallbackFactory<IUserFeign> {
}
@Override
public String portalLogin(UserPdu userPdu) {
return JSON.toJSONString(Rest.fail("登录失败!"));
public String portalLogin(LoginPdu loginPdu) {
return null;
}
@Override
......
......@@ -23,6 +23,10 @@
<profiles.log.level>info</profiles.log.level>
<profiles.publish.path>/home/publish</profiles.publish.path>
<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>
......@@ -65,6 +69,15 @@
</properties>
</profile>
<profile>
<id>qiling</id>
<properties>
<profiles.active>qiling</profiles.active>
<skipUi>false</skipUi>
</properties>
</profile>
<profile>
<id>yibin</id>
<properties>
......
This diff is collapsed.
package com.mortals.xhx.base.framework.exception;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cn.hutool.core.util.StrUtil;
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.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.exception.AppException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* 统一异常处理
*/
@ControllerAdvice
@Slf4j
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_MSG = "msg";
public static final String KEY_RESULT_DATA = "data";
public static final int VALUE_RESULT_FAILURE = -1;
public static final String KEY_RESULT_CODE = "code";
public static final String KEY_RESULT_MSG = "msg";
public static final String KEY_RESULT_DATA = "data";
public static final int VALUE_RESULT_FAILURE = -1;
@ExceptionHandler(value = Exception.class)
@ResponseBody
public String handle(Exception e) {
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
if (e instanceof AppException) {
StackTraceElement stack = e.getStackTrace()[0];
log.error("[business error]=========stack message[{}],[{},method:{},line{}][{}]", e.getMessage(),
stack.getClassName(), stack.getMethodName(), stack.getLineNumber(), e.getClass().getName());
AppException ex = (AppException) e;
ret.put(KEY_RESULT_MSG, ex.getMessage());
} else {
log.error("[system error]", e);
ret.put(KEY_RESULT_MSG, "unknown exception!");
}
return ret.toJSONString();
}
@ExceptionHandler(value = Exception.class)
@ResponseBody
public String handle(Exception e) {
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
if (e instanceof AppException) {
StackTraceElement stack = e.getStackTrace()[0];
log.error("[business error]=========stack message[{}],[{},method:{},line{}][{}]", e.getMessage(),
stack.getClassName(), stack.getMethodName(), stack.getLineNumber(), e.getClass().getName());
AppException ex = (AppException) e;
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 {
log.error("[system error]", e);
response.setStatus(HttpStatus.HTTP_INTERNAL_ERROR);
ret.put(KEY_RESULT_MSG, "未知错误!" + e.getMessage());
}
return ret.toJSONString();
}
}
......@@ -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.valid.service.ValidCodeService;
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.feign.user.IUserFeign;
import org.apache.commons.logging.Log;
......@@ -62,10 +63,11 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
String loginName = loginForm.getLoginName();
String password = loginForm.getPassword();
UserPdu userPdu = new UserPdu();
userPdu.setLoginName(loginName);
userPdu.setPassword(password);
String resp = userFeign.portalLogin(userPdu);
LoginPdu loginPdu = new LoginPdu();
loginPdu.setLoginName(loginName);
loginPdu.setPassword(password);
loginPdu.setSecurityCode("admin");
String resp = userFeign.portalLogin(loginPdu);
return resp;
......
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.service.ITask;
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.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 org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.List;
/**
* 同步用户,唯一标识为用户名。
*/
@Slf4j
@Service("SyncUserTask")
@ConditionalOnExpression("'${platform.type:null}'=='cloud'")
public class SyncUserTaskImpl implements ITaskExcuteService {
@Autowired
private IUserFeign userFeign;
@Autowired
private UserService userService;
@Override
public void excuteTask(ITask task) throws AppException {
log.info("同步用户任务");
UserPdu userPdu = new UserPdu();
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));
userService.refreshUser();
}
......
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