mirror of
https://gitee.com/dromara/MaxKey.git
synced 2026-05-14 20:50:14 +08:00
RBAC Support
1、RBAC 基于角色的访问控制(Role-Based Access Control )支持 2、修复用户组访问权限删除问题 3、DAO层整合 4、Javascript验证及AJAX提交优化
This commit is contained in:
@@ -1,60 +1,51 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.maxkey.domain.apps;
|
||||
|
||||
/**
|
||||
* UserApps .
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
public class UserApps extends Apps {
|
||||
private static final long serialVersionUID = 3186085827268041549L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 3186085827268041549L;
|
||||
|
||||
private String username;
|
||||
|
||||
private String userId;
|
||||
private String username;
|
||||
|
||||
private String displayName;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public UserApps() {
|
||||
|
||||
}
|
||||
private String userId;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
private String displayName;
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
public UserApps() {
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserApplications [username=" + username
|
||||
+ ", userId=" + userId + ", displayName=" + displayName + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserApplications [username=" + username + ", userId=" + userId
|
||||
+ ", displayName=" + displayName + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
public class InitApplicationContext extends HttpServlet {
|
||||
private static final Logger _logger = LoggerFactory.getLogger(InitApplicationContext.class);
|
||||
public class InitializeContext extends HttpServlet {
|
||||
private static final Logger _logger = LoggerFactory.getLogger(InitializeContext.class);
|
||||
private static final long serialVersionUID = -797399138268601444L;
|
||||
ApplicationContext applicationContext;
|
||||
|
||||
@@ -59,12 +59,12 @@ public class InitApplicationContext extends HttpServlet {
|
||||
/**
|
||||
* InitApplicationContext.
|
||||
*/
|
||||
public InitApplicationContext() {
|
||||
public InitializeContext() {
|
||||
this.applicationContext =
|
||||
WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
|
||||
}
|
||||
|
||||
public InitApplicationContext(ConfigurableApplicationContext applicationContext) {
|
||||
public InitializeContext(ConfigurableApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
*/
|
||||
package org.maxkey.dao.persistence;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.apache.mybatis.jpa.persistence.IJpaBaseMapper;
|
||||
import org.maxkey.domain.apps.Apps;
|
||||
import org.maxkey.domain.apps.UserApps;
|
||||
|
||||
/**
|
||||
* @author Crystal.sea
|
||||
@@ -19,4 +22,7 @@ public interface AppsMapper extends IJpaBaseMapper<Apps> {
|
||||
|
||||
@Update("UPDATE APPS SET ISEXTENDATTR=#{isExtendAttr}, EXTENDATTR=#{extendAttr} WHERE id = #{id}")
|
||||
public int updateExtendAttr(Apps app);
|
||||
|
||||
|
||||
public List<UserApps> queryMyApps(UserApps userApplications);
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.maxkey.dao.persistence;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.mybatis.jpa.persistence.IJpaBaseMapper;
|
||||
import org.maxkey.domain.apps.UserApps;
|
||||
|
||||
/**
|
||||
* @author Crystal.sea
|
||||
*
|
||||
*/
|
||||
public interface MyAppsListMapper extends IJpaBaseMapper<UserApps> {
|
||||
|
||||
public List<UserApps> queryMyApps(UserApps userApplications);
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package org.maxkey.dao.persistence;
|
||||
|
||||
import org.apache.mybatis.jpa.persistence.IJpaBaseMapper;
|
||||
import org.maxkey.domain.UserInfo;
|
||||
|
||||
|
||||
/**
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
public interface MyProfileMapper extends IJpaBaseMapper<UserInfo>{
|
||||
|
||||
public int updateProfile(UserInfo userInfo);
|
||||
|
||||
}
|
||||
@@ -41,6 +41,8 @@ public interface UserInfoMapper extends IJpaBaseMapper<UserInfo>{
|
||||
|
||||
public int changeMobile(UserInfo userInfo);
|
||||
|
||||
public int updateProfile(UserInfo userInfo);
|
||||
|
||||
@Select("SELECT * FROM USERINFO WHERE EMAIL = #{value} OR MOBILE= #{value}")
|
||||
public UserInfo queryUserInfoByEmailMobile(String emailMobile);
|
||||
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package org.maxkey.dao.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.mybatis.jpa.persistence.JpaBaseService;
|
||||
import org.maxkey.dao.persistence.AppsMapper;
|
||||
import org.maxkey.domain.apps.Apps;
|
||||
import org.maxkey.domain.apps.UserApps;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@@ -32,4 +35,7 @@ public class AppsService extends JpaBaseService<Apps>{
|
||||
return ((AppsMapper)super.getMapper()).updateExtendAttr(app)>0;
|
||||
}
|
||||
|
||||
public List<UserApps> queryMyApps(UserApps userApplications){
|
||||
return getMapper().queryMyApps(userApplications);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
package org.maxkey.dao.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.mybatis.jpa.persistence.JpaBaseService;
|
||||
import org.maxkey.dao.persistence.MyAppsListMapper;
|
||||
import org.maxkey.domain.apps.UserApps;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MyAppsListService extends JpaBaseService<UserApps>{
|
||||
|
||||
public MyAppsListService() {
|
||||
super(MyAppsListMapper.class);
|
||||
}
|
||||
|
||||
public List<UserApps> queryMyApps(UserApps userApplications){
|
||||
return getMapper().queryMyApps(userApplications);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public MyAppsListMapper getMapper() {
|
||||
// TODO Auto-generated method stub
|
||||
return (MyAppsListMapper)super.getMapper();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package org.maxkey.dao.service;
|
||||
|
||||
import org.apache.mybatis.jpa.persistence.JpaBaseService;
|
||||
import org.maxkey.dao.persistence.MyProfileMapper;
|
||||
import org.maxkey.domain.UserInfo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
public class MyProfileService extends JpaBaseService<UserInfo> {
|
||||
|
||||
|
||||
public MyProfileService() {
|
||||
super(MyProfileMapper.class);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.connsec.db.service.BaseService#getMapper()
|
||||
*/
|
||||
@Override
|
||||
public MyProfileMapper getMapper() {
|
||||
// TODO Auto-generated method stub
|
||||
return (MyProfileMapper)super.getMapper();
|
||||
}
|
||||
|
||||
|
||||
public int updateProfile(UserInfo userInfo){
|
||||
|
||||
return getMapper().updateProfile(userInfo);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -223,5 +223,10 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
|
||||
public UserInfo queryUserInfoByEmailMobile(String emailMobile) {
|
||||
return getMapper().queryUserInfoByEmailMobile(emailMobile);
|
||||
}
|
||||
|
||||
public int updateProfile(UserInfo userInfo){
|
||||
|
||||
return getMapper().updateProfile(userInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -152,4 +152,39 @@
|
||||
WHERE
|
||||
ID = #{id}
|
||||
</update>
|
||||
|
||||
<select id="queryMyApps" parameterType="UserApps" resultType="UserApps">
|
||||
SELECT DISTINCT
|
||||
APP.*
|
||||
FROM
|
||||
APPS APP,GROUP_PRIVILEGES GP
|
||||
WHERE
|
||||
APP.ID=GP.APPID
|
||||
AND GP.GROUPID IN(
|
||||
SELECT
|
||||
G.ID
|
||||
FROM
|
||||
GROUPS G
|
||||
WHERE
|
||||
G.ID='ALL_USER_GROUP'
|
||||
OR G.ID IN(
|
||||
SELECT
|
||||
GM.GROUPID
|
||||
FROM
|
||||
GROUP_MEMBER GM,USERINFO U
|
||||
WHERE 1 = 1
|
||||
<if test="userId != null and userId != ''">
|
||||
AND U.ID = #{userId}
|
||||
</if>
|
||||
<if test="username != null and username != ''">
|
||||
AND U.USERNAME = #{username}
|
||||
</if>
|
||||
AND GM.MEMBERID = U.ID
|
||||
)
|
||||
)
|
||||
<if test="name != null and name != ''">
|
||||
AND NAME = #{name}
|
||||
</if>
|
||||
ORDER BY SORTINDEX
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -20,7 +20,17 @@
|
||||
<!-- AppGroup -->
|
||||
<select id="appsInGroup" parameterType="GroupPrivileges" resultType="GroupPrivileges">
|
||||
SELECT
|
||||
*
|
||||
GP.ID,
|
||||
GP.GROUPID,
|
||||
GP.APPID,
|
||||
APPS.NAME,
|
||||
APPS.ICON,
|
||||
APPS.LOGINURL,
|
||||
APPS.PROTOCOL,
|
||||
APPS.CATEGORY,
|
||||
APPS.DESCRIPTION,
|
||||
APPS.VENDOR,
|
||||
APPS.VENDORURL
|
||||
FROM
|
||||
APPS APPS,
|
||||
GROUP_PRIVILEGES GP
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.maxkey.dao.persistence.MyAppsListMapper">
|
||||
|
||||
<select id="queryMyApps" parameterType="UserApps" resultType="UserApps">
|
||||
SELECT DISTINCT
|
||||
APP.*
|
||||
FROM
|
||||
APPS APP,GROUP_PRIVILEGES GP
|
||||
WHERE
|
||||
APP.ID=GP.APPID
|
||||
AND GP.GROUPID IN(
|
||||
SELECT
|
||||
G.ID
|
||||
FROM
|
||||
GROUPS G
|
||||
WHERE
|
||||
G.ID='ALL_USER_GROUP'
|
||||
OR G.ID IN(
|
||||
SELECT
|
||||
GM.GROUPID
|
||||
FROM
|
||||
GROUP_MEMBER GM,USERINFO U
|
||||
WHERE 1 = 1
|
||||
<if test="userId != null and userId != ''">
|
||||
AND U.ID = #{userId}
|
||||
</if>
|
||||
<if test="username != null and username != ''">
|
||||
AND U.USERNAME = #{username}
|
||||
</if>
|
||||
AND GM.MEMBERID = U.ID
|
||||
)
|
||||
)
|
||||
<if test="name != null and name != ''">
|
||||
AND NAME = #{name}
|
||||
</if>
|
||||
ORDER BY SORTINDEX
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,62 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.maxkey.dao.persistence.MyProfileMapper">
|
||||
|
||||
<update id="updateProfile" parameterType="UserInfo" >
|
||||
UPDATE USERINFO SET
|
||||
DISPLAYNAME = #{displayName},
|
||||
NICKNAME = #{nickName},
|
||||
NAMEZHSPELL = #{nameZhSpell},
|
||||
NAMEZHSHORTSPELL= #{nameZhShortSpell},
|
||||
GIVENNAME = #{givenName},
|
||||
MIDDLENAME = #{middleName},
|
||||
FAMILYNAME = #{familyName},
|
||||
HONORIFICPREFIX = #{honorificPrefix},
|
||||
HONORIFICSUFFIX = #{honorificSuffix},
|
||||
FORMATTEDNAME = #{formattedName} ,
|
||||
MARRIED = #{married},
|
||||
GENDER = #{gender},
|
||||
BIRTHDATE = #{birthDate},
|
||||
<if test="picture != null">
|
||||
PICTURE = #{picture},
|
||||
</if>
|
||||
IDTYPE = #{idType},
|
||||
IDCARDNO = #{idCardNo},
|
||||
WEBSITE = #{webSite},
|
||||
|
||||
LOCALE = #{locale},
|
||||
TIMEZONE = #{timeZone},
|
||||
PREFERREDLANGUAGE= #{preferredLanguage},
|
||||
|
||||
WINDOWSACCOUNT = #{windowsAccount},
|
||||
|
||||
WORKCOUNTRY = #{workCountry},
|
||||
WORKREGION = #{workRegion},
|
||||
WORKLOCALITY = #{workLocality},
|
||||
WORKSTREETADDRESS= #{workStreetAddress},
|
||||
WORKADDRESSFORMATTED= #{workAddressFormatted},
|
||||
WORKEMAIL = #{workEmail},
|
||||
WORKPHONENUMBER = #{workPhoneNumber},
|
||||
WORKPOSTALCODE = #{workPostalCode},
|
||||
WORKFAX = #{workFax},
|
||||
|
||||
HOMECOUNTRY = #{homeCountry},
|
||||
HOMEREGION = #{homeRegion},
|
||||
HOMELOCALITY = #{homeLocality},
|
||||
HOMESTREETADDRESS= #{homeStreetAddress},
|
||||
HOMEADDRESSFORMATTED= #{homeAddressFormatted},
|
||||
HOMEEMAIL = #{homeEmail},
|
||||
HOMEPHONENUMBER= #{homePhoneNumber},
|
||||
HOMEPOSTALCODE = #{homePostalCode},
|
||||
HOMEFAX = #{homeFax},
|
||||
|
||||
EXTRAATTRIBUTE = #{extraAttribute},
|
||||
|
||||
MODIFIEDBY = #{modifiedBy},
|
||||
MODIFIEDDATE = current_timestamp
|
||||
WHERE
|
||||
ID = #{id}
|
||||
</update>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -189,4 +189,61 @@
|
||||
#{item}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="updateProfile" parameterType="UserInfo" >
|
||||
UPDATE USERINFO SET
|
||||
DISPLAYNAME = #{displayName},
|
||||
NICKNAME = #{nickName},
|
||||
NAMEZHSPELL = #{nameZhSpell},
|
||||
NAMEZHSHORTSPELL= #{nameZhShortSpell},
|
||||
GIVENNAME = #{givenName},
|
||||
MIDDLENAME = #{middleName},
|
||||
FAMILYNAME = #{familyName},
|
||||
HONORIFICPREFIX = #{honorificPrefix},
|
||||
HONORIFICSUFFIX = #{honorificSuffix},
|
||||
FORMATTEDNAME = #{formattedName} ,
|
||||
MARRIED = #{married},
|
||||
GENDER = #{gender},
|
||||
BIRTHDATE = #{birthDate},
|
||||
<if test="picture != null">
|
||||
PICTURE = #{picture},
|
||||
</if>
|
||||
IDTYPE = #{idType},
|
||||
IDCARDNO = #{idCardNo},
|
||||
WEBSITE = #{webSite},
|
||||
|
||||
LOCALE = #{locale},
|
||||
TIMEZONE = #{timeZone},
|
||||
PREFERREDLANGUAGE= #{preferredLanguage},
|
||||
|
||||
WINDOWSACCOUNT = #{windowsAccount},
|
||||
|
||||
WORKCOUNTRY = #{workCountry},
|
||||
WORKREGION = #{workRegion},
|
||||
WORKLOCALITY = #{workLocality},
|
||||
WORKSTREETADDRESS= #{workStreetAddress},
|
||||
WORKADDRESSFORMATTED= #{workAddressFormatted},
|
||||
WORKEMAIL = #{workEmail},
|
||||
WORKPHONENUMBER = #{workPhoneNumber},
|
||||
WORKPOSTALCODE = #{workPostalCode},
|
||||
WORKFAX = #{workFax},
|
||||
|
||||
HOMECOUNTRY = #{homeCountry},
|
||||
HOMEREGION = #{homeRegion},
|
||||
HOMELOCALITY = #{homeLocality},
|
||||
HOMESTREETADDRESS= #{homeStreetAddress},
|
||||
HOMEADDRESSFORMATTED= #{homeAddressFormatted},
|
||||
HOMEEMAIL = #{homeEmail},
|
||||
HOMEPHONENUMBER= #{homePhoneNumber},
|
||||
HOMEPOSTALCODE = #{homePostalCode},
|
||||
HOMEFAX = #{homeFax},
|
||||
|
||||
EXTRAATTRIBUTE = #{extraAttribute},
|
||||
|
||||
MODIFIEDBY = #{modifiedBy},
|
||||
MODIFIEDDATE = current_timestamp
|
||||
WHERE
|
||||
ID = #{id}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -4,7 +4,7 @@ import java.util.Date;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import org.maxkey.web.InitApplicationContext;
|
||||
import org.maxkey.web.InitializeContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
@@ -34,7 +34,7 @@ public class MaxKeyMgtApplication extends SpringBootServletInitializer {
|
||||
System.out.println("MaxKeyMgtApplication");
|
||||
|
||||
ConfigurableApplicationContext applicationContext =SpringApplication.run(MaxKeyMgtApplication.class, args);
|
||||
InitApplicationContext initWebContext=new InitApplicationContext(applicationContext);
|
||||
InitializeContext initWebContext=new InitializeContext(applicationContext);
|
||||
|
||||
|
||||
try {
|
||||
|
||||
@@ -1,26 +1,18 @@
|
||||
/*
|
||||
* crystal.sea
|
||||
*/
|
||||
|
||||
/* for datagrid queryParams*/
|
||||
function dataGridQueryParams(params) {
|
||||
var postData={};
|
||||
if($("#basic_search_form")){//o.length>0
|
||||
postData=$("#basic_search_form").serializeObject();
|
||||
}
|
||||
|
||||
if($("#advanced_search")){//o.length>0
|
||||
postData=$.extend(postData,$("#advanced_search_form").serializeObject()||{});
|
||||
}
|
||||
|
||||
params=$.extend(params,postData);
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
//jquery begin
|
||||
$(function(){
|
||||
|
||||
//document forward
|
||||
$.forward=function(config){
|
||||
if(config.target){
|
||||
@@ -232,6 +224,85 @@ $(function(){
|
||||
$(".d-footer").show();
|
||||
};
|
||||
|
||||
// Fetch all the forms we want to apply custom Bootstrap validation styles to
|
||||
// For actionForm use ajax submit
|
||||
var forms = $(".needs-validation");
|
||||
// Loop over them and prevent submission
|
||||
Array.prototype.filter.call(forms, function (form) {
|
||||
form.addEventListener('submit', function (event) {
|
||||
if (form.checkValidity() === false) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}else{
|
||||
if($("#actionForm")[0]){//ajaxSubmit
|
||||
$("#actionForm").ajaxSubmit({//form ajax submit
|
||||
dataType : 'json',//json type
|
||||
success : function(data) { //success return
|
||||
$.unloading();
|
||||
|
||||
var formErrorType=$("#actionForm").attr("type");//error alert type
|
||||
|
||||
if(data.errors && formErrorType){//have error field return
|
||||
if(formErrorType=="alert"){//alert dialog
|
||||
var errorMessage=data.message+"<br>";
|
||||
for (var elem in data.errors){
|
||||
errorMessage+=data.errors[elem].message+"<br>";
|
||||
}
|
||||
$.alert({content:errorMessage,type:"error"});
|
||||
}else{//label tip
|
||||
for (var elem in data.errors){
|
||||
$("label[for='"+data.errors[elem].field+"']").html(data.errors[elem].message);
|
||||
}
|
||||
if(formErrorType!="label"){
|
||||
$("#"+formErrorType).show();
|
||||
}
|
||||
}
|
||||
return;
|
||||
} else {//no error,alert result message
|
||||
$.alert({content:data.message,type:$.platform.messages.messageType[data.messageType],
|
||||
callback:function(){
|
||||
if($("#actionForm").attr("autoclose")) {//auto close button
|
||||
if($("#backBtn").attr("id")){
|
||||
$("#backBtn").click();
|
||||
}else{
|
||||
$.closeWindow();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if($("#actionForm").attr("forward")){//auto forwar to actionForm forward attr
|
||||
document.location.href=$("#actionForm").attr("forward");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// refresh datagrid after Submit
|
||||
if($("#datagrid")[0]){
|
||||
$("#datagrid").bootstrapTable("refresh");
|
||||
}
|
||||
//self define afterSubmit
|
||||
if (typeof(afterSubmit) == "function"){
|
||||
afterSubmit(data);//call back
|
||||
}
|
||||
},
|
||||
beforeSubmit: function(arr, $form, options) { //before submit
|
||||
$.loading();//loading icon
|
||||
if (typeof(beforeSubmit) == "function"){
|
||||
return beforeSubmit();//callback
|
||||
}
|
||||
},
|
||||
error : function(a, b, c) {//submit error
|
||||
$.unloading();
|
||||
$.alert({content:$.platform.messages.submit.errorText,type:"error"});
|
||||
}
|
||||
});
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
form.classList.add('was-validated');
|
||||
}, false);
|
||||
});
|
||||
|
||||
//window open by element is window style
|
||||
$(".window").on("click",function(){
|
||||
if (typeof(beforeWindow) == "function"){
|
||||
@@ -444,7 +515,9 @@ $(function(){
|
||||
//alert delete result
|
||||
$.alert({content:data.message,type:$.platform.messages.messageType[data.messageType]});
|
||||
//refresh grid list
|
||||
|
||||
if($("#datagrid")[0]){
|
||||
$("#datagrid").bootstrapTable("refresh");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -456,7 +529,6 @@ $(function(){
|
||||
if($("#actionForm").attr("autoclose")) {
|
||||
// try to refresh parent grid list
|
||||
if($.dialog.parent) {
|
||||
|
||||
$.dialog.close();
|
||||
return;
|
||||
}
|
||||
@@ -484,111 +556,19 @@ $(function(){
|
||||
|
||||
});
|
||||
|
||||
|
||||
//submit button
|
||||
$("#submitBtn").click(function(){
|
||||
var canSubmit = true;
|
||||
if (typeof(beforeAction) == "function"){
|
||||
canSubmit = beforeAction();//before submit
|
||||
}
|
||||
if($("#actionForm").attr("validate") && $("#actionForm").attr("validate")=="false"){//是否通过验证和自定义验证,validate属性
|
||||
return false;
|
||||
}
|
||||
if(canSubmit) {
|
||||
//$("#actionForm").submit();//submit
|
||||
}
|
||||
});
|
||||
|
||||
//form submit form define
|
||||
//form json url init all ways not used
|
||||
if($("#actionForm")){//actionForm exist
|
||||
if($("#actionForm").attr("loadaction")){//init form
|
||||
$("#actionForm").json2form({url : $("#actionForm").attr("loadaction")});//init #actionForm with loadaction url
|
||||
$("#actionForm").removeAttr('loadaction'); //is need init
|
||||
}
|
||||
};
|
||||
|
||||
// Fetch all the forms we want to apply custom Bootstrap validation styles to
|
||||
var forms = $(".needs-validation");
|
||||
// Loop over them and prevent submission
|
||||
Array.prototype.filter.call(forms, function (form) {
|
||||
form.addEventListener('submit', function (event) {
|
||||
if (form.checkValidity() === false) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}else{
|
||||
if($("#actionForm")[0]){//ajaxSubmit
|
||||
$("#actionForm").ajaxSubmit({//form ajax submit
|
||||
dataType : 'json',//json type
|
||||
success : function(data) { //success return
|
||||
$.unloading();
|
||||
if (typeof(afterSubmit) == "function"){
|
||||
afterSubmit(data);//call back
|
||||
return;
|
||||
}
|
||||
|
||||
var formErrorType=$("#actionForm").attr("type");//error alert type
|
||||
|
||||
if(data.errors && formErrorType){//have error field return
|
||||
if(formErrorType=="alert"){//alert dialog
|
||||
var errorMessage=data.message+"<br>";
|
||||
for (var elem in data.errors){
|
||||
errorMessage+=data.errors[elem].message+"<br>";
|
||||
}
|
||||
$.alert({content:errorMessage,type:"error"});
|
||||
}else{//label tip
|
||||
for (var elem in data.errors){
|
||||
$("label[for='"+data.errors[elem].field+"']").html(data.errors[elem].message);
|
||||
}
|
||||
if(formErrorType!="label"){
|
||||
$("#"+formErrorType).show();
|
||||
}
|
||||
}
|
||||
return;
|
||||
} else {//no error,alert result message
|
||||
$.alert({content:data.message,type:$.platform.messages.messageType[data.messageType],
|
||||
callback:function(){
|
||||
if($("#actionForm").attr("autoclose")) {//auto close button
|
||||
if($("#backBtn").attr("id")){
|
||||
$("#backBtn").click();
|
||||
}else{
|
||||
$.closeWindow();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if($("#actionForm").attr("forward")){//auto forwar to actionForm forward attr
|
||||
document.location.href=$("#actionForm").attr("forward");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
beforeSubmit: function(arr, $form, options) { //before submit
|
||||
$.loading();//loading icon
|
||||
if (typeof(beforeSubmit) == "function"){
|
||||
return beforeSubmit();//callback
|
||||
}
|
||||
},
|
||||
error : function(a, b, c) {//submit error
|
||||
$.unloading();
|
||||
$.alert({content:$.platform.messages.submit.errorText,type:"error"});
|
||||
}
|
||||
});
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
}
|
||||
form.classList.add('was-validated');
|
||||
}, false);
|
||||
});
|
||||
|
||||
$.dataGridSelRowsData=function(dataGridElement){
|
||||
return $(dataGridElement).bootstrapTable('getSelections');
|
||||
};
|
||||
|
||||
|
||||
|
||||
var curExpandNode = null;
|
||||
|
||||
$.tree=function (treeSettings){
|
||||
|
||||
function singlePath(newNode) {
|
||||
@@ -696,5 +676,4 @@ $(function(){
|
||||
}
|
||||
);
|
||||
};//end tree
|
||||
|
||||
});//jquery end
|
||||
});//jquery end
|
||||
@@ -35,11 +35,11 @@
|
||||
</head>
|
||||
<body>
|
||||
<div style="display:none">
|
||||
<form id="actionForm" method="post" action="<@base/>/groupPrivileges/insert">
|
||||
<form id="actionForm" method="post" action="<@base/>/groupPrivileges/insert" class="needs-validation" novalidate>
|
||||
<table>
|
||||
<tr><td></td><td><input type="text" id="groupId" name="groupId" value="${groupId}"/></td></tr>
|
||||
<tr><td></td><td><input type="text" id="appId" name="appId" value=""/></td></tr>
|
||||
<tr><td colspan="2"><input id="submitBtn" type="button" value="submit"></input></td></tr>
|
||||
<tr><td colspan="2"><input id="submitBtn" type="submit" value="submit"></input></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -37,13 +37,13 @@
|
||||
<body>
|
||||
|
||||
<div style="display:none">
|
||||
<form id="actionForm" method="post" action="<@base/>/groupMember/insert">
|
||||
<form id="actionForm" method="post" action="<@base/>/groupMember/insert" class="needs-validation" novalidate>
|
||||
<table>
|
||||
<tr><td></td><td><input type="text" id="groupId" name="groupId" value="${group.id}"/></td></tr>
|
||||
<tr><td></td><td><input type="text" id="groupName" name="groupName" value="${group.name}"/></td></tr>
|
||||
<tr><td></td><td><input type="text" id="memberId" name="memberId" value=""/></td></tr>
|
||||
<tr><td></td><td><input type="text" id="memberName" name="memberName" value=""/></td></tr>
|
||||
<tr><td colspan="2"><input id="submitBtn" type="button" value="submit"></input></td></tr>
|
||||
<tr><td colspan="2"><input id="submitBtn" type="submit" value="submit"></input></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div style="display:none1">
|
||||
<form id="actionForm" method="post" action="<@base/>/rolemembers/insert">
|
||||
<div style="display:none">
|
||||
<form id="actionForm" method="post" action="<@base/>/rolemembers/insert" class="needs-validation" novalidate>
|
||||
<table>
|
||||
<tr><td></td><td><input type="text" id="roleId" name="roleId" value="${role.id}"/></td></tr>
|
||||
<tr><td></td><td><input type="text" id="roleName" name="roleName" value="${role.name}"/></td></tr>
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.util.Date;
|
||||
import javax.servlet.ServletException;
|
||||
import org.apache.ibatis.io.VFS;
|
||||
import org.apache.mybatis.jpa.SpringBootVFS;
|
||||
import org.maxkey.web.InitApplicationContext;
|
||||
import org.maxkey.web.InitializeContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
@@ -24,7 +24,7 @@ public class MaxKeyApplication extends SpringBootServletInitializer {
|
||||
VFS.addImplClass(SpringBootVFS.class);
|
||||
ConfigurableApplicationContext applicationContext =
|
||||
SpringApplication.run(MaxKeyApplication.class, args);
|
||||
InitApplicationContext initWebContext = new InitApplicationContext(applicationContext);
|
||||
InitializeContext initWebContext = new InitializeContext(applicationContext);
|
||||
try {
|
||||
initWebContext.init(null);
|
||||
} catch (ServletException e) {
|
||||
|
||||
@@ -6,7 +6,6 @@ import org.maxkey.constants.ConstantsProtocols;
|
||||
import org.maxkey.crypto.ReciprocalUtils;
|
||||
import org.maxkey.dao.service.AccountsService;
|
||||
import org.maxkey.dao.service.AppsService;
|
||||
import org.maxkey.dao.service.MyAppsListService;
|
||||
import org.maxkey.dao.service.UserInfoService;
|
||||
import org.maxkey.domain.Accounts;
|
||||
import org.maxkey.domain.UserInfo;
|
||||
@@ -42,9 +41,6 @@ public class AppListController {
|
||||
@Autowired
|
||||
protected JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Autowired
|
||||
MyAppsListService myAppsListService;
|
||||
|
||||
@Autowired
|
||||
AccountsService appUsersService;
|
||||
|
||||
@@ -82,7 +78,7 @@ public class AppListController {
|
||||
UserApps userApplications = new UserApps();
|
||||
userApplications.setUsername(WebContext.getUserInfo().getUsername());
|
||||
|
||||
List<UserApps> appList = myAppsListService.queryMyApps(userApplications);
|
||||
List<UserApps> appList = appsService.queryMyApps(userApplications);
|
||||
for (UserApps app : appList) {
|
||||
WebContext.setAttribute(app.getId(), app.getIcon());
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.maxkey.web.contorller;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import org.maxkey.constants.ConstantsOperateMessage;
|
||||
import org.maxkey.dao.service.MyProfileService;
|
||||
import org.maxkey.dao.service.UserInfoService;
|
||||
import org.maxkey.domain.UserInfo;
|
||||
import org.maxkey.web.WebContext;
|
||||
@@ -27,9 +26,6 @@ public class ProfileController {
|
||||
@Autowired
|
||||
private UserInfoService userInfoService;
|
||||
|
||||
@Autowired
|
||||
private MyProfileService myProfileService;
|
||||
|
||||
@RequestMapping(value = { "/myProfile" })
|
||||
public ModelAndView forwardBasic() {
|
||||
ModelAndView modelAndView = new ModelAndView("profile/myProfile");
|
||||
@@ -69,7 +65,7 @@ public class ProfileController {
|
||||
// userInfo.setExtraAttribute(extraAttribute);
|
||||
// }
|
||||
|
||||
if (myProfileService.updateProfile(userInfo) > 0) {
|
||||
if (userInfoService.updateProfile(userInfo) > 0) {
|
||||
new Message(
|
||||
WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),
|
||||
userInfo, MessageType.success,
|
||||
|
||||
Reference in New Issue
Block a user