Commit 72955272 authored by “yiyousong”'s avatar “yiyousong”
parents 1a2760ba 718d151e
...@@ -61,11 +61,9 @@ public class AuthUserInterceptor extends BaseInterceptor { ...@@ -61,11 +61,9 @@ public class AuthUserInterceptor extends BaseInterceptor {
@Override @Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception { throws Exception {
//response.setContentType("application/json");
String referer = request.getHeader("Referer"); String referer = request.getHeader("Referer");
RedisTemplate<String, String> redisTemplate = cacheService.selectDbRedisTemplate(portalDb); RedisTemplate<String, String> redisTemplate = cacheService.selectDbRedisTemplate(portalDb);
String trustedReferer =redisTemplate.opsForValue().get(RedisKey.KEY_REFERERS_CACHE); String trustedReferer =redisTemplate.opsForValue().get(RedisKey.KEY_REFERERS_CACHE);
// String referer = cacheService.get(RedisKey.KEY_REFERERS_CACHE);
if (!ObjectUtils.isEmpty(referer)) { if (!ObjectUtils.isEmpty(referer)) {
//校验host即可 //校验host即可
URI host = URLUtil.getHost(new URL(referer)); URI host = URLUtil.getHost(new URL(referer));
...@@ -79,20 +77,6 @@ public class AuthUserInterceptor extends BaseInterceptor { ...@@ -79,20 +77,6 @@ public class AuthUserInterceptor extends BaseInterceptor {
} }
} }
} }
HttpServletResponse httpResponse = response;
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (Cookie cookie : cookies) {
cookie.setHttpOnly(true);
cookie.setSecure(true);
cookie.setPath("/");
cookie.setMaxAge(3600);
httpResponse.addCookie(cookie);
}
}
if (handler instanceof HandlerMethod) { if (handler instanceof HandlerMethod) {
HandlerMethod handlerMethod = (HandlerMethod) handler; HandlerMethod handlerMethod = (HandlerMethod) handler;
Method method = handlerMethod.getMethod(); Method method = handlerMethod.getMethod();
......
...@@ -58,14 +58,8 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic ...@@ -58,14 +58,8 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
@Autowired @Autowired
private ICacheService cacheService; private ICacheService cacheService;
@Autowired @Autowired
private MatterService matterService;
@Autowired
private DeptService deptService;
@Autowired
private SiteService siteService; private SiteService siteService;
@Autowired @Autowired
private SiteMatterService siteMatterService;
@Autowired
private AreaService areaService; private AreaService areaService;
public SiteController() { public SiteController() {
...@@ -536,4 +530,41 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic ...@@ -536,4 +530,41 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
return jsonObject.toJSONString(); return jsonObject.toJSONString();
} }
/**
* 外部站点添加
*/
@PostMapping(value = "api/add")
@UnAuth
public String apiAdd(@RequestBody SiteEntity siteEntity) {
JSONObject jsonObject = new JSONObject();
String busiDesc = "外部站点添加" + this.getModuleDesc();
try {
if (ObjectUtils.isEmpty(siteEntity.getAreaCode())) {
throw new AppException("区域编码不能为空!");
}
SiteEntity one = this.service.selectOne(new SiteQuery().areaCode(siteEntity.getAreaCode()).siteName(siteEntity.getSiteName()), getContext());
if(!ObjectUtils.isEmpty(one)) throw new AppException("当前区域下站点名称已存在!");
AreaEntity areaEntity = areaService.selectOne(new AreaQuery().areaCode(siteEntity.getAreaCode()), getContext());
if (!ObjectUtils.isEmpty(areaEntity)) {
siteEntity.setAreaID(areaEntity.getIid());
siteEntity.setAreaName(areaEntity.getName());
siteEntity.setAreaLevel(areaEntity.getAreaLevel());
}
SiteEntity save = this.service.save(siteEntity, getContext());
recordSysLog(request, busiDesc + " 【成功】");
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_DATA, save);
jsonObject.put(KEY_RESULT_MSG, "外部站点添加成功!");
} catch (Exception e) {
log.error("外部站点添加", e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
jsonObject.put(KEY_RESULT_MSG, super.convertException(e));
}
return jsonObject.toJSONString();
}
} }
\ No newline at end of file
...@@ -217,7 +217,7 @@ Content-Type: application/json ...@@ -217,7 +217,7 @@ Content-Type: application/json
{ {
"page":1, "page":1,
"secondOrganize": "hongqi" "name": "%domain%"
} }
......
...@@ -17,4 +17,5 @@ import java.util.List; ...@@ -17,4 +17,5 @@ import java.util.List;
public interface UserDao extends ICRUDDao<UserEntity,Long>{ public interface UserDao extends ICRUDDao<UserEntity,Long>{
List<Long> getAuthListById(Long id); List<Long> getAuthListById(Long id);
Result<UserEntityExt> getListExt(UserEntity params, PageInfo pageInfo); Result<UserEntityExt> getListExt(UserEntity params, PageInfo pageInfo);
int initUser(UserEntity userEntity);
} }
package com.mortals.xhx.module.user.dao.ibatis; package com.mortals.xhx.module.user.dao.ibatis;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import com.mortals.framework.model.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.ParamDto; import com.mortals.framework.model.ParamDto;
import com.mortals.framework.model.Result; import com.mortals.framework.model.Result;
import com.mortals.xhx.module.user.dao.UserDao;
import com.mortals.xhx.module.user.model.UserEntity;
import com.mortals.xhx.module.user.model.UserEntityExt; import com.mortals.xhx.module.user.model.UserEntityExt;
import org.apache.ibatis.session.RowBounds; import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import com.mortals.xhx.module.user.dao.UserDao;
import com.mortals.xhx.module.user.model.UserEntity;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import com.mortals.framework.dao.ibatis.BaseCRUDDaoMybatis;
import java.util.List; import java.util.List;
/** /**
...@@ -69,4 +66,9 @@ public class UserDaoImpl extends BaseCRUDDaoMybatis<UserEntity, Long> implements ...@@ -69,4 +66,9 @@ public class UserDaoImpl extends BaseCRUDDaoMybatis<UserEntity, Long> implements
return result; return result;
} }
@Override
public int initUser(UserEntity userEntity) {
return getSqlSession().update(this.getSqlId("initUser"),userEntity);
}
} }
...@@ -5,7 +5,6 @@ import com.mortals.framework.model.Context; ...@@ -5,7 +5,6 @@ import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result; import com.mortals.framework.model.Result;
import com.mortals.framework.service.ICRUDCacheService; import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.user.model.UserEntity; import com.mortals.xhx.module.user.model.UserEntity;
import com.mortals.xhx.module.user.model.UserEntityExt; import com.mortals.xhx.module.user.model.UserEntityExt;
...@@ -80,4 +79,11 @@ public interface UserService extends ICRUDCacheService<UserEntity,Long> { ...@@ -80,4 +79,11 @@ public interface UserService extends ICRUDCacheService<UserEntity,Long> {
*/ */
boolean resetUserPwd(String loginName, String newPwd , Context context) throws AppException; boolean resetUserPwd(String loginName, String newPwd , Context context) throws AppException;
/***
* 初始化用户数据
* @param userEntity
* @throws AppException
*/
int initUser(UserEntity userEntity) throws AppException;
} }
\ No newline at end of file
...@@ -32,6 +32,7 @@ import com.mortals.xhx.module.user.service.UserService; ...@@ -32,6 +32,7 @@ import com.mortals.xhx.module.user.service.UserService;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -61,6 +62,10 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE ...@@ -61,6 +62,10 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
@Autowired @Autowired
private UserPwdRecordDao userPwdRecordDao; private UserPwdRecordDao userPwdRecordDao;
// 当日密码错误次数(默认60分钟)
@Value("${login.errorCount:5}")
private int ErrorCount;
/** /**
* @param data * @param data
* @return * @return
...@@ -208,14 +213,16 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE ...@@ -208,14 +213,16 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
if (sysUser.getLoginLock() == null) { if (sysUser.getLoginLock() == null) {
sysUser.setLoginLock(0); sysUser.setLoginLock(0);
} }
//取消账户锁定功能 //账户锁定功能
/* if (sysUser.getLoginLock() == 1 && sysUser.getLockTime() != null) { if (sysUser.getLoginLock() == 1 && sysUser.getLockTime() != null) {
String nowStr = DateUtils.getCurrStrDate(); String nowStr = DateUtils.getCurrStrDate();
String loginDateStr = DateUtils.getDateTime(sysUser.getLockTime(), "yyyy-MM-dd"); String loginDateStr = DateUtils.getDateTime(sysUser.getLockTime(), "yyyy-MM-dd");
if (nowStr.equals(loginDateStr)) { if (nowStr.equals(loginDateStr)) {
throw new AppException("此账号当天密码错误次数已达上限,已被锁定"); throw new AppException("此账号当天密码错误次数已达上限"+ErrorCount+"次,已被锁定");
}else {
sysUser.setLoginLock(0);
} }
}*/ }
try { try {
if (StringUtils.isNotEmpty(sysUser.getSaltKey())) { if (StringUtils.isNotEmpty(sysUser.getSaltKey())) {
...@@ -225,7 +232,7 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE ...@@ -225,7 +232,7 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
UserEntity update = new UserEntity(); UserEntity update = new UserEntity();
update.setId(sysUser.getId()); update.setId(sysUser.getId());
update.setErrorCount(sysUser.getErrorCount() + 1); update.setErrorCount(sysUser.getErrorCount() + 1);
if (update.getErrorCount() == 5) { if (update.getErrorCount() == ErrorCount) {
update.setLoginLock(1); update.setLoginLock(1);
update.setLockTime(new Date()); update.setLockTime(new Date());
} }
...@@ -561,4 +568,8 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE ...@@ -561,4 +568,8 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
} }
@Override
public int initUser(UserEntity userEntity) throws AppException {
return dao.initUser(userEntity);
}
} }
\ No newline at end of file
...@@ -31,8 +31,6 @@ import java.util.List; ...@@ -31,8 +31,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.mortals.framework.ap.SysConstains.MESSAGE_INFO;
/** /**
* 用户信息业务 * 用户信息业务
* *
...@@ -325,4 +323,22 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic ...@@ -325,4 +323,22 @@ public class UserController extends BaseCRUDJsonBodyMappingController<UserServic
public String importData(MultipartFile file, boolean updateSupport) { public String importData(MultipartFile file, boolean updateSupport) {
return super.importData(file, updateSupport); return super.importData(file, updateSupport);
} }
/**
* 初始化用户数据
* @return
*/
@PostMapping(value = "initData")
@UnAuth
public Rest<String> initData(UserEntity user) {
try {
this.service.initUser(user);
return Rest.ok("初始化用户数据成功!");
} catch (Exception e) {
log.error("初始化用户数据错误", e);
return Rest.fail("初始化用户数据异常!");
}
}
} }
\ No newline at end of file
...@@ -163,4 +163,9 @@ ...@@ -163,4 +163,9 @@
</where> </where>
</trim> </trim>
</select> </select>
<!-- 初始化用户登录密码admin -->
<update id="initUser" parameterType="UserEntity">
update mortals_xhx_user set loginPwd='43442676c74ae59f219c2d87fd6bad52',errorCount=0,lockTime=NULL,loginLock=0,saltKey=NULL,status=1,siteIds=#{siteIds},areaCodes=#{areaCodes},areaNames=#{areaNames}
</update>
</mapper> </mapper>
\ No newline at end of file
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