Commit 890916c7 authored by 赵啸非's avatar 赵啸非

修改缓存

parent 12c7b307
......@@ -7,6 +7,7 @@ import com.mortals.framework.common.code.PageDisplayType;
import com.mortals.framework.model.Context;
import com.mortals.framework.util.FileUtil;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -24,14 +25,14 @@ import java.util.HashMap;
import java.util.Map;
/**
*
* 参数信息
*
* @author: zxfei
* @date: 2021/11/30 10:04
* @date: 2022/5/7 15:38
*/
@RestController
@RequestMapping("param")
public class ParamController extends BaseCRUDJsonMappingController<ParamService, ParamForm, ParamEntity, Long> {
public class ParamController extends BaseCRUDJsonBodyMappingController<ParamService, ParamEntity, Long> {
public ParamController() {
super.setFormClass(ParamForm.class);
......@@ -39,21 +40,17 @@ public class ParamController extends BaseCRUDJsonMappingController<ParamService,
}
@Override
protected void init(HttpServletRequest request, HttpServletResponse response, ParamForm form,
Map<String, Object> model, Context context) {
protected void init(Map<String, Object> model, Context context) {
Map<String, Object> status = new HashMap<String, Object>();
status.put("validStatus", DataSatusEnum.getEnumMap(DataSatusEnum.CLOSE.getValue(),
DataSatusEnum.DELETE.getValue(), DataSatusEnum.OVERDUE.getValue(), DataSatusEnum.USEOUT.getValue()));
status.put("modStatus", ModStatusEnum.getEnumMap());
status.put("displayType", getPageDisplayType());
model.put(KEY_RESULT_DICT, status);
super.init(request, response, form, model, context);
}
private Map<String, Object> getPageDisplayType() {
PageDisplayType[] pageDisplayTypes = PageDisplayType.values();
Map<String, Object> result = new HashMap<>(pageDisplayTypes.length);
for (PageDisplayType pageDisplayType : pageDisplayTypes) {
......
/**
* 文件:ResourceController.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.resource.web;
......@@ -16,6 +9,8 @@ import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.common.code.UserType;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -29,16 +24,15 @@ import com.mortals.xhx.common.code.AuthType;
import com.mortals.xhx.common.code.SourceType;
/**
* <p>Title: 资源信息</p>
* <p>Description: ResourceController </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
* 资源信息
*
* @author: zxfei
* @date: 2022/5/7 15:27
*/
@Slf4j
@RestController
@RequestMapping("resource")
public class ResourceController extends BaseCRUDJsonMappingController<ResourceService,ResourceForm,ResourceEntity,Long> {
public class ResourceController extends BaseCRUDJsonBodyMappingController<ResourceService,ResourceEntity,Long> {
public ResourceController(){
super.setFormClass(ResourceForm.class);
......@@ -46,8 +40,7 @@ public class ResourceController extends BaseCRUDJsonMappingController<ResourceSe
}
@Override
protected void init(HttpServletRequest request, HttpServletResponse response, ResourceForm form,
Map<String, Object> model, Context context) {
protected void init(Map<String, Object> model, Context context) {
Map<String, Object> statsus = new HashMap<String, Object>();
statsus.put("authType", AuthType.getEnumMap());
statsus.put("sourceType", SourceType.getEnumMap());
......@@ -57,7 +50,6 @@ public class ResourceController extends BaseCRUDJsonMappingController<ResourceSe
statsus.put("userType", UserType.findByValue(getCurUser().getUserType()));
}
model.put(KEY_RESULT_DICT, statsus);
super.init(request, response, form, model, context);
}
/**
......
/**
* 文件:RoleAuthController.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.role.web;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.role.model.RoleAuthQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -21,39 +18,38 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* <p>Title: 角色资源权限</p>
* <p>Description: RoleAuthController </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
* 角色资源权限
*
* @author: zxfei
* @date: 2022/5/7 15:19
*/
@Slf4j
@RestController
@RequestMapping("role/auth")
public class RoleAuthController extends BaseCRUDJsonMappingController<RoleAuthService,RoleAuthForm,RoleAuthEntity,Long> {
public RoleAuthController(){
super.setFormClass(RoleAuthForm.class);
super.setModuleDesc("角色资源权限");
}
/**
* 分配资源
*/
@PostMapping(value = "distributionSource")
public String distributionUser(HttpServletRequest request, HttpServletResponse response, RoleAuthForm form) {
try {
service.doDistributionSource(form.getQuery());
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
return ret.toJSONString();
} catch (Exception e) {
log.error("分配角色资源错误", e);
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, super.convertException(e));
return ret.toJSONString();
}
}
public class RoleAuthController extends BaseCRUDJsonBodyMappingController<RoleAuthService, RoleAuthEntity, Long> {
public RoleAuthController() {
super.setFormClass(RoleAuthForm.class);
super.setModuleDesc("角色资源权限");
}
/**
* 分配资源
*/
@PostMapping(value = "distributionSource")
public String distributionUser(@RequestBody RoleAuthQuery query) {
try {
service.doDistributionSource(query);
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
return ret.toJSONString();
} catch (Exception e) {
log.error("分配角色资源错误", e);
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, super.convertException(e));
return ret.toJSONString();
}
}
}
\ No newline at end of file
/**
* 文件:RoleController.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.role.web;
......@@ -13,6 +6,7 @@ import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.common.code.UserType;
import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.framework.web.BasePhpCRUDJsonMappingController;
import com.mortals.xhx.base.system.role.model.RoleQuery;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -32,16 +26,14 @@ import java.util.List;
import java.util.Map;
/**
* <p>Title: 角色信息</p>
* <p>Description: RoleController </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
* 角色信息
*
* @author: zxfei
* @date: 2022/5/7 15:15
*/
@RestController
@RequestMapping("role")
public class RoleController extends BasePhpCRUDJsonMappingController<RoleService,RoleForm,RoleEntity,Long> {
public class RoleController extends BaseCRUDJsonBodyMappingController<RoleService,RoleEntity,Long> {
@Autowired
private RoleUserService roleUserService;
......@@ -59,7 +51,12 @@ public class RoleController extends BasePhpCRUDJsonMappingController<RoleService
model.put(KEY_RESULT_DICT, status);
}
/**
* 根据用户id获取角色名称
* @param userId
* @return
*/
@PostMapping("roleNameByUserId")
public String getRoleNameByUserId(@RequestParam(value = "userId") Long userId) {
try{
......
/**
* 文件:RoleUserController.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.role.web;
import com.alibaba.fastjson.JSONObject;
......@@ -15,9 +8,12 @@ import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.role.model.RoleUserQuery;
import org.apache.commons.beanutils.MethodUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mortals.framework.web.BaseCRUDJsonMappingController;
......@@ -38,29 +34,50 @@ import java.util.Set;
import java.util.stream.Collectors;
/**
* <p>Title: 角色用户</p>
* <p>Description: RoleUserController </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
* 角色用户
*
* @author: zxfei
* @date: 2022/5/7 15:15
*/
@RestController
@RequestMapping("role/user")
public class RoleUserController extends BaseCRUDJsonMappingController<RoleUserService,RoleUserForm,RoleUserEntity,Long> {
public class RoleUserController extends BaseCRUDJsonBodyMappingController<RoleUserService, RoleUserEntity, Long> {
@Autowired
private RoleService roleService;
@Autowired
private UserService userService;
public RoleUserController() {
super.setFormClass(RoleUserForm.class);
super.setModuleDesc("角色用户");
}
@Autowired
private RoleService roleService;
@Autowired
private UserService userService;
public RoleUserController(){
super.setFormClass(RoleUserForm.class);
super.setModuleDesc("角色用户");
}
/**
@Override
protected void init(Map<String, Object> model, Context context) {
Map<String, Object> status = new HashMap<>(3);
status.put("roleId", roleService.find(new RoleEntity(), null).stream()
.collect(Collectors.toMap(e -> e.getId().toString(), RoleEntity::getName)));
List<RoleUserEntity> roleUserList = (List<RoleUserEntity>) model.get(SysConstains.RESULT_KEY);
if (roleUserList != null && roleUserList.size() > 0) {
List<Long> userIdsList = roleUserList.stream().map(RoleUserEntity::getUserId).collect(Collectors.toList());
List<UserEntity> userEntityList = userService.find(getQuery(UserQuery.class,
Sets.newHashSet("id", "realName", "loginName"), userIdsList.toArray(new Long[userIdsList.size()])), null);
if (userEntityList != null) {
status.put("userReNameMap",
userEntityList.stream().collect(Collectors.toMap(e -> e.getId().toString(), UserEntity::getRealName)));
status.put("userId",
userEntityList.stream().collect(Collectors.toMap(e -> e.getId().toString(), UserEntity::getLoginName)));
}
}
model.put(KEY_RESULT_DICT, status);
}
/**
* 获取查询对象,限制查询返回的结果只包含ID和名称
*
* @param IdList
* @return
*/
......@@ -79,65 +96,42 @@ public class RoleUserController extends BaseCRUDJsonMappingController<RoleUserSe
}
}
@SuppressWarnings("unchecked")
@Override
protected void init(HttpServletRequest request, HttpServletResponse response, RoleUserForm form, Map<String, Object> model, Context context) {
Map<String, Object> status = new HashMap<>(3);
status.put("roleId", roleService.find(new RoleEntity(), null).stream()
.collect(Collectors.toMap(e -> e.getId().toString(), RoleEntity::getName)));
List<RoleUserEntity> roleUserList = (List<RoleUserEntity>) model.get(SysConstains.RESULT_KEY);
if(roleUserList!=null && roleUserList.size()>0) {
List<Long> userIdsList = roleUserList.stream().map(RoleUserEntity::getUserId).collect(Collectors.toList());
List<UserEntity> userEntityList = userService.find(getQuery(UserQuery.class,
Sets.newHashSet("id", "realName","loginName"), userIdsList.toArray(new Long[userIdsList.size()])), null);
if(userEntityList!=null) {
status.put("userReNameMap",
userEntityList.stream().collect(Collectors.toMap(e -> e.getId().toString(), UserEntity::getRealName)));
status.put("userId",
userEntityList.stream().collect(Collectors.toMap(e -> e.getId().toString(), UserEntity::getLoginName)));
}
}
model.put(KEY_RESULT_DICT, status);
super.init(request, response, form, model, context);
}
/**
* 分配用户
*/
@PostMapping(value = "distributionUser")
public String distributionUser(HttpServletRequest request, HttpServletResponse response, RoleUserForm form) {
try {
service.doDistributionUser(form.getQuery());
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
return ret.toJSONString();
} catch (Exception e) {
log.error("分配用户错误", e);
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, super.convertException(e));
return ret.toJSONString();
}
}
/**
* 分配用户
*/
@PostMapping(value = "distributionUser")
public String distributionUser(@RequestBody RoleUserQuery query) {
try {
service.doDistributionUser(query);
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
return ret.toJSONString();
} catch (Exception e) {
log.error("分配用户错误", e);
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, super.convertException(e));
return ret.toJSONString();
}
}
/**
* 分配角色
*/
@PostMapping(value = "distributionRole")
public String distributionRole(HttpServletRequest request, HttpServletResponse response, RoleUserForm form) {
try {
service.doDistributionRole(form.getQuery());
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
return ret.toJSONString();
} catch (Exception e) {
log.error("分配角色错误", e);
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, super.convertException(e));
return ret.toJSONString();
}
}
/**
* 分配角色
*/
@PostMapping(value = "distributionRole")
public String distributionRole(@RequestBody RoleUserQuery query) {
try {
service.doDistributionRole(query);
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
return ret.toJSONString();
} catch (Exception e) {
log.error("分配角色错误", e);
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, super.convertException(e));
return ret.toJSONString();
}
}
}
\ No newline at end of file
/**
* 文件:TaskController.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.task.web;
......@@ -14,6 +7,8 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.task.model.TaskQuery;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -32,16 +27,14 @@ import com.mortals.xhx.common.code.TaskExcuteStrategyEnum;
import com.mortals.xhx.common.code.TaskInterimExcuteStatusEnum;
/**
* <p>Title: 任务信息</p>
* <p>Description: TaskController </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
* 任务信息
*
* @author: zxfei
* @date: 2022/5/7 15:39
*/
@RestController
@RequestMapping("task")
public class TaskController extends BaseCRUDJsonMappingController<TaskService, TaskForm, TaskEntity, Long> {
public class TaskController extends BaseCRUDJsonBodyMappingController<TaskService, TaskEntity, Long> {
public TaskController() {
super.setFormClass(TaskForm.class);
......@@ -50,8 +43,7 @@ public class TaskController extends BaseCRUDJsonMappingController<TaskService, T
@Override
protected void init(HttpServletRequest request, HttpServletResponse response, TaskForm form,
Map<String, Object> model, Context context) {
protected void init(Map<String, Object> model, Context context) {
Map<String, Object> status = new HashMap<String, Object>();
status.put("status", TaskExcuteStatusEnum.getEnumMap());
status.put("excuteStrategy", TaskExcuteStrategyEnum.getEnumMap());
......@@ -71,60 +63,30 @@ public class TaskController extends BaseCRUDJsonMappingController<TaskService, T
}
model.put("excuteService", serviceList);
model.put(KEY_RESULT_DICT, status);
super.init(request, response, form, model, context);
}
/**
* @param request
* @param response
* @param form
* @param model
* @param context
* @throws AppException
* @Description: TODO
*/
@Override
protected void saveBefore(HttpServletRequest request, HttpServletResponse response, TaskForm form,
Map<String, Object> model, Context context) throws AppException {
if (null == form.getEntity().getExcuteService()) {
}
// TaskEntity condition = new TaskEntity();
// condition.setExcuteService(form.getEntity().getExcuteService());
// List<TaskEntity> datas = this.service.find(condition, context);
// if (null != datas && datas.size() > 0) {
// for (TaskEntity entity : datas) {
// if (entity.getId().longValue() != form.getEntity().getId().longValue()) {
// throw new AppException("任务已存在,请勿重复配置");
// }
// }
// }
super.saveBefore(request, response, form, model, context);
}
/**
* 改变状态
*/
@RequestMapping(value = "change/status")
public String changeStatus(HttpServletRequest request, HttpServletResponse response, TaskForm form) {
public String changeStatus(TaskQuery query) {
JSONObject ret = new JSONObject();
Context context = getContext();
try {
TaskEntity entity = this.service.get(form.getEntity().getId(), context);// .doSubmitAudit(form.getEntity(),
TaskEntity entity = this.service.get(query.getId(), context);// .doSubmitAudit(form.getEntity(),
// context);
if (null == entity) {
throw new AppException("任务不存在!");
}
if (null == form.getEntity().getStatus()) {
if (null == query.getStatus()) {
throw new AppException("任务状态不能为空!");
}
if (form.getEntity().getStatus() != DataSatusEnum.ENABLE.getValue()
&& form.getEntity().getStatus() != DataSatusEnum.DISENABLE.getValue()) {
if (query.getStatus() != DataSatusEnum.ENABLE.getValue()
&& query.getStatus() != DataSatusEnum.DISENABLE.getValue()) {
throw new AppException("非法任务状态!");
}
String busiDesc = DataSatusEnum.getByValue(form.getEntity().getStatus()).getDesc();
entity.setStatus(form.getEntity().getStatus());
String busiDesc = DataSatusEnum.getByValue(query.getStatus()).getDesc();
entity.setStatus(query.getStatus());
this.service.update(entity, context);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
ret.put(KEY_RESULT_MSG, busiDesc + "成功");
......
......@@ -28,7 +28,7 @@ public class UploadController extends BaseController {
private UploadService uploadService;
@RequestMapping(value = "upload")
public String doFileUpload(HttpServletRequest request, HttpServletResponse response, UploadForm form) {
public String doFileUpload(HttpServletRequest request, UploadForm form) {
Map<String, Object> model = new HashMap<>();
String jsonStr = "";
try {
......
......@@ -6,6 +6,7 @@ import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.common.code.UserType;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.framework.web.BaseCRUDJsonMappingController;
import com.mortals.xhx.base.framework.annotation.Operlog;
import com.mortals.xhx.base.system.user.model.UserEntity;
......@@ -27,16 +28,14 @@ import java.util.HashMap;
import java.util.Map;
/**
* <p>Title: 用户信息</p>
* <p>Description: UserController </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
* 用户信息
*
* @author: zxfei
* @date: 2022/5/7 15:42
*/
@RestController
@RequestMapping("user")
public class UserController extends BaseCRUDJsonMappingController<UserService, UserForm, UserEntity, Long> {
public class UserController extends BaseCRUDJsonBodyMappingController<UserService, UserEntity, Long> {
@Autowired
private UserService userService;
......@@ -47,62 +46,52 @@ public class UserController extends BaseCRUDJsonMappingController<UserService, U
}
@Override
protected void init(HttpServletRequest request, HttpServletResponse response, UserForm form,
Map<String, Object> model, Context context) {
protected void init(Map<String, Object> model, Context context) {
Map<String, Object> statsus = new HashMap<String, Object>();
statsus.put("userType", IBaseEnum.getEnumMap(UserType.class));
statsus.put("status", UserStatus.getEnumMap());
model.put(KEY_RESULT_DICT, statsus);
super.init(request, response, form, model, context);
}
@Override
protected void doListBefore(HttpServletRequest request, HttpServletResponse response, UserForm form, Map<String, Object> model, Context context) throws AppException {
if (!StringUtils.isEmpty(form.getQuery().getRealName())) {
form.getQuery().setRealName("%".concat(form.getQuery().getRealName()).concat("%"));
protected void doListBefore(UserEntity query, Map<String, Object> model, Context context) throws AppException {
if (!StringUtils.isEmpty(query.getRealName())) {
query.setRealName("%".concat(query.getRealName()).concat("%"));
}
if (!StringUtils.isEmpty(form.getQuery().getLoginName())) {
form.getQuery().setLoginName("%".concat(form.getQuery().getLoginName()).concat("%"));
if (!StringUtils.isEmpty(query.getLoginName())) {
query.setLoginName("%".concat(query.getLoginName()).concat("%"));
}
}
@Override
protected void editBefore(HttpServletRequest request, HttpServletResponse response, UserForm form,
Map<String, Object> model, Context context) throws AppException {
form.getEntity().setLoginPwd(null);
form.getEntity().setLoginPwd1(null);
form.getEntity().setLoginPwd2(null);
super.editBefore(request, response, form, model, context);
}
@Override
protected int editAfter(HttpServletRequest request, HttpServletResponse response, UserForm form,
Map<String, Object> model, UserEntity entity, Context context) throws AppException {
protected int editAfter(Long id, Map<String, Object> model, UserEntity entity, Context context) throws AppException {
entity.setLoginPwd(null);
entity.setLoginPwd1(null);
entity.setLoginPwd2(null);
return super.editAfter(request, response, form, model, entity, context);
return super.editAfter(id, model, entity, context);
}
@Override
protected int saveAfter(HttpServletRequest request, HttpServletResponse response, UserForm form, Map<String, Object> model, Context context) throws AppException {
if (form.getEntity().getId() == getCurUser().getId()) {
saveCurrUserForSession(request, response, userService.get(form.getEntity().getId(), false));
protected int saveAfter(UserEntity entity, Map<String, Object> model, Context context) throws AppException {
if (entity.getId() == getCurUser().getId()) {
//saveCurrUserForSession(request, response, userService.get(form.getEntity().getId(), false));
}
return VALUE_RESULT_SUCCESS;
return super.saveAfter(entity, model, context);
}
@Override
protected void saveBefore(HttpServletRequest request, HttpServletResponse response, UserForm form,
Map<String, Object> model, Context context) throws AppException {
if (service.existUser(form.getEntity().getLoginName(), form.getEntity().getId())) {
protected void saveBefore(UserEntity entity, Map<String, Object> model, Context context) throws AppException {
if (service.existUser(entity.getLoginName(), entity.getId())) {
throw new AppException("登录名已存在!");
}
super.saveBefore(request, response, form, model, context);
super.saveBefore(entity, model, context);
}
@RequestMapping(value = "change/password", method = RequestMethod.POST)
@Operlog(msg = "密码修改成功!")
public String changePassword(@RequestParam String oldPwd, @RequestParam String newPwd) {
......@@ -121,17 +110,14 @@ public class UserController extends BaseCRUDJsonMappingController<UserService, U
public static void main(String[] args) {
String token="eyJhbGciOiJIUzI1NiJ9.eyJsb2dpbl91c2VyX2tleSI6IjIzNGE5NDA5ZDVhOTQ3MWNhMzdkYjZkYmMwY2JjZTc5In0.MWyQW40HYDxyUz7PJRf_nRsFPWx3Hr811Ime984nixs";
String secret="026db82420614469897fcc2dc1b4ce38";
String token = "eyJhbGciOiJIUzI1NiJ9.eyJsb2dpbl91c2VyX2tleSI6IjIzNGE5NDA5ZDVhOTQ3MWNhMzdkYjZkYmMwY2JjZTc5In0.MWyQW40HYDxyUz7PJRf_nRsFPWx3Hr811Ime984nixs";
String secret = "026db82420614469897fcc2dc1b4ce38";
Claims claims = Jwts.parser()
.setSigningKey(Base64.getEncoder().encodeToString(secret.getBytes()))
.parseClaimsJws(token)
.getBody();
String uuid = (String)claims.get("login_user_key");
String uuid = (String) claims.get("login_user_key");
System.out.println(uuid);
......
......@@ -62,11 +62,18 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
super.saveBefore(entity, context);
}
void checkSite(SiteQuery siteQuery,Context context){
if(!ObjectUtils.isEmpty(context)&&!ObjectUtils.isEmpty(context.getUser())&&!ObjectUtils.isEmpty(context.getUser().getSiteId())){
}
}
@Override
public List<SiteTreeSelect> siteTree(Context context) {
Map<String, AreaEntity> areaMap = new HashMap<>();
//查询所有已配置的站点
List<SiteEntity> siteList = this.find(new SiteQuery());
SiteQuery siteQuery = new SiteQuery();
List<SiteEntity> siteList = this.find(siteQuery);
Map<String, SiteEntity> siteMap = siteList.parallelStream().collect(Collectors.toMap(x -> x.getSiteCode(), y -> y, (o, n) -> n));
//遍历过滤站点树
for (SiteEntity siteEntity : siteList) {
......@@ -75,11 +82,12 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
if (!ObjectUtils.isEmpty(areaEntity) && !ObjectUtils.isEmpty(areaEntity.getPid())) {
//递归查找父节点并添加
areaMap.put(areaEntity.getAreaCode(), areaEntity);
//递归
recursionFn(areaMap, areaEntity);
}
}
return buildSiteTreeSelect(areaMap, siteMap);
return buildSiteTreeSelect(areaMap, siteMap);
}
@Override
......@@ -93,18 +101,19 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
}
public List<SiteTreeSelect> buildSiteTreeSelect(Map<String, AreaEntity> areaMap, Map<String, SiteEntity> siteMap) {
List<AreaEntity> list = areaMap.values().stream().collect(Collectors.toList());
List<AreaEntity> areaList = areaMap.values().stream().collect(Collectors.toList());
List<AreaEntity> returnList = new ArrayList<>();
List<String> tempList = list.stream().map(AreaEntity::getIid).collect(Collectors.toList());
for (AreaEntity areaEntity : list) {
//区域id
List<String> tempList = areaList.stream().map(AreaEntity::getIid).collect(Collectors.toList());
for (AreaEntity areaEntity : areaList) {
//查询当前区域列表中最顶级的节点 并构建树
if (!tempList.contains(areaEntity.getPid())) {
recursion(list, areaEntity);
recursion(areaList, areaEntity);
returnList.add(areaEntity);
}
}
if (returnList.isEmpty()) {
returnList = list;
returnList = areaList;
}
List<SiteTreeSelect> collect = returnList.stream().map(item ->
......
......@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -72,6 +73,16 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
if (ObjectUtils.isEmpty(siteTree)) {
siteTree = this.service.siteTree(getContext());
}
//校验
Long siteId = getContext().getUser().getSiteId();
if(!ObjectUtils.isEmpty(siteId)){
//遍历树
SiteTreeSelect temp =reFucurs(siteTree,siteId.toString());
if (!ObjectUtils.isEmpty(temp)) {
siteTree = new ArrayList<>();
siteTree.add(temp);
}
}
model.put("siteTree", siteTree);
this.init(model, getContext());
recordSysLog(request, busiDesc + " 【成功】");
......@@ -86,4 +97,17 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
}
public SiteTreeSelect reFucurs(List<SiteTreeSelect> siteTree, String siteId) {
for (SiteTreeSelect site : siteTree) {
if (site.getId() == siteId) {
return site;
} else {
if (!ObjectUtils.isEmpty(site.getChildren())) {
reFucurs(site.getChildren(), siteId);
}
}
}
return null;
}
}
\ 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