This commit is contained in:
MaxKey
2022-04-03 08:34:09 +08:00
parent a2740e15de
commit 0586a2a559
22 changed files with 773 additions and 1461 deletions

View File

@@ -117,15 +117,9 @@ public class MaxKeyMgtMvcConfig implements WebMvcConfigurer {
registry.addInterceptor(permissionAdapter)
.addPathPatterns("/dashboard/**")
.addPathPatterns("/orgs/**")
.addPathPatterns("/userinfo/**")
.addPathPatterns("/users/**")
.addPathPatterns("/apps/**")
.addPathPatterns("/app/accounts/**")
.addPathPatterns("/groups/**")
.addPathPatterns("/groupMember/**")
.addPathPatterns("/groupPrivileges/**")
.addPathPatterns("/roles/**")
.addPathPatterns("/rolemembers/**")
.addPathPatterns("/resources/**")
.addPathPatterns("/accounts/**")
.addPathPatterns("/access/**")
.addPathPatterns("/access/**/**")
@@ -139,11 +133,8 @@ public class MaxKeyMgtMvcConfig implements WebMvcConfigurer {
.addPathPatterns("/historys/**")
.addPathPatterns("/historys/**/**")
.addPathPatterns("/socialsprovider/**")
.addPathPatterns("/accountsstrategy/**")
.addPathPatterns("/institutions/**")
.addPathPatterns("/localization/**")
.addPathPatterns("/synchronizers/**")
;

View File

@@ -18,24 +18,24 @@
package org.maxkey.web.access.contorller;
import org.apache.mybatis.jpa.persistence.JpaPageResults;
import org.maxkey.constants.ConstsOperateMessage;
import org.maxkey.authn.annotation.CurrentUser;
import org.maxkey.entity.GroupMember;
import org.maxkey.entity.Groups;
import org.maxkey.entity.Message;
import org.maxkey.entity.UserInfo;
import org.maxkey.persistence.service.GroupMemberService;
import org.maxkey.persistence.service.GroupsService;
import org.maxkey.web.WebContext;
import org.maxkey.web.message.Message;
import org.maxkey.web.message.MessageType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
@Controller
@@ -51,72 +51,46 @@ public class GroupMemberController {
@Qualifier("groupsService")
GroupsService groupsService;
@RequestMapping(value={"/list"})
public ModelAndView groupsList(){
return new ModelAndView("groupuser/groupUsersList");
}
@RequestMapping(value = { "/grid" })
@RequestMapping(value = { "/fetch" }, produces = {MediaType.APPLICATION_JSON_VALUE})
@ResponseBody
public JpaPageResults<GroupMember> grid(@ModelAttribute("groupMember") GroupMember groupMember) {
if(groupMember.getGroupId()==null||groupMember.getGroupId().equals("")){
return null;
}
groupMember.setInstId(WebContext.getUserInfo().getInstId());
return groupMemberService.queryPageResults(groupMember);
public ResponseEntity<?> fetch(
@ModelAttribute GroupMember groupMember,
@CurrentUser UserInfo currentUser) {
_logger.debug("fetch "+groupMember);
groupMember.setInstId(currentUser.getInstId());
return new Message<JpaPageResults<GroupMember>>(
groupMemberService.queryPageResults(groupMember)).buildResponse();
}
@RequestMapping(value = { "/forwardAdd" })
public ModelAndView forwardAdd() {
return new ModelAndView("groups/groupAdd");
}
@RequestMapping(value = { "/forwardUpdate/{id}" })
public ModelAndView forwardUpdate(@PathVariable("id") String id) {
ModelAndView modelAndView=new ModelAndView("groups/groupUpdate");
GroupMember groupMember=groupMemberService.get(id);
modelAndView.addObject("model",groupMember);
return modelAndView;
}
@RequestMapping(value = { "/queryMemberInGroup" })
@RequestMapping(value = { "/memberInGroup" })
@ResponseBody
public JpaPageResults<GroupMember> queryMemberInGroup(@ModelAttribute("groupMember") GroupMember groupMember) {
public ResponseEntity<?> memberInGroup(@ModelAttribute GroupMember groupMember,@CurrentUser UserInfo currentUser) {
_logger.debug("groupMember : "+groupMember);
groupMember.setInstId(WebContext.getUserInfo().getInstId());
groupMember.setInstId(currentUser.getInstId());
if(groupMember.getGroupId()==null||groupMember.getGroupId().equals("")||groupMember.getGroupId().equals("ROLE_ALL_USER")){
return groupMemberService.queryPageResults("allMemberInGroup",groupMember);
return new Message<JpaPageResults<GroupMember>>(
groupMemberService.queryPageResults("allMemberInGroup",groupMember)).buildResponse();
}else{
return groupMemberService.queryPageResults("memberInGroup",groupMember);
return new Message<JpaPageResults<GroupMember>>(
groupMemberService.queryPageResults("memberInGroup",groupMember)).buildResponse();
}
}
@RequestMapping(value={"/addGroupAppsList/{groupId}"})
public ModelAndView addGroupAppsList(@PathVariable("groupId") String groupId){
ModelAndView modelAndView=new ModelAndView("groupuser/addGroupUsersList");
Groups group=groupsService.get(groupId);
modelAndView.addObject("group", group);
return modelAndView;
}
@RequestMapping(value = { "/queryMemberNotInGroup" })
@RequestMapping(value = { "/memberNotInGroup" })
@ResponseBody
public JpaPageResults<GroupMember> queryMemberNotInGroupGrid(@ModelAttribute("groupMember") GroupMember groupMember) {
groupMember.setInstId(WebContext.getUserInfo().getInstId());
return groupMemberService.queryPageResults("memberNotInGroup",groupMember);
public ResponseEntity<?> memberNotInGroup(@ModelAttribute GroupMember groupMember,@CurrentUser UserInfo currentUser) {
groupMember.setInstId(currentUser.getInstId());
return new Message<JpaPageResults<GroupMember>>(
groupMemberService.queryPageResults("memberNotInGroup",groupMember)).buildResponse();
}
@RequestMapping(value = {"/insert"})
@RequestMapping(value = {"/add"})
@ResponseBody
public Message insertGroupUser(@ModelAttribute("groupMember") GroupMember groupMember) {
public ResponseEntity<?> addGroupMember(@ModelAttribute("groupMember") GroupMember groupMember,@CurrentUser UserInfo currentUser) {
if (groupMember == null || groupMember.getGroupId() == null) {
return new Message("传入参数为空",MessageType.error);
return new Message<GroupMember>(Message.FAIL).buildResponse();
}
String groupId = groupMember.getGroupId();
@@ -136,31 +110,25 @@ public class GroupMemberController {
arrMemberIds[i],
arrMemberNames[i],
"USER",
WebContext.getUserInfo().getInstId());
currentUser.getInstId());
newGroupMember.setId(WebContext.genId());
result = groupMemberService.insert(newGroupMember);
}
if(!result) {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_ERROR),MessageType.error);
if(result) {
return new Message<GroupMember>(Message.SUCCESS).buildResponse();
}
}
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_SUCCESS),MessageType.info);
return new Message<GroupMember>(Message.FAIL).buildResponse();
}
@RequestMapping(value = {"/delete"})
@ResponseBody
public Message deleteGroupMember(@ModelAttribute("groupMember") GroupMember groupMember) {
_logger.debug("groupMember : "+groupMember);
if (groupMember == null || groupMember.getId() == null) {
return new Message("传入参数为空",MessageType.error);
@RequestMapping(value={"/delete"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> delete(@RequestParam("ids") String ids,@CurrentUser UserInfo currentUser) {
_logger.debug("-delete ids : {}" , ids);
if (groupMemberService.deleteBatch(ids)) {
return new Message<GroupMember>(Message.SUCCESS).buildResponse();
} else {
return new Message<GroupMember>(Message.FAIL).buildResponse();
}
if(groupMemberService.deleteBatch(groupMember.getId())) {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_SUCCESS),MessageType.info);
}
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_ERROR),MessageType.error);
}
}

View File

@@ -14,28 +14,26 @@
* limitations under the License.
*/
package org.maxkey.web.access.contorller;
import org.apache.mybatis.jpa.persistence.JpaPageResults;
import org.maxkey.constants.ConstsOperateMessage;
import org.maxkey.authn.annotation.CurrentUser;
import org.maxkey.entity.GroupPrivileges;
import org.maxkey.entity.Message;
import org.maxkey.entity.UserInfo;
import org.maxkey.entity.apps.Apps;
import org.maxkey.persistence.service.GroupPrivilegesService;
import org.maxkey.web.WebContext;
import org.maxkey.web.message.Message;
import org.maxkey.web.message.MessageType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping(value={"/access/privileges"})
@@ -43,100 +41,78 @@ public class GroupPrivilegesController {
final static Logger _logger = LoggerFactory.getLogger(GroupPrivilegesController.class);
@Autowired
@Qualifier("groupPrivilegesService")
GroupPrivilegesService groupPrivilegesService;
@RequestMapping(value={"/list"})
public ModelAndView groupsList(){
return new ModelAndView("groupapp/groupAppsList");
}
@RequestMapping(value = { "/queryAppsInGroup" })
@RequestMapping(value = { "/appsInGroup" })
@ResponseBody
public JpaPageResults<GroupPrivileges> queryAppsInGroup(@ModelAttribute("groupApp") GroupPrivileges groupApp) {
public ResponseEntity<?> appsInGroup(
@ModelAttribute GroupPrivileges groupPrivilege,
@CurrentUser UserInfo currentUser) {
JpaPageResults<GroupPrivileges> groupPrivileges;
groupApp.setInstId(WebContext.getUserInfo().getInstId());
groupPrivileges= groupPrivilegesService.queryPageResults("appsInGroup",groupApp);
groupPrivilege.setInstId(currentUser.getInstId());
groupPrivileges= groupPrivilegesService.queryPageResults("appsInGroup",groupPrivilege);
if(groupPrivileges!=null&&groupPrivileges.getRows()!=null){
for (Apps app : groupPrivileges.getRows()){
app.transIconBase64();
}
}
return groupPrivileges;
return new Message<JpaPageResults<GroupPrivileges>>(Message.FAIL,groupPrivileges).buildResponse();
}
@RequestMapping(value={"/addGroupAppsList/{groupId}"})
public ModelAndView appsNotInGroupList(@PathVariable("groupId") String groupId){
ModelAndView modelAndView=new ModelAndView("groupapp/addGroupAppsList");
modelAndView.addObject("groupId", groupId);
return modelAndView;
}
@RequestMapping(value = { "/queryAppsNotInGroup" })
@RequestMapping(value = { "/appsNotInGroup" })
@ResponseBody
public JpaPageResults<GroupPrivileges> queryAppsNotInGroup(@ModelAttribute("groupApp") GroupPrivileges groupApp) {
public ResponseEntity<?> appsNotInGroup(
@ModelAttribute GroupPrivileges groupPrivilege,
@CurrentUser UserInfo currentUser) {
JpaPageResults<GroupPrivileges> groupPrivileges;
groupApp.setInstId(WebContext.getUserInfo().getInstId());
groupPrivileges= groupPrivilegesService.queryPageResults("appsNotInGroup",groupApp);
groupPrivilege.setInstId(currentUser.getInstId());
groupPrivileges= groupPrivilegesService.queryPageResults("appsNotInGroup",groupPrivilege);
if(groupPrivileges!=null&&groupPrivileges.getRows()!=null){
for (Apps app : groupPrivileges.getRows()){
app.transIconBase64();
}
}
return groupPrivileges;
return new Message<JpaPageResults<GroupPrivileges>>(Message.FAIL,groupPrivileges).buildResponse();
}
@RequestMapping(value = {"/insert"})
@RequestMapping(value = {"/add"})
@ResponseBody
public Message insertGroupApp(@ModelAttribute("groupApp") GroupPrivileges groupApp) {
if (groupApp == null || groupApp.getGroupId() == null) {
return new Message("传入参数为空",MessageType.error);
public ResponseEntity<?> insertGroupApp(
@ModelAttribute GroupPrivileges groupPrivileges,
@CurrentUser UserInfo currentUser) {
if (groupPrivileges == null || groupPrivileges.getGroupId() == null) {
return new Message<GroupPrivileges>(Message.FAIL).buildResponse();
}
String groupId = groupApp.getGroupId();
String groupId = groupPrivileges.getGroupId();
boolean result = true;
String appIds = groupApp.getAppId();
String appIds = groupPrivileges.getAppId();
if (appIds != null) {
String[] arrAppIds = appIds.split(",");
for (int i = 0; i < arrAppIds.length; i++) {
GroupPrivileges newGroupApp =
new GroupPrivileges(groupId, arrAppIds[i],WebContext.getUserInfo().getInstId());
newGroupApp.setId(WebContext.genId());
result = groupPrivilegesService.insert(newGroupApp);
GroupPrivileges newGroupPrivilege =
new GroupPrivileges(groupId, arrAppIds[i],currentUser.getInstId());
newGroupPrivilege.setId(WebContext.genId());
result = groupPrivilegesService.insert(newGroupPrivilege);
}
if(!result) {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_ERROR),MessageType.error);
if(result) {
return new Message<GroupPrivileges>(Message.SUCCESS).buildResponse();
}
}
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_SUCCESS),MessageType.info);
return new Message<GroupPrivileges>(Message.FAIL).buildResponse();
}
@RequestMapping(value = {"/delete"})
@ResponseBody
public Message deleteGroupApp(@ModelAttribute("groupApp") GroupPrivileges groupApp) {
if (groupApp == null || groupApp.getId() == null) {
return new Message("传入参数为空",MessageType.error);
@RequestMapping(value={"/delete"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> delete(@RequestParam("ids") String ids,@CurrentUser UserInfo currentUser) {
_logger.debug("-delete ids : {}" , ids);
if (groupPrivilegesService.deleteBatch(ids)) {
return new Message<GroupPrivileges>(Message.SUCCESS).buildResponse();
} else {
return new Message<GroupPrivileges>(Message.FAIL).buildResponse();
}
if(groupPrivilegesService.deleteBatch(groupApp.getId())) {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_SUCCESS),MessageType.info);
}
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_ERROR),MessageType.error);
}
}

View File

@@ -19,24 +19,24 @@ package org.maxkey.web.apps.contorller;
import org.apache.mybatis.jpa.persistence.JpaPageResults;
import org.maxkey.constants.ConstsOperateMessage;
import org.maxkey.authn.annotation.CurrentUser;
import org.maxkey.crypto.ReciprocalUtils;
import org.maxkey.entity.ExtraAttr;
import org.maxkey.entity.ExtraAttrs;
import org.maxkey.entity.Message;
import org.maxkey.entity.UserInfo;
import org.maxkey.entity.apps.Apps;
import org.maxkey.web.WebContext;
import org.maxkey.web.message.Message;
import org.maxkey.web.message.MessageType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.nimbusds.jose.JOSEException;
import com.nimbusds.jose.JWEAlgorithm;
import com.nimbusds.jose.JWSAlgorithm;
@@ -53,68 +53,82 @@ import com.nimbusds.jose.jwk.gen.RSAKeyGenerator;
public class ApplicationsController extends BaseAppContorller {
final static Logger _logger = LoggerFactory.getLogger(ApplicationsController.class);
@RequestMapping(value={"/list"})
public ModelAndView applicationsList(){
return new ModelAndView("apps/appsList");
}
@RequestMapping(value={"/select"})
public ModelAndView select(@RequestParam(name="accountMgmt",required=false) String accountMgmt){
ModelAndView modelAndView=new ModelAndView("apps/selectAppsList");
if(accountMgmt != null) {
modelAndView.addObject("accountMgmt", accountMgmt);
}else {
modelAndView.addObject("accountMgmt", 3);
}
return modelAndView;
}
@RequestMapping(value = { "/grid" })
@RequestMapping(value = { "/fetch" }, produces = {MediaType.APPLICATION_JSON_VALUE})
@ResponseBody
public JpaPageResults<Apps> queryDataGrid(@ModelAttribute("applications") Apps applications) {
applications.setInstId(WebContext.getUserInfo().getInstId());
JpaPageResults<Apps> apps=appsService.queryPageResults(applications);
if(apps!=null&&apps.getRows()!=null){
for (Apps app : apps.getRows()){
app.transIconBase64();
}
public ResponseEntity<?> fetch(@ModelAttribute Apps apps,@CurrentUser UserInfo currentUser) {
apps.setInstId(currentUser.getInstId());
JpaPageResults<Apps> appsList =appsService.queryPageResults(apps);
for (Apps app : appsList.getRows()){
app.transIconBase64();
}
return apps;
_logger.debug("List "+appsList);
return new Message<JpaPageResults<Apps>>(appsList).buildResponse();
}
@RequestMapping(value = { "/forwardAdd" })
public ModelAndView forwardAdd() {
return new ModelAndView("apps/appAdd");
}
@ResponseBody
@RequestMapping(value={"/add"})
public Message insert(@ModelAttribute("application") Apps application) {
_logger.debug("-Add :" + application);
transform(application);
application.setInstId(WebContext.getUserInfo().getInstId());
if (appsService.insert(application)) {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_SUCCESS),MessageType.success);
@RequestMapping(value={"/query"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> query(@ModelAttribute Apps apps,@CurrentUser UserInfo currentUser) {
_logger.debug("-query :" + apps);
if (appsService.load(apps)!=null) {
return new Message<Apps>(Message.SUCCESS).buildResponse();
} else {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_SUCCESS),MessageType.error);
return new Message<Apps>(Message.SUCCESS).buildResponse();
}
}
@RequestMapping(value = { "/get/{id}" }, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> get(@PathVariable("id") String id) {
Apps apps = appsService.get(id);
return new Message<Apps>(apps).buildResponse();
}
@ResponseBody
@RequestMapping(value={"/add"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> insert(@RequestBody Apps apps,@CurrentUser UserInfo currentUser) {
_logger.debug("-Add :" + apps);
transform(apps);
apps.setInstId(currentUser.getInstId());
if (appsService.insert(apps)) {
return new Message<Apps>(Message.SUCCESS).buildResponse();
} else {
return new Message<Apps>(Message.FAIL).buildResponse();
}
}
@ResponseBody
@RequestMapping(value={"/update"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> update(@RequestBody Apps apps,@CurrentUser UserInfo currentUser) {
_logger.debug("-update :" + apps);
transform(apps);
apps.setInstId(currentUser.getInstId());
if (appsService.update(apps)) {
return new Message<Apps>(Message.SUCCESS).buildResponse();
} else {
return new Message<Apps>(Message.FAIL).buildResponse();
}
}
@ResponseBody
@RequestMapping(value={"/delete"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> delete(@RequestParam("ids") String ids,@CurrentUser UserInfo currentUser) {
_logger.debug("-delete ids : {} " , ids);
if (appsService.deleteBatch(ids)) {
return new Message<Apps>(Message.SUCCESS).buildResponse();
} else {
return new Message<Apps>(Message.FAIL).buildResponse();
}
}
@RequestMapping(value = { "/forwardAppsExtendAttr/{id}" })
public ModelAndView forwardExtendAttr(@PathVariable("id") String id) {
ModelAndView modelAndView=new ModelAndView("apps/appsExtendAttr");
modelAndView.addObject("model",appsService.get(id));
return modelAndView;
public ResponseEntity<?> forwardExtendAttr(@PathVariable("id") String id) {
Apps apps = appsService.get(id);
return new Message<Apps>(apps).buildResponse();
}
@ResponseBody
@RequestMapping(value = { "/updateExtendAttr" })
public Message updateExtendAttr(@ModelAttribute("application") Apps application,@ModelAttribute("extraAttrs") ExtraAttr extraAttr) {
public ResponseEntity<?> updateExtendAttr(@ModelAttribute("application") Apps application,@ModelAttribute("extraAttrs") ExtraAttr extraAttr) {
if(extraAttr.getAttr()!=null){
String []attributes=extraAttr.getAttr().split(",");
String []attributeType=extraAttr.getType().split(",");
@@ -127,67 +141,16 @@ public class ApplicationsController extends BaseAppContorller {
}
if (appsService.updateExtendAttr(application)) {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_SUCCESS),MessageType.success);
return new Message<Apps>(Message.SUCCESS).buildResponse();
} else {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_ERROR),MessageType.error);
return new Message<Apps>(Message.FAIL).buildResponse();
}
}
/**
* query
* @param application
* @return
*/
@ResponseBody
@RequestMapping(value={"/query"})
public Message query(@ModelAttribute("application") Apps application) {
_logger.debug("-query :" + application);
if (appsService.load(application)!=null) {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_SUCCESS),MessageType.success);
} else {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_ERROR),MessageType.error);
}
}
/**
* modify
* @param application
* @return
*/
@ResponseBody
@RequestMapping(value={"/update"})
public Message update(@ModelAttribute("application") Apps application) {
_logger.debug("-update application :" + application);
application.setInstId(WebContext.getUserInfo().getInstId());
if (appsService.update(application)) {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_SUCCESS),MessageType.success);
} else {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_ERROR),MessageType.error);
}
}
@ResponseBody
@RequestMapping(value={"/delete"})
public Message delete(@ModelAttribute("application") Apps application) {
_logger.debug("-delete application :" + application);
if (appsService.deleteBatch(application.getId())) {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.DELETE_SUCCESS),MessageType.success);
} else {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.DELETE_SUCCESS),MessageType.error);
}
}
@ResponseBody
@RequestMapping(value = { "/generate/secret/{type}" })
public String generateSecret(@PathVariable("type") String type,@RequestParam(name="id",required=false) String id) throws JOSEException {
public ResponseEntity<?> generateSecret(@PathVariable("type") String type,@RequestParam(name="id",required=false) String id) throws JOSEException {
String secret="";
type=type.toLowerCase();
if(type.equals("des")){
@@ -242,7 +205,7 @@ public class ApplicationsController extends BaseAppContorller {
secret=ReciprocalUtils.generateKey("");
}
return secret;
return new Message<Object>(Message.SUCCESS,(Object)secret).buildResponse();
}

View File

@@ -18,144 +18,99 @@
package org.maxkey.web.config.contorller;
import org.apache.mybatis.jpa.persistence.JpaPageResults;
import org.maxkey.constants.ConstsOperateMessage;
import org.maxkey.authn.annotation.CurrentUser;
import org.maxkey.entity.AccountsStrategy;
import org.maxkey.entity.Roles;
import org.maxkey.entity.Message;
import org.maxkey.entity.UserInfo;
import org.maxkey.persistence.service.AccountsService;
import org.maxkey.persistence.service.AccountsStrategyService;
import org.maxkey.web.WebContext;
import org.maxkey.web.message.Message;
import org.maxkey.web.message.MessageType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping(value={"/accountsstrategy"})
@RequestMapping(value={"/config/accountsstrategy"})
public class AccountsStrategyController {
final static Logger _logger = LoggerFactory.getLogger(AccountsStrategyController.class);
@Autowired
@Qualifier("accountsStrategyService")
AccountsStrategyService accountsStrategyService;
@Autowired
AccountsService accountsService;
@RequestMapping(value={"/list"})
public ModelAndView rolesList(){
return new ModelAndView("accountsstrategy/accountsStrategyList");
}
@RequestMapping(value={"/select"})
public ModelAndView selectAccountsStrategyList(){
return new ModelAndView("accountsstrategy/selectAccountsStrategy");
}
@RequestMapping(value = { "/grid" })
@RequestMapping(value = { "/fetch" }, produces = {MediaType.APPLICATION_JSON_VALUE})
@ResponseBody
public JpaPageResults<AccountsStrategy> queryDataGrid(@ModelAttribute("accountsStrategy") AccountsStrategy accountsStrategy) {
_logger.debug(""+accountsStrategy);
accountsStrategy.setInstId(WebContext.getUserInfo().getInstId());
public ResponseEntity<?> fetch(@ModelAttribute AccountsStrategy accountsStrategy,@CurrentUser UserInfo currentUser) {
accountsStrategy.setInstId(currentUser.getInstId());
JpaPageResults<AccountsStrategy> accountsStrategyList =accountsStrategyService.queryPageResults(accountsStrategy);
for (AccountsStrategy strategy : accountsStrategyList.getRows()){
WebContext.setAttribute(strategy.getId(), strategy.getAppIcon());
strategy.transIconBase64();
}
return accountsStrategyList;
_logger.debug("Accounts Strategy "+accountsStrategyList);
return new Message<JpaPageResults<AccountsStrategy>>(
accountsStrategyList).buildResponse();
}
@RequestMapping(value = { "/forwardAdd" })
public ModelAndView forwardAdd() {
return new ModelAndView("accountsstrategy/accountsStrategyAdd");
}
@RequestMapping(value = { "/forwardUpdate/{id}" })
public ModelAndView forwardUpdate(@PathVariable("id") String id) {
ModelAndView modelAndView=new ModelAndView("accountsstrategy/accountsStrategyUpdate");
AccountsStrategy accountsStrategy=accountsStrategyService.get(id);
modelAndView.addObject("model",accountsStrategy);
return modelAndView;
}
@ResponseBody
@RequestMapping(value={"/add"})
public Message insert(@ModelAttribute("accountsStrategy") AccountsStrategy accountsStrategy) {
_logger.debug("-Add :" + accountsStrategy);
accountsStrategy.setInstId(WebContext.getUserInfo().getInstId());
if (accountsStrategyService.insert(accountsStrategy)) {
accountsService.refreshByStrategy(accountsStrategy);
//rolesService.refreshDynamicRoles(role);
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_SUCCESS),MessageType.success);
} else {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_SUCCESS),MessageType.error);
}
}
/**
* 查询
* @param role
* @return
*/
@ResponseBody
@RequestMapping(value={"/query"})
public Message query(@ModelAttribute("accountsStrategy") AccountsStrategy accountsStrategy) {
@RequestMapping(value={"/query"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> query(@ModelAttribute AccountsStrategy accountsStrategy,@CurrentUser UserInfo currentUser) {
_logger.debug("-query :" + accountsStrategy);
accountsStrategy.setInstId(WebContext.getUserInfo().getInstId());
if (accountsStrategyService.load(accountsStrategy)!=null) {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_SUCCESS),MessageType.success);
return new Message<AccountsStrategy>(Message.SUCCESS).buildResponse();
} else {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_ERROR),MessageType.error);
return new Message<AccountsStrategy>(Message.SUCCESS).buildResponse();
}
}
/**
* 修改
* @param role
* @return
*/
@RequestMapping(value = { "/get/{id}" }, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> get(@PathVariable("id") String id) {
AccountsStrategy accountsStrategy = accountsStrategyService.get(id);
return new Message<AccountsStrategy>(accountsStrategy).buildResponse();
}
@ResponseBody
@RequestMapping(value={"/update"})
public Message update(@ModelAttribute("accountsStrategy") AccountsStrategy accountsStrategy) {
_logger.debug("-update AccountsStrategy :" + accountsStrategy);
accountsStrategy.setInstId(WebContext.getUserInfo().getInstId());
@RequestMapping(value={"/add"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> insert(@RequestBody AccountsStrategy accountsStrategy,@CurrentUser UserInfo currentUser) {
_logger.debug("-Add :" + accountsStrategy);
if (accountsStrategyService.insert(accountsStrategy)) {
accountsService.refreshByStrategy(accountsStrategy);
return new Message<AccountsStrategy>(Message.SUCCESS).buildResponse();
} else {
return new Message<AccountsStrategy>(Message.FAIL).buildResponse();
}
}
@ResponseBody
@RequestMapping(value={"/update"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> update(@RequestBody AccountsStrategy accountsStrategy,@CurrentUser UserInfo currentUser) {
_logger.debug("-update :" + accountsStrategy);
if (accountsStrategyService.update(accountsStrategy)) {
// rolesService.refreshDynamicRoles(role);
accountsService.refreshByStrategy(accountsStrategy);
return new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_SUCCESS),MessageType.success);
accountsService.refreshByStrategy(accountsStrategy);
return new Message<AccountsStrategy>(Message.SUCCESS).buildResponse();
} else {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_ERROR),MessageType.error);
return new Message<AccountsStrategy>(Message.FAIL).buildResponse();
}
}
@ResponseBody
@RequestMapping(value={"/delete"})
public Message delete(@ModelAttribute("role") Roles role) {
_logger.debug("-delete role :" + role);
if (accountsStrategyService.deleteById(role.getId())) {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.DELETE_SUCCESS),MessageType.success);
@RequestMapping(value={"/delete"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> delete(@RequestParam("ids") String ids,@CurrentUser UserInfo currentUser) {
_logger.debug("-delete ids : {} " , ids);
if (accountsStrategyService.deleteBatch(ids)) {
return new Message<AccountsStrategy>(Message.SUCCESS).buildResponse();
} else {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.DELETE_SUCCESS),MessageType.error);
return new Message<AccountsStrategy>(Message.FAIL).buildResponse();
}
}
}

View File

@@ -18,23 +18,23 @@
package org.maxkey.web.config.contorller;
import org.apache.mybatis.jpa.persistence.JpaPageResults;
import org.maxkey.constants.ConstsOperateMessage;
import org.maxkey.authn.annotation.CurrentUser;
import org.maxkey.entity.Message;
import org.maxkey.entity.Notices;
import org.maxkey.entity.UserInfo;
import org.maxkey.persistence.service.NoticesService;
import org.maxkey.web.WebContext;
import org.maxkey.web.message.Message;
import org.maxkey.web.message.MessageType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping(value={"/notices"})
@@ -42,101 +42,66 @@ public class NoticesController {
final static Logger _logger = LoggerFactory.getLogger(NoticesController.class);
@Autowired
@Qualifier("noticesService")
NoticesService noticesService;
@RequestMapping(value={"/list"})
public ModelAndView noticesList(){
return new ModelAndView("notices/noticesList");
}
@RequestMapping(value = { "/grid" })
@RequestMapping(value = { "/fetch" }, produces = {MediaType.APPLICATION_JSON_VALUE})
@ResponseBody
public JpaPageResults<Notices> queryDataGrid(@ModelAttribute("notices") Notices notice) {
public ResponseEntity<?> fetch(@ModelAttribute Notices notice,@CurrentUser UserInfo currentUser) {
_logger.debug(""+notice);
notice.setInstId(WebContext.getUserInfo().getInstId());
return noticesService.queryPageResults(notice);
notice.setInstId(currentUser.getInstId());
return new Message<JpaPageResults<Notices>>(
noticesService.queryPageResults(notice)).buildResponse();
}
@RequestMapping(value = { "/forwardAdd" })
public ModelAndView forwardAdd() {
return new ModelAndView("notices/noticeAdd");
}
@RequestMapping(value = { "/forwardUpdate/{id}" })
public ModelAndView forwardUpdate(@PathVariable("id") String id) {
ModelAndView modelAndView=new ModelAndView("notices/noticeUpdate");
Notices notice=noticesService.get(id);
modelAndView.addObject("model",notice);
return modelAndView;
}
@ResponseBody
@RequestMapping(value={"/add"})
public Message insert(@ModelAttribute("notice")Notices notice) {
_logger.debug("-Add :" + notice);
notice.setInstId(WebContext.getUserInfo().getInstId());
if (noticesService.insert(notice)) {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_SUCCESS),MessageType.success);
} else {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_SUCCESS),MessageType.error);
}
}
/**
* 查询
* @param role
* @return
*/
@ResponseBody
@RequestMapping(value={"/query"})
public Message query(@ModelAttribute("notice")Notices notice) {
@RequestMapping(value={"/query"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> query(@ModelAttribute Notices notice,@CurrentUser UserInfo currentUser) {
_logger.debug("-query :" + notice);
notice.setInstId(WebContext.getUserInfo().getInstId());
if (noticesService.load(notice)!=null) {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_SUCCESS),MessageType.success);
return new Message<Notices>(Message.SUCCESS).buildResponse();
} else {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_ERROR),MessageType.error);
return new Message<Notices>(Message.SUCCESS).buildResponse();
}
}
/**
* 修改
* @param role
* @return
*/
@RequestMapping(value = { "/get/{id}" }, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> get(@PathVariable("id") String id) {
Notices notice=noticesService.get(id);
return new Message<Notices>(notice).buildResponse();
}
@ResponseBody
@RequestMapping(value={"/update"})
public Message update(@ModelAttribute("notice")Notices notice) {
_logger.debug("-update notice :" + notice);
notice.setInstId(WebContext.getUserInfo().getInstId());
@RequestMapping(value={"/add"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> insert(@RequestBody Notices notice,@CurrentUser UserInfo currentUser) {
_logger.debug("-Add :" + notice);
if (noticesService.insert(notice)) {
return new Message<Notices>(Message.SUCCESS).buildResponse();
} else {
return new Message<Notices>(Message.FAIL).buildResponse();
}
}
@ResponseBody
@RequestMapping(value={"/update"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> update(@RequestBody Notices notice,@CurrentUser UserInfo currentUser) {
_logger.debug("-update :" + notice);
if (noticesService.update(notice)) {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_SUCCESS),MessageType.success);
return new Message<Notices>(Message.SUCCESS).buildResponse();
} else {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_ERROR),MessageType.error);
return new Message<Notices>(Message.FAIL).buildResponse();
}
}
@ResponseBody
@RequestMapping(value={"/delete"})
public Message delete(@ModelAttribute("notice")Notices notice) {
_logger.debug("-delete notice :" + notice);
if (noticesService.deleteBatch(notice.getId())) {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.DELETE_SUCCESS),MessageType.success);
@RequestMapping(value={"/delete"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> delete(@RequestParam("ids") String ids,@CurrentUser UserInfo currentUser) {
_logger.debug("-delete ids : {} " , ids);
if (noticesService.deleteBatch(ids)) {
return new Message<Notices>(Message.SUCCESS).buildResponse();
} else {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.DELETE_SUCCESS),MessageType.error);
return new Message<Notices>(Message.FAIL).buildResponse();
}
}
}

View File

@@ -79,8 +79,8 @@ public class SynchronizersController {
}
@ResponseBody
@RequestMapping(value={"/sync"})
public ResponseEntity<?> sync(@RequestParam("id") String id) {
@RequestMapping(value={"/synchr"})
public ResponseEntity<?> synchr(@RequestParam("id") String id) {
_logger.debug("-sync ids :" + id);
List<String> ids = StringUtils.string2List(id, ",");

View File

@@ -18,28 +18,28 @@
package org.maxkey.web.contorller;
import org.apache.mybatis.jpa.persistence.JpaPageResults;
import org.maxkey.constants.ConstsOperateMessage;
import org.maxkey.authn.annotation.CurrentUser;
import org.maxkey.crypto.password.PasswordReciprocal;
import org.maxkey.entity.Accounts;
import org.maxkey.entity.AccountsStrategy;
import org.maxkey.entity.Message;
import org.maxkey.entity.UserInfo;
import org.maxkey.persistence.service.AccountsService;
import org.maxkey.persistence.service.AccountsStrategyService;
import org.maxkey.persistence.service.AppsService;
import org.maxkey.persistence.service.UserInfoService;
import org.maxkey.web.WebContext;
import org.maxkey.web.message.Message;
import org.maxkey.web.message.MessageType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
@Controller
@@ -48,114 +48,89 @@ public class AccountsController {
final static Logger _logger = LoggerFactory.getLogger(AccountsController.class);
@Autowired
@Qualifier("accountsService")
AccountsService accountsService;
@Autowired
@Qualifier("accountsStrategyService")
AccountsStrategyService accountsStrategyService;
@Autowired
@Qualifier("appsService")
protected AppsService appsService;
AppsService appsService;
@Autowired
@Qualifier("userInfoService")
private UserInfoService userInfoService;
UserInfoService userInfoService;
@RequestMapping(value={"/list"})
public ModelAndView appAccountsList(){
ModelAndView modelAndView=new ModelAndView("/accounts/accountsList");
return modelAndView;
@RequestMapping(value = { "/fetch" }, produces = {MediaType.APPLICATION_JSON_VALUE})
@ResponseBody
public ResponseEntity<?> fetch(@ModelAttribute Accounts accounts,@CurrentUser UserInfo currentUser) {
_logger.debug(""+accounts);
accounts.setInstId(currentUser.getInstId());
return new Message<JpaPageResults<Accounts>>(
accountsService.queryPageResults(accounts)).buildResponse();
}
@RequestMapping(value={"/grid"})
@ResponseBody
public JpaPageResults<Accounts> grid(@ModelAttribute("appAccounts") Accounts appAccounts){
appAccounts.setInstId(WebContext.getUserInfo().getInstId());
return accountsService.queryPageResults(appAccounts);
}
@RequestMapping(value = { "/forwardSelect/{appId}" })
public ModelAndView forwardSelect(@PathVariable("appId") String appId) {
ModelAndView modelAndView=new ModelAndView("/accounts/accountsAddSelect");
modelAndView.addObject("appId",appId);
return modelAndView;
}
@RequestMapping(value = { "/forwardAdd" })
public ModelAndView forwardAdd(@ModelAttribute("appAccounts") Accounts appAccounts) {
ModelAndView modelAndView=new ModelAndView("/accounts/accountsAdd");
//Applications app= appsService.get(appAccounts.getAppId());
//appAccounts.setAppName(app.getName());
modelAndView.addObject("model",appAccounts);
return modelAndView;
}
/**
*
* @param group
* @return
*/
@ResponseBody
@RequestMapping(value={"/add"})
public Message add(@ModelAttribute("appAccounts") Accounts appAccounts ) {
_logger.debug("-update :" + appAccounts);
appAccounts.setInstId(WebContext.getUserInfo().getInstId());
appAccounts.setRelatedPassword(PasswordReciprocal.getInstance().encode(appAccounts.getRelatedPassword()));
accountsService.insert(appAccounts);
return new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_SUCCESS),MessageType.success);
}
@RequestMapping(value = { "/forwardUpdate/{id}" })
public ModelAndView forwardUpdate(@PathVariable("id") String id) {
ModelAndView modelAndView=new ModelAndView("/accounts/accountsUpdate");
Accounts appAccounts =accountsService.get(id);
appAccounts.setRelatedPassword(PasswordReciprocal.getInstance().decoder(appAccounts.getRelatedPassword()));
modelAndView.addObject("model",appAccounts);
return modelAndView;
@RequestMapping(value={"/query"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> query(@ModelAttribute Accounts account,@CurrentUser UserInfo currentUser) {
_logger.debug("-query :" + account);
account.setInstId(currentUser.getInstId());
if (accountsService.load(account)!=null) {
return new Message<Accounts>(Message.SUCCESS).buildResponse();
} else {
return new Message<Accounts>(Message.SUCCESS).buildResponse();
}
}
/**
*
* @param group
* @return
*/
@ResponseBody
@RequestMapping(value={"/update"})
public Message update(@ModelAttribute("appAccounts") Accounts appAccounts ) {
_logger.debug("-update :" + appAccounts);
appAccounts.setInstId(WebContext.getUserInfo().getInstId());
appAccounts.setRelatedPassword(PasswordReciprocal.getInstance().encode(appAccounts.getRelatedPassword()));
accountsService.update(appAccounts);
return new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_SUCCESS),MessageType.success);
@RequestMapping(value = { "/get/{id}" }, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> get(@PathVariable("id") String id) {
Accounts account=accountsService.get(id);
return new Message<Accounts>(account).buildResponse();
}
@ResponseBody
@RequestMapping(value={"/delete"})
public Message delete(@ModelAttribute("appAccounts") Accounts appAccounts ) {
_logger.debug("-delete AppAccounts :" + appAccounts);
accountsService.deleteBatch(appAccounts.getId());
return new Message(WebContext.getI18nValue(ConstsOperateMessage.DELETE_SUCCESS),MessageType.success);
@RequestMapping(value={"/add"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> insert(@RequestBody Accounts account,@CurrentUser UserInfo currentUser) {
_logger.debug("-Add :" + account);
account.setInstId(currentUser.getInstId());
account.setRelatedPassword(PasswordReciprocal.getInstance().encode(account.getRelatedPassword()));
if (accountsService.insert(account)) {
return new Message<Accounts>(Message.SUCCESS).buildResponse();
} else {
return new Message<Accounts>(Message.FAIL).buildResponse();
}
}
@ResponseBody
@RequestMapping(value={"/update"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> update(@RequestBody Accounts account,@CurrentUser UserInfo currentUser) {
_logger.debug("-update :" + account);
account.setInstId(currentUser.getInstId());
account.setRelatedPassword(PasswordReciprocal.getInstance().encode(account.getRelatedPassword()));
if (accountsService.update(account)) {
return new Message<Accounts>(Message.SUCCESS).buildResponse();
} else {
return new Message<Accounts>(Message.FAIL).buildResponse();
}
}
@ResponseBody
@RequestMapping(value={"/delete"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> delete(@RequestParam("ids") String ids,@CurrentUser UserInfo currentUser) {
_logger.debug("-delete ids : {} " , ids);
if (accountsService.deleteBatch(ids)) {
return new Message<Accounts>(Message.SUCCESS).buildResponse();
} else {
return new Message<Accounts>(Message.FAIL).buildResponse();
}
}
@ResponseBody
@RequestMapping(value = "/generate")
public String generate(@ModelAttribute("appAccounts") Accounts appAccounts) {
AccountsStrategy accountsStrategy = accountsStrategyService.get(appAccounts.getStrategyId());
UserInfo userInfo = userInfoService.get(appAccounts.getUserId());
public String generate(@ModelAttribute Accounts account) {
AccountsStrategy accountsStrategy = accountsStrategyService.get(account.getStrategyId());
UserInfo userInfo = userInfoService.get(account.getUserId());
return accountsService.generateAccount(userInfo,accountsStrategy);
}
}

View File

@@ -20,7 +20,6 @@ package org.maxkey.web.contorller;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.TreeSet;
import java.util.stream.Collectors;
@@ -29,30 +28,29 @@ import org.apache.mybatis.jpa.persistence.JpaPageResults;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.maxkey.constants.ConstsOperateMessage;
import org.maxkey.authn.annotation.CurrentUser;
import org.maxkey.entity.ExcelImport;
import org.maxkey.entity.Message;
import org.maxkey.entity.Organizations;
import org.maxkey.entity.UserInfo;
import org.maxkey.persistence.service.OrganizationsService;
import org.maxkey.util.ExcelUtils;
import org.maxkey.web.WebContext;
import org.maxkey.web.component.TreeAttributes;
import org.maxkey.web.component.TreeNode;
import org.maxkey.web.component.TreeNodeList;
import org.maxkey.web.message.Message;
import org.maxkey.web.message.MessageScope;
import org.maxkey.web.message.MessageType;
import org.maxkey.web.message.OperateType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.google.common.collect.Lists;
@@ -61,132 +59,109 @@ import com.google.common.collect.Lists;
public class OrganizationsController {
static final Logger _logger = LoggerFactory.getLogger(OrganizationsController.class);
@Autowired
OrganizationsService organizationsService;
@Autowired
OrganizationsService organizationsService;
@ResponseBody
@RequestMapping({"/tree"})
public List<HashMap<String, Object>> organizationsTree(@RequestParam(value = "id", required = false) String id) {
_logger.debug("organizationsTree id :" + id);
Organizations queryOrg = new Organizations();
queryOrg.setInstId(WebContext.getUserInfo().getInstId());
List<Organizations> organizationsList = this.organizationsService.queryOrgs(queryOrg);
TreeNodeList treeNodeList = new TreeNodeList();
for (Organizations org : organizationsList) {
TreeNode treeNode = new TreeNode(org.getId(), org.getName());
if (org.getHasChild() != null && org.getHasChild().startsWith("Y")) {
treeNode.setHasChild();
}
treeNode.setAttr("data", org);
treeNode.setPId(org.getParentId());
if (org.getId().equals("1")) {
treeNode.setAttr("open", Boolean.valueOf(true));
} else {
treeNode.setAttr("open", Boolean.valueOf(false));
}
treeNodeList.addTreeNode(treeNode.getAttr());
}
return treeNodeList.getTreeNodeList();
}
@RequestMapping({ "/list" })
public ModelAndView orgsTreeList() {
return new ModelAndView("orgs/orgsList");
}
@RequestMapping(value = { "/pageresults" })
@RequestMapping(value = { "/fetch" }, produces = {MediaType.APPLICATION_JSON_VALUE})
@ResponseBody
public JpaPageResults<Organizations> pageResults(@ModelAttribute("orgs") Organizations orgs) {
orgs.setInstId(WebContext.getUserInfo().getInstId());
return organizationsService.queryPageResults(orgs);
public ResponseEntity<?> fetch(@ModelAttribute Organizations org,@CurrentUser UserInfo currentUser) {
_logger.debug("fetch {}" , org);
org.setInstId(currentUser.getInstId());
return new Message<JpaPageResults<Organizations>>(
organizationsService.queryPageResults(org)).buildResponse();
}
@RequestMapping({"/orgsSelect/{deptId}/{department}"})
public ModelAndView orgsSelect(@PathVariable("deptId") String deptId, @PathVariable("department") String department) {
ModelAndView modelAndView = new ModelAndView("orgs/orgsSelect");
modelAndView.addObject("deptId", deptId);
modelAndView.addObject("department", department);
return modelAndView;
}
@RequestMapping(value = { "/forwardAdd" })
public ModelAndView forwardAdd(@ModelAttribute("org") Organizations org) {
ModelAndView modelAndView=new ModelAndView("/orgs/orgsAdd");
org =organizationsService.get(org.getId());
modelAndView.addObject("model",org);
return modelAndView;
}
@ResponseBody
@RequestMapping({"/add"})
public Message insert(@ModelAttribute("org") Organizations org) {
_logger.debug("-Add :" + org);
if (null == org.getId() || org.getId().equals("")) {
org.generateId();
}
org.setInstId(WebContext.getUserInfo().getInstId());
if (this.organizationsService.insert(org)) {
return new Message(WebContext.getI18nValue("message.action.insert.success"), MessageType.success);
}
return new Message(WebContext.getI18nValue("message.action.insert.success"), MessageType.error);
}
@ResponseBody
@RequestMapping({"/query"})
public Message query(@ModelAttribute("org") Organizations org) {
_logger.debug("-query :" + org);
org.setInstId(WebContext.getUserInfo().getInstId());
if (this.organizationsService.load(org) != null) {
return new Message(WebContext.getI18nValue("message.action.insert.success"), MessageType.success);
@RequestMapping(value={"/query"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> query(@ModelAttribute Organizations org,@CurrentUser UserInfo currentUser) {
_logger.debug("-query {}" , org);
org.setInstId(currentUser.getInstId());
List<Organizations> orgList = organizationsService.query(org);
if (orgList != null) {
return new Message<List<Organizations>>(Message.SUCCESS,orgList).buildResponse();
} else {
return new Message<List<Organizations>>(Message.FAIL).buildResponse();
}
return new Message(WebContext.getI18nValue("message.action.insert.error"), MessageType.error);
}
@RequestMapping(value = { "/forwardUpdate/{id}" })
public ModelAndView forwardUpdate(@PathVariable("id") String id) {
ModelAndView modelAndView=new ModelAndView("/orgs/orgsUpdate");
Organizations org =organizationsService.get(id);
modelAndView.addObject("model",org);
return modelAndView;
@RequestMapping(value = { "/get/{id}" }, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> get(@PathVariable("id") String id) {
Organizations org=organizationsService.get(id);
return new Message<Organizations>(org).buildResponse();
}
@ResponseBody
@RequestMapping({"/update"})
public Message update(@ModelAttribute("org") Organizations org) {
_logger.debug("-update organization :" + org);
org.setInstId(WebContext.getUserInfo().getInstId());
if (this.organizationsService.update(org)) {
return new Message(WebContext.getI18nValue("message.action.update.success"), MessageType.success);
}
return new Message(WebContext.getI18nValue("message.action.update.error"), MessageType.error);
@RequestMapping(value={"/add"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> insert(@RequestBody Organizations org,@CurrentUser UserInfo currentUser) {
_logger.debug("-Add :" + org);
org.setInstId(currentUser.getInstId());
if (organizationsService.insert(org)) {
return new Message<Organizations>(Message.SUCCESS).buildResponse();
} else {
return new Message<Organizations>(Message.FAIL).buildResponse();
}
}
@ResponseBody
@RequestMapping({"/delete"})
public Message delete(@ModelAttribute("org") Organizations org) {
_logger.debug("-delete organization :" + org);
if (this.organizationsService.deleteBatch(org.getId())) {
return new Message(WebContext.getI18nValue("message.action.delete.success"), MessageType.success);
}
return new Message(WebContext.getI18nValue("message.action.delete.success"), MessageType.error);
@RequestMapping(value={"/update"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> update(@RequestBody Organizations org,@CurrentUser UserInfo currentUser) {
_logger.debug("-update :" + org);
org.setInstId(currentUser.getInstId());
if (organizationsService.update(org)) {
return new Message<Organizations>(Message.SUCCESS).buildResponse();
} else {
return new Message<Organizations>(Message.FAIL).buildResponse();
}
}
@ResponseBody
@RequestMapping(value={"/delete"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> delete(@RequestParam("ids") String ids,@CurrentUser UserInfo currentUser) {
_logger.debug("-delete ids : {} " , ids);
if (organizationsService.deleteBatch(ids)) {
return new Message<Organizations>(Message.SUCCESS).buildResponse();
} else {
return new Message<Organizations>(Message.FAIL).buildResponse();
}
}
@ResponseBody
@RequestMapping(value={"/tree"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> tree(@ModelAttribute Organizations organization,@CurrentUser UserInfo currentUser) {
_logger.debug("-query {}" , organization);
organization.setInstId(currentUser.getInstId());
List<Organizations> orgList = organizationsService.query(organization);
if (orgList != null) {
TreeAttributes treeAttributes = new TreeAttributes();
int nodeCount = 0;
for (Organizations org : orgList) {
TreeNode treeNode = new TreeNode(org.getId(),org.getName());
treeNode.setCode(org.getCode());
treeNode.setCodePath(org.getCodePath());
treeNode.setNamePath(org.getNamePath());
treeNode.setParentKey(org.getParentId());
treeNode.setParentTitle(org.getParentName());
treeNode.setParentCode(org.getParentCode());
treeNode.setAttrs(org);
treeNode.setLeaf(true);
treeAttributes.addNode(treeNode);
nodeCount ++;
if(org.getId().equalsIgnoreCase(currentUser.getInstId())) {
treeNode.setExpanded(true);
treeNode.setLeaf(false);
treeAttributes.setRootNode(treeNode);
}
}
treeAttributes.setNodeCount(nodeCount);
return new Message<TreeAttributes>(Message.SUCCESS,treeAttributes).buildResponse();
} else {
return new Message<TreeAttributes>(Message.FAIL).buildResponse();
}
}
@RequestMapping({"/orgUsersList"})
public ModelAndView orgUsersList() { return new ModelAndView("orgs/orgUsersList"); }
@RequestMapping(value = "/import")
public ModelAndView importing(@ModelAttribute("excelImportFile")ExcelImport excelImportFile) {
public ResponseEntity<?> importingOrganizations(@ModelAttribute("excelImportFile")ExcelImport excelImportFile) {
if (excelImportFile.isExcelNotEmpty() ) {
try {
List<Organizations> orgsList = Lists.newArrayList();
@@ -209,9 +184,9 @@ public class OrganizationsController {
if(!CollectionUtils.isEmpty(orgsList)){
orgsList = orgsList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getId()))), ArrayList::new));
if(organizationsService.insertBatch(orgsList)) {
new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_SUCCESS), null, MessageType.success, OperateType.add, MessageScope.DB);
return new Message<Organizations>(Message.SUCCESS).buildResponse();
}else {
new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_ERROR), MessageType.error);
return new Message<Organizations>(Message.FAIL).buildResponse();
}
}
} catch (IOException e) {
@@ -219,11 +194,10 @@ public class OrganizationsController {
}finally {
excelImportFile.closeWorkbook();
}
}else {
new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_ERROR), MessageType.error);
}
return new ModelAndView("/orgs/orgsImport");
return new Message<Organizations>(Message.FAIL).buildResponse();
}
public Organizations buildOrganizationsFromSheetRow(Row row) {

View File

@@ -29,16 +29,14 @@ import java.util.Map;
import java.util.TreeSet;
import java.util.stream.Collectors;
import javax.validation.Valid;
import org.apache.mybatis.jpa.persistence.JpaPageResults;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.maxkey.constants.ConstsOperateMessage;
import org.maxkey.authn.annotation.CurrentUser;
import org.maxkey.constants.ConstsPasswordSetType;
import org.maxkey.crypto.password.PasswordReciprocal;
import org.maxkey.entity.ExcelImport;
import org.maxkey.entity.Message;
import org.maxkey.entity.UserInfo;
import org.maxkey.persistence.service.UserInfoService;
import org.maxkey.util.DateUtils;
@@ -46,27 +44,22 @@ import org.maxkey.util.ExcelUtils;
import org.maxkey.util.JsonUtils;
import org.maxkey.util.StringUtils;
import org.maxkey.web.WebContext;
import org.maxkey.web.message.Message;
import org.maxkey.web.message.MessageScope;
import org.maxkey.web.message.MessageType;
import org.maxkey.web.message.OperateType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.google.common.collect.Lists;
/**
@@ -74,104 +67,85 @@ import com.google.common.collect.Lists;
*
*/
@Controller
@RequestMapping(value = { "/userinfo" })
@RequestMapping(value = { "/users" })
public class UserInfoController {
final static Logger _logger = LoggerFactory.getLogger(UserInfoController.class);
@Autowired
@Qualifier("userInfoService")
private UserInfoService userInfoService;
/**
* 查询用户列表
* @param user
* @return
*/
@RequestMapping(value={"/grid"})
@RequestMapping(value = { "/fetch" }, produces = {MediaType.APPLICATION_JSON_VALUE})
@ResponseBody
public JpaPageResults<UserInfo> forwardUsersList(@ModelAttribute("userInfo") UserInfo userInfo){
userInfo.setInstId(WebContext.getUserInfo().getInstId());
return userInfoService.queryPageResults(userInfo);
public ResponseEntity<?> fetch(@ModelAttribute UserInfo userInfo,@CurrentUser UserInfo currentUser) {
_logger.debug(""+userInfo);
userInfo.setInstId(currentUser.getInstId());
return new Message<JpaPageResults<UserInfo>>(
userInfoService.queryPageResults(userInfo)).buildResponse();
}
@RequestMapping(value={"/forwardAdd"})
public ModelAndView forwardSelectUserType(){
ModelAndView modelAndView=new ModelAndView("/userinfo/userAdd");
//List<UserType> userTypeList=userTypeService.query(null);
//modelAndView.addObject("userTypeList", userTypeList);
return modelAndView;
}
@RequestMapping(value={"/list"})
public ModelAndView usersList(){
return new ModelAndView("/userinfo/usersList");
}
@RequestMapping(value={"/select"})
public ModelAndView usersSelect(){
ModelAndView modelAndView= new ModelAndView("/userinfo/userinfoSelect");
return modelAndView;
}
/**
* 新增
* @param userInfo
* @param result
* @return
*/
@RequestMapping(value="/add")
public ModelAndView addUsers(@Valid @ModelAttribute("userInfo")UserInfo userInfo,BindingResult result) {
_logger.debug(userInfo.toString());
if(result.hasErrors()){
// new Message(WebContext.getValidErrorText(),result);
@ResponseBody
@RequestMapping(value={"/query"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> query(@ModelAttribute UserInfo userInfo,@CurrentUser UserInfo currentUser) {
_logger.debug("-query :" + userInfo);
if (userInfoService.load(userInfo)!=null) {
return new Message<UserInfo>(Message.SUCCESS).buildResponse();
} else {
return new Message<UserInfo>(Message.SUCCESS).buildResponse();
}
userInfo.setId(WebContext.genId());
userInfo.setInstId(WebContext.getUserInfo().getInstId());
//userInfo.setNameZHShortSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), true));
//userInfo.setNameZHSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), false));
if( userInfoService.insert(userInfo)) {
new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_SUCCESS),userInfo,MessageType.success,OperateType.add,MessageScope.DB);
}
new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_ERROR),MessageType.error);
return WebContext.forward("forwardUpdate/"+userInfo.getId());
}
@RequestMapping(value={"/forwardUpdate/{id}"})
public ModelAndView forwardUpdateUsers(@PathVariable("id")String id){
ModelAndView modelAndView=new ModelAndView("/userinfo/userUpdate");
@RequestMapping(value = { "/get/{id}" }, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> get(@PathVariable("id") String id) {
UserInfo userInfo=userInfoService.get(id);
if(userInfo.getPicture()!=null){
userInfo.transPictureBase64();
}
modelAndView.addObject("model", userInfo);
return modelAndView;
}
/**
* 查询用户根据id
* @param id
* @return
*/
@ResponseBody
@RequestMapping(value="/getUsers/{id}")
public UserInfo getUserInfo(@PathVariable("id")String id) {
_logger.debug(id);
UserInfo userInfo = userInfoService.get(id);
if(userInfo!=null&&userInfo.getDecipherable()!=null){
try{
userInfo.setPassword(PasswordReciprocal.getInstance().decoder(userInfo.getDecipherable()));
}catch (Exception e) {
}
userInfo.setDecipherable(userInfo.getPassword());
}
return userInfo;
return new Message<UserInfo>(userInfo).buildResponse();
}
@ResponseBody
@RequestMapping(value={"/add"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> insert(@RequestBody UserInfo userInfo,@CurrentUser UserInfo currentUser) {
_logger.debug("-Add :" + userInfo);
userInfo.setId(WebContext.genId());
userInfo.setInstId(currentUser.getInstId());
if (userInfoService.insert(userInfo)) {
return new Message<UserInfo>(Message.SUCCESS).buildResponse();
} else {
return new Message<UserInfo>(Message.FAIL).buildResponse();
}
}
@ResponseBody
@RequestMapping(value={"/update"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> update(@RequestBody UserInfo userInfo,@CurrentUser UserInfo currentUser) {
_logger.debug("-update :" + userInfo);
_logger.info(userInfo.getExtraAttributeName());
_logger.info(userInfo.getExtraAttributeValue());
//userInfo.setNameZHShortSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), true));
//userInfo.setNameZHSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), false));
convertExtraAttribute(userInfo) ;
_logger.info(userInfo.getExtraAttribute());
userInfo.setInstId(currentUser.getInstId());
if (userInfoService.update(userInfo)) {
return new Message<UserInfo>(Message.SUCCESS).buildResponse();
} else {
return new Message<UserInfo>(Message.FAIL).buildResponse();
}
}
@ResponseBody
@RequestMapping(value={"/delete"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> delete(@RequestParam("ids") String ids,@CurrentUser UserInfo currentUser) {
_logger.debug("-delete ids : {} " , ids);
if (userInfoService.deleteBatch(ids)) {
return new Message<UserInfo>(Message.SUCCESS).buildResponse();
} else {
return new Message<UserInfo>(Message.FAIL).buildResponse();
}
}
@ResponseBody
@RequestMapping(value = "/randomPassword")
@@ -179,69 +153,6 @@ public class UserInfoController {
return userInfoService.randomPassword();
}
/**
* 修改用户
* @param userInfo
* @param result
* @return
*/
@RequestMapping(value="/update")
public ModelAndView updateUsers(@Valid @ModelAttribute("userInfo")UserInfo userInfo,BindingResult result) {
_logger.debug(userInfo.toString());
if(result.hasErrors()){
// new Message(WebContext.getValidErrorText(),result);
}
_logger.info(userInfo.getExtraAttributeName());
_logger.info(userInfo.getExtraAttributeValue());
//userInfo.setNameZHShortSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), true));
//userInfo.setNameZHSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), false));
convertExtraAttribute(userInfo) ;
_logger.info(userInfo.getExtraAttribute());
userInfo.setInstId(WebContext.getUserInfo().getInstId());
if(userInfoService.update(userInfo)) {
new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_SUCCESS),userInfo,MessageType.success,OperateType.add,MessageScope.DB);
}
new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_ERROR),MessageType.error);
return WebContext.forward("forwardUpdate/"+userInfo.getId());
}
/**
* 批量删除用户
* @param id
* @return
*/
@ResponseBody
@RequestMapping(value="/batchDelete")
public Message batchDeleteUsers(@RequestParam("id")String id) {
_logger.debug(id);
if(userInfoService.deleteBatch(StringUtils.string2List(id, ","))) {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.DELETE_SUCCESS),MessageType.success);
} else {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.DELETE_ERROR),MessageType.error);
}
}
/**
* 根据用户id删除用户
*
* @param id
* @return
*/
@ResponseBody
@RequestMapping(value="/delete")
public Message deleteUsersById(@RequestParam("id") String id) {
_logger.debug(id);
if(userInfoService.deleteBatch(id)) {
//provisioningPrepare.prepare(userInfo, OPERATEACTION.DELETE_ACTION);
return new Message(WebContext.getI18nValue(ConstsOperateMessage.DELETE_SUCCESS),MessageType.success);
} else {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.DELETE_ERROR),MessageType.error);
}
}
protected void convertExtraAttribute(UserInfo userInfo) {
if(userInfo.getExtraAttributeValue()!=null){
@@ -256,39 +167,22 @@ public class UserInfoController {
}
}
@RequestMapping(value={"/forwardChangePassword/{id}"})
public ModelAndView forwardChangePassword(@PathVariable("id")String id){
ModelAndView modelAndView=new ModelAndView("/userinfo/changePassword");
UserInfo userInfo=userInfoService.get(id);
modelAndView.addObject("model", userInfo);
return modelAndView;
}
@RequestMapping(value={"/forwardChangeUserinfoStatus/{id}"})
public ModelAndView forwardChangeUserinfoStatus(@PathVariable("id")String id){
ModelAndView modelAndView=new ModelAndView("/userinfo/changeUserinfoStatus");
UserInfo userInfo=userInfoService.get(id);
modelAndView.addObject("model", userInfo);
return modelAndView;
}
@ResponseBody
@RequestMapping(value="/changePassword")
public Message changePassword( @ModelAttribute("userInfo")UserInfo userInfo) {
public ResponseEntity<?> changePassword( @ModelAttribute("userInfo")UserInfo userInfo) {
_logger.debug(userInfo.getId());
userInfo.setPasswordSetType(ConstsPasswordSetType.PASSWORD_NORMAL);
if(userInfoService.changePassword(userInfo,true)) {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_SUCCESS),MessageType.success);
return new Message<UserInfo>(Message.SUCCESS).buildResponse();
} else {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_ERROR),MessageType.error);
return new Message<UserInfo>(Message.FAIL).buildResponse();
}
}
@RequestMapping(value = "/import")
public ModelAndView importing(@ModelAttribute("excelImportFile")ExcelImport excelImportFile) {
public ResponseEntity<?> importingUsers(@ModelAttribute("excelImportFile")ExcelImport excelImportFile) {
if (excelImportFile.isExcelNotEmpty() ) {
try {
List<UserInfo> userInfoList = Lists.newArrayList();
@@ -314,9 +208,7 @@ public class UserInfoController {
if(!CollectionUtils.isEmpty(userInfoList)){
userInfoList = userInfoList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getUsername()))), ArrayList::new));
if( userInfoService.insertBatch(userInfoList)) {
new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_SUCCESS), null, MessageType.success, OperateType.add, MessageScope.DB);
}else {
new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_ERROR), MessageType.error);
return new Message<UserInfo>(Message.SUCCESS).buildResponse();
}
}
} catch (IOException e) {
@@ -324,11 +216,9 @@ public class UserInfoController {
}finally {
excelImportFile.closeWorkbook();
}
}else {
new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_ERROR), MessageType.error);
}
return new Message<UserInfo>(Message.FAIL).buildResponse();
return new ModelAndView("/userinfo/usersImport");
}
@InitBinder

View File

@@ -17,167 +17,138 @@
package org.maxkey.web.permissions.contorller;
import java.util.HashMap;
import java.util.List;
import org.apache.mybatis.jpa.persistence.JpaPageResults;
import org.maxkey.constants.ConstsOperateMessage;
import org.maxkey.authn.annotation.CurrentUser;
import org.maxkey.entity.Message;
import org.maxkey.entity.Resources;
import org.maxkey.entity.UserInfo;
import org.maxkey.persistence.service.ResourcesService;
import org.maxkey.web.WebContext;
import org.maxkey.web.component.TreeAttributes;
import org.maxkey.web.component.TreeNode;
import org.maxkey.web.component.TreeNodeList;
import org.maxkey.web.message.Message;
import org.maxkey.web.message.MessageType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping(value={"/resources"})
@RequestMapping(value={"/permissions/resources"})
public class ResourcesController {
final static Logger _logger = LoggerFactory.getLogger(ResourcesController.class);
@Autowired
@Qualifier("resourcesService")
ResourcesService resourcesService;
@RequestMapping(value={"/list"})
public ModelAndView resourcesList(){
return new ModelAndView("resources/resourcesList");
}
@RequestMapping(value={"/selectResourcesList"})
public ModelAndView selectResourcesList(){
return new ModelAndView("resources/selectResourcesList");
}
@RequestMapping(value = { "/grid" })
@RequestMapping(value = { "/fetch" }, produces = {MediaType.APPLICATION_JSON_VALUE})
@ResponseBody
public JpaPageResults<Resources> queryDataGrid(@ModelAttribute("resources") Resources resources) {
_logger.debug(""+resources);
resources.setInstId(WebContext.getUserInfo().getInstId());
return resourcesService.queryPageResults(resources);
public ResponseEntity<?> fetch(@ModelAttribute Resources resource,@CurrentUser UserInfo currentUser) {
_logger.debug("fetch {}" , resource);
resource.setInstId(currentUser.getInstId());
return new Message<JpaPageResults<Resources>>(
resourcesService.queryPageResults(resource)).buildResponse();
}
@RequestMapping(value = { "/forwardAdd" })
public ModelAndView forwardAdd() {
return new ModelAndView("resources/resourceAdd");
@ResponseBody
@RequestMapping(value={"/query"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> query(@ModelAttribute Resources resource,@CurrentUser UserInfo currentUser) {
_logger.debug("-query {}" , resource);
resource.setInstId(currentUser.getInstId());
List<Resources> resourceList = resourcesService.query(resource);
if (resourceList != null) {
return new Message<List<Resources>>(Message.SUCCESS,resourceList).buildResponse();
} else {
return new Message<List<Resources>>(Message.FAIL).buildResponse();
}
}
@RequestMapping(value = { "/forwardUpdate/{id}" })
public ModelAndView forwardUpdate(@PathVariable("id") String id) {
ModelAndView modelAndView=new ModelAndView("resources/resourceUpdate");
@RequestMapping(value = { "/get/{id}" }, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> get(@PathVariable("id") String id) {
Resources resource=resourcesService.get(id);
modelAndView.addObject("model",resource);
return modelAndView;
return new Message<Resources>(resource).buildResponse();
}
@ResponseBody
@RequestMapping(value={"/add"})
public Message insert(@ModelAttribute("resource") Resources resource) {
@RequestMapping(value={"/add"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> insert(@RequestBody Resources resource,@CurrentUser UserInfo currentUser) {
_logger.debug("-Add :" + resource);
resource.setInstId(WebContext.getUserInfo().getInstId());
resource.setInstId(currentUser.getInstId());
if (resourcesService.insert(resource)) {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_SUCCESS),MessageType.success);
return new Message<Resources>(Message.SUCCESS).buildResponse();
} else {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_SUCCESS),MessageType.error);
return new Message<Resources>(Message.FAIL).buildResponse();
}
}
/**
* 查询
* @param resource
* @return
*/
@ResponseBody
@RequestMapping(value={"/query"})
public Message query(@ModelAttribute("resource") Resources resource) {
_logger.debug("-query :" + resource);
resource.setInstId(WebContext.getUserInfo().getInstId());
if (resourcesService.load(resource)!=null) {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_SUCCESS),MessageType.success);
} else {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_ERROR),MessageType.error);
}
}
/**
* 修改
* @param resource
* @return
*/
@ResponseBody
@RequestMapping(value={"/update"})
public Message update(@ModelAttribute("resource") Resources resource) {
_logger.debug("-update resource :" + resource);
resource.setInstId(WebContext.getUserInfo().getInstId());
@RequestMapping(value={"/update"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> update(@RequestBody Resources resource,@CurrentUser UserInfo currentUser) {
_logger.debug("-update :" + resource);
resource.setInstId(currentUser.getInstId());
if (resourcesService.update(resource)) {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_SUCCESS),MessageType.success);
return new Message<Resources>(Message.SUCCESS).buildResponse();
} else {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_ERROR),MessageType.error);
return new Message<Resources>(Message.FAIL).buildResponse();
}
}
@ResponseBody
@RequestMapping(value={"/delete"})
public Message delete(@ModelAttribute("resource") Resources resource) {
_logger.debug("-delete resource :" + resource);
if (resourcesService.deleteBatch(resource.getId())) {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.DELETE_SUCCESS),MessageType.success);
@RequestMapping(value={"/delete"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> delete(@RequestParam("ids") String ids,@CurrentUser UserInfo currentUser) {
_logger.debug("-delete ids : {} " , ids);
if (resourcesService.deleteBatch(ids)) {
return new Message<Resources>(Message.SUCCESS).buildResponse();
} else {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.DELETE_SUCCESS),MessageType.error);
return new Message<Resources>(Message.FAIL).buildResponse();
}
}
@ResponseBody
@RequestMapping(value={"/tree"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> tree(@ModelAttribute Resources resource,@CurrentUser UserInfo currentUser) {
_logger.debug("-query {}" , resource);
resource.setInstId(currentUser.getInstId());
List<Resources> resourceList = resourcesService.query(resource);
if (resourceList != null) {
TreeAttributes treeAttributes = new TreeAttributes();
int nodeCount = 0;
for (Resources r : resourceList) {
TreeNode treeNode = new TreeNode(r.getId(),r.getName());
treeNode.setParentKey(r.getParentId());
treeNode.setParentTitle(r.getParentName());
treeNode.setAttrs(r);
treeNode.setLeaf(true);
treeAttributes.addNode(treeNode);
nodeCount ++;
if(r.getId().equalsIgnoreCase(currentUser.getInstId())) {
treeNode.setExpanded(true);
treeNode.setLeaf(false);
treeAttributes.setRootNode(treeNode);
}
}
TreeNode rootNode = new TreeNode(resource.getAppId(),resource.getAppName());
rootNode.setParentKey(resource.getAppId());
rootNode.setExpanded(true);
rootNode.setLeaf(false);
treeAttributes.setRootNode(rootNode);
treeAttributes.setNodeCount(nodeCount);
return new Message<TreeAttributes>(Message.SUCCESS,treeAttributes).buildResponse();
} else {
return new Message<TreeAttributes>(Message.FAIL).buildResponse();
}
}
@ResponseBody
@RequestMapping({"/tree"})
public List<HashMap<String, Object>> resourcesTree(
@RequestParam(value = "appId", required = false) String appId,
@RequestParam(value = "appName", required = false) String appName
) {
_logger.debug("resourcesTree appId :" + appId + " ,appName " + appName);
Resources queryRes = new Resources();
queryRes.setAppId(appId);
queryRes.setInstId(WebContext.getUserInfo().getInstId());
List<Resources> resourcesList = this.resourcesService.queryResourcesTree(queryRes);
TreeNodeList treeNodeList = new TreeNodeList();
TreeNode rootNode = new TreeNode(appId, appName);
rootNode.setAttr("open", Boolean.valueOf(true));
treeNodeList.addTreeNode(rootNode.getAttr());
for (Resources res : resourcesList) {
TreeNode treeNode = new TreeNode(res.getId(), res.getName());
treeNode.setAttr("data", res);
treeNode.setPId(res.getParentId());
treeNodeList.addTreeNode(treeNode.getAttr());
}
return treeNodeList.getTreeNodeList();
}
}

View File

@@ -18,96 +18,79 @@
package org.maxkey.web.permissions.contorller;
import org.apache.mybatis.jpa.persistence.JpaPageResults;
import org.maxkey.constants.ConstsOperateMessage;
import org.maxkey.authn.annotation.CurrentUser;
import org.maxkey.entity.Message;
import org.maxkey.entity.RoleMember;
import org.maxkey.entity.Roles;
import org.maxkey.entity.UserInfo;
import org.maxkey.persistence.service.RoleMemberService;
import org.maxkey.persistence.service.RolesService;
import org.maxkey.web.WebContext;
import org.maxkey.web.message.Message;
import org.maxkey.web.message.MessageType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping(value={"/rolemembers"})
@RequestMapping(value={"/permissions/rolemembers"})
public class RoleMemberController {
final static Logger _logger = LoggerFactory.getLogger(RoleMemberController.class);
@Autowired
@Qualifier("roleMemberService")
RoleMemberService roleMemberService;
@Autowired
@Qualifier("rolesService")
RolesService rolesService;
@RequestMapping(value={"/list"})
public ModelAndView groupsList(){
return new ModelAndView("roleusers/roleUsersList");
}
@RequestMapping(value = { "/grid" })
@RequestMapping(value = { "/fetch" }, produces = {MediaType.APPLICATION_JSON_VALUE})
@ResponseBody
public JpaPageResults<RoleMember> grid(@ModelAttribute("roleMember") RoleMember roleMember) {
public ResponseEntity<?> fetch(
@ModelAttribute("roleMember") RoleMember roleMember,
@CurrentUser UserInfo currentUser) {
if(roleMember.getRoleId()==null||roleMember.getRoleId().equals("")){
return null;
}
roleMember.setInstId(WebContext.getUserInfo().getInstId());
return roleMemberService.queryPageResults(roleMember);
roleMember.setInstId(currentUser.getInstId());
return new Message<JpaPageResults<RoleMember>>(
roleMemberService.queryPageResults(roleMember)).buildResponse();
}
@RequestMapping(value = { "/queryMemberInRole" })
@RequestMapping(value = { "/memberInRole" })
@ResponseBody
public JpaPageResults<RoleMember> queryMemberInRole(@ModelAttribute("roleMember") RoleMember roleMember) {
public ResponseEntity<?> memberInRole(@ModelAttribute RoleMember roleMember) {
_logger.debug("roleMember : "+roleMember);
roleMember.setInstId(WebContext.getUserInfo().getInstId());
if(roleMember.getRoleId()==null||roleMember.getRoleId().equals("")||roleMember.getRoleId().equals("ALL_USER_ROLE")){
return roleMemberService.queryPageResults("allMemberInRole",roleMember);
return new Message<JpaPageResults<RoleMember>>(
roleMemberService.queryPageResults("allMemberInRole",roleMember)).buildResponse();
}else{
return roleMemberService.queryPageResults("memberInRole",roleMember);
return new Message<JpaPageResults<RoleMember>>(
roleMemberService.queryPageResults("memberInRole",roleMember)).buildResponse();
}
}
@RequestMapping(value={"/addRoleAppsList/{roleId}"})
public ModelAndView addGroupAppsList(@PathVariable("roleId") String roleId){
ModelAndView modelAndView=new ModelAndView("roleusers/addRoleUsersList");
Roles role=rolesService.get(roleId);
modelAndView.addObject("role", role);
return modelAndView;
}
@RequestMapping(value = { "/queryMemberNotInRole" })
@RequestMapping(value = { "/memberNotInRole" })
@ResponseBody
public JpaPageResults<RoleMember> queryMemberNotInGroupGrid(@ModelAttribute("roleMember") RoleMember roleMember) {
public ResponseEntity<?> memberNotInRole(@ModelAttribute RoleMember roleMember) {
roleMember.setInstId(WebContext.getUserInfo().getInstId());
return roleMemberService.queryPageResults("memberNotInRole",roleMember);
return new Message<JpaPageResults<RoleMember>>(
roleMemberService.queryPageResults("memberNotInGroup",roleMember)).buildResponse();
}
@RequestMapping(value = {"/insert"})
@RequestMapping(value = {"/add"})
@ResponseBody
public Message insertRoleUsers(@ModelAttribute("roleMember") RoleMember roleMember) {
public ResponseEntity<?> add(@ModelAttribute RoleMember roleMember) {
if (roleMember == null || roleMember.getRoleId() == null) {
return new Message("传入参数为空",MessageType.error);
return new Message<RoleMember>(Message.FAIL).buildResponse();
}
String groupId = roleMember.getRoleId();
boolean result = true;
String memberIds = roleMember.getMemberId();
String memberNames = roleMember.getMemberName();
@@ -127,26 +110,21 @@ public class RoleMemberController {
newRoleMember.setId(WebContext.genId());
result = roleMemberService.insert(newRoleMember);
}
if(!result) {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_ERROR),MessageType.error);
if(result) {
return new Message<RoleMember>(Message.SUCCESS).buildResponse();
}
}
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_SUCCESS),MessageType.info);
return new Message<RoleMember>(Message.FAIL).buildResponse();
}
@RequestMapping(value = {"/delete"})
@ResponseBody
public Message deleteGroupMember(@ModelAttribute("roleMember") RoleMember roleMember) {
_logger.debug("roleMember : "+roleMember);
if (roleMember == null || roleMember.getId() == null) {
return new Message("传入参数为空",MessageType.error);
@RequestMapping(value={"/delete"}, produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<?> delete(@RequestParam("ids") String ids,@CurrentUser UserInfo currentUser) {
_logger.debug("-delete ids : {}" , ids);
if (roleMemberService.deleteBatch(ids)) {
return new Message<RoleMember>(Message.SUCCESS).buildResponse();
} else {
return new Message<RoleMember>(Message.FAIL).buildResponse();
}
if(roleMemberService.deleteBatch(roleMember.getId())) {
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_SUCCESS),MessageType.info);
}
return new Message(WebContext.getI18nValue(ConstsOperateMessage.INSERT_ERROR),MessageType.error);
}
}

View File

@@ -40,9 +40,9 @@ import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping(value={"/permissions"})
public class PermissionsController {
final static Logger _logger = LoggerFactory.getLogger(PermissionsController.class);
@RequestMapping(value={"/permissions/privileges"})
public class RolePrivilegesController {
final static Logger _logger = LoggerFactory.getLogger(RolePrivilegesController.class);
@Autowired
@Qualifier("rolesService")