代码优化,删除UserAdjoint次要功能

This commit is contained in:
shimingxy 2024-04-20 11:48:15 +08:00
parent 8e1a09566a
commit 38c09792c0
16 changed files with 31 additions and 647 deletions

View File

@ -110,8 +110,8 @@ public class ApplicationAutoConfiguration {
if(_logger.isTraceEnabled()) {
_logger.trace("Password Encoders :");
for (String key : encoders.keySet()) {
_logger.trace("{}= {}" ,String.format("%-10s", key), encoders.get(key).getClass().getName());
for (Map.Entry<String,PasswordEncoder> entry : encoders.entrySet()) {
_logger.trace("{}= {}" ,String.format("%-10s", entry.getKey()), entry.getValue().getClass().getName());
}
}
_logger.debug("{} is default encoder" , idForEncode);
@ -140,7 +140,7 @@ public class ApplicationAutoConfiguration {
* @return
*/
@Bean
public KeyStoreLoader spKeyStoreLoader(
public KeyStoreLoader serviceProviderKeyStoreLoader(
@Value("${maxkey.saml.v20.sp.issuing.entity.id}") String entityName,
@Value("${maxkey.saml.v20.sp.keystore.password}") String keystorePassword,
@Value("${maxkey.saml.v20.sp.keystore}") Resource keystoreFile) {
@ -173,7 +173,7 @@ public class ApplicationAutoConfiguration {
IdGenerator idGenerator = new IdGenerator(strategy);
SnowFlakeId snowFlakeId = new SnowFlakeId(datacenterId,machineId);
idGenerator.setSnowFlakeId(snowFlakeId);
WebContext.idGenerator = idGenerator;
WebContext.setIdGenerator(idGenerator);
return idGenerator;
}

View File

@ -18,6 +18,7 @@
package org.dromara.maxkey.configuration;
import org.apache.commons.lang3.StringUtils;
import org.dromara.maxkey.constants.ConstsDatabase;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
@ -73,7 +74,7 @@ public class ApplicationConfig {
@Value("${maxkey.notices.visible:false}")
private boolean noticesVisible;
public static String databaseProduct = "MySQL";
static String databaseProduct = ConstsDatabase.MYSQL;
@Autowired
EmailConfig emailConfig;
@ -236,6 +237,14 @@ public class ApplicationConfig {
this.noticesVisible = noticesVisible;
}
public static String getDatabaseProduct() {
return databaseProduct;
}
public static void setDatabaseProduct(String databaseProduct) {
ApplicationConfig.databaseProduct = databaseProduct;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();

View File

@ -21,21 +21,18 @@ import org.dromara.maxkey.configuration.ApplicationConfig;
public class ConstsDatabase {
public static String MYSQL = "MySQL";
public static final String MYSQL = "MySQL";
public static String POSTGRESQL = "PostgreSQL";
public static final String POSTGRESQL = "PostgreSQL";
public static String ORACLE = "Oracle";
public static final String ORACLE = "Oracle";
public static String MSSQLSERVER = "SQL Server";
public static final String MSSQLSERVER = "SQL Server";
public static String DB2 = "db2";
public static final String DB2 = "db2";
public static boolean compare(String databaseProduct) {
if(databaseProduct.equalsIgnoreCase(ApplicationConfig.databaseProduct)) {
return true;
}
return false;
return databaseProduct.equalsIgnoreCase(ApplicationConfig.getDatabaseProduct());
}
}

View File

@ -290,8 +290,6 @@ public class UserInfo extends JpaEntity implements Serializable {
List<Organizations> depts;
List<UserInfoAdjoint> adjoints;
public static class ONLINE {
// 在线
public static final int ONLINE = 1;
@ -1318,14 +1316,6 @@ public class UserInfo extends JpaEntity implements Serializable {
this.depts = depts;
}
public List<UserInfoAdjoint> getAdjoints() {
return adjoints;
}
public void setAdjoints(List<UserInfoAdjoint> adjoints) {
this.adjoints = adjoints;
}
public String getInstId() {
return instId;
}

View File

@ -1,324 +0,0 @@
/*
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.maxkey.entity;
import java.io.Serializable;
import org.dromara.mybatis.jpa.entity.JpaEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
@Entity
@Table(name = "MXK_USERINFO_ADJUNCT")
public class UserInfoAdjoint extends JpaEntity implements Serializable {
/**
*
*/
private static final long serialVersionUID = -8634054312223379561L;
@Id
@Column
@GeneratedValue
String id;
protected String displayName;
@Column
protected String userId;
// for work
@Column
protected String workCountry;
@Column
protected String workRegion;// province;
@Column
protected String workLocality;// city;
@Column
protected String workStreetAddress;
@Column
protected String workAddressFormatted;
@Column
protected String workEmail;
@Column
protected String workPhoneNumber;
@Column
protected String workPostalCode;
@Column
protected String workFax;
@Column
protected String costCenter;
@Column
protected String organization;
@Column
protected String division;
@Column
protected String departmentId;
@Column
protected String department;
@Column
protected String jobTitle;
@Column
protected String jobLevel;
@Column
protected String managerId;
@Column
protected String manager;
@Column
protected String assistantId;
@Column
protected String assistant;
@Column
protected String entryDate;
@Column
protected String quitDate;
@Column
private String instId;
private String instName;
public UserInfoAdjoint() {
super();
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getWorkCountry() {
return workCountry;
}
public void setWorkCountry(String workCountry) {
this.workCountry = workCountry;
}
public String getWorkRegion() {
return workRegion;
}
public void setWorkRegion(String workRegion) {
this.workRegion = workRegion;
}
public String getWorkLocality() {
return workLocality;
}
public void setWorkLocality(String workLocality) {
this.workLocality = workLocality;
}
public String getWorkStreetAddress() {
return workStreetAddress;
}
public void setWorkStreetAddress(String workStreetAddress) {
this.workStreetAddress = workStreetAddress;
}
public String getWorkAddressFormatted() {
return workAddressFormatted;
}
public void setWorkAddressFormatted(String workAddressFormatted) {
this.workAddressFormatted = workAddressFormatted;
}
public String getWorkEmail() {
return workEmail;
}
public void setWorkEmail(String workEmail) {
this.workEmail = workEmail;
}
public String getWorkPhoneNumber() {
return workPhoneNumber;
}
public void setWorkPhoneNumber(String workPhoneNumber) {
this.workPhoneNumber = workPhoneNumber;
}
public String getWorkPostalCode() {
return workPostalCode;
}
public void setWorkPostalCode(String workPostalCode) {
this.workPostalCode = workPostalCode;
}
public String getWorkFax() {
return workFax;
}
public void setWorkFax(String workFax) {
this.workFax = workFax;
}
public String getCostCenter() {
return costCenter;
}
public void setCostCenter(String costCenter) {
this.costCenter = costCenter;
}
public String getOrganization() {
return organization;
}
public void setOrganization(String organization) {
this.organization = organization;
}
public String getDivision() {
return division;
}
public void setDivision(String division) {
this.division = division;
}
public String getDepartmentId() {
return departmentId;
}
public void setDepartmentId(String departmentId) {
this.departmentId = departmentId;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getJobTitle() {
return jobTitle;
}
public void setJobTitle(String jobTitle) {
this.jobTitle = jobTitle;
}
public String getJobLevel() {
return jobLevel;
}
public void setJobLevel(String jobLevel) {
this.jobLevel = jobLevel;
}
public String getManagerId() {
return managerId;
}
public void setManagerId(String managerId) {
this.managerId = managerId;
}
public String getManager() {
return manager;
}
public void setManager(String manager) {
this.manager = manager;
}
public String getAssistantId() {
return assistantId;
}
public void setAssistantId(String assistantId) {
this.assistantId = assistantId;
}
public String getAssistant() {
return assistant;
}
public void setAssistant(String assistant) {
this.assistant = assistant;
}
public String getEntryDate() {
return entryDate;
}
public void setEntryDate(String entryDate) {
this.entryDate = entryDate;
}
public String getQuitDate() {
return quitDate;
}
public void setQuitDate(String quitDate) {
this.quitDate = quitDate;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getInstId() {
return instId;
}
public void setInstId(String instId) {
this.instId = instId;
}
public String getInstName() {
return instName;
}
public void setInstName(String instName) {
this.instName = instName;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("UserInfoAdjoint [id=");
builder.append(id);
builder.append(", displayName=");
builder.append(displayName);
builder.append(", workCountry=");
builder.append(workCountry);
builder.append(", workRegion=");
builder.append(workRegion);
builder.append(", workLocality=");
builder.append(workLocality);
builder.append(", workStreetAddress=");
builder.append(workStreetAddress);
builder.append(", workAddressFormatted=");
builder.append(workAddressFormatted);
builder.append(", workEmail=");
builder.append(workEmail);
builder.append(", workPhoneNumber=");
builder.append(workPhoneNumber);
builder.append(", workPostalCode=");
builder.append(workPostalCode);
builder.append(", workFax=");
builder.append(workFax);
builder.append(", costCenter=");
builder.append(costCenter);
builder.append(", organization=");
builder.append(organization);
builder.append(", division=");
builder.append(division);
builder.append(", departmentId=");
builder.append(departmentId);
builder.append(", department=");
builder.append(department);
builder.append(", jobTitle=");
builder.append(jobTitle);
builder.append(", jobLevel=");
builder.append(jobLevel);
builder.append(", managerId=");
builder.append(managerId);
builder.append(", manager=");
builder.append(manager);
builder.append(", assistantId=");
builder.append(assistantId);
builder.append(", assistant=");
builder.append(assistant);
builder.append(", entryDate=");
builder.append(entryDate);
builder.append(", quitDate=");
builder.append(quitDate);
builder.append("]");
return builder.toString();
}
}

View File

@ -96,7 +96,7 @@ public class InitializeContext extends HttpServlet {
logger.info("List DatabaseMetaData Variables ");
Connection connection = ((javax.sql.DataSource) applicationContext.getBean("dataSource")).getConnection();
DatabaseMetaData databaseMetaData = connection.getMetaData();
ApplicationConfig.databaseProduct = databaseMetaData.getDatabaseProductName();
ApplicationConfig.setDatabaseProduct(databaseMetaData.getDatabaseProductName());
logger.info("DatabaseProductName : {}", databaseMetaData.getDatabaseProductName());
logger.info("DatabaseProductVersion: {}" ,databaseMetaData.getDatabaseProductVersion());

View File

@ -523,7 +523,11 @@ public final class WebContext {
return idGenerator.generate();
}
public static ModelAndView redirect(String redirectUrl) {
public static void setIdGenerator(IdGenerator idGenerator) {
WebContext.idGenerator = idGenerator;
}
public static ModelAndView redirect(String redirectUrl) {
return new ModelAndView("redirect:" + redirectUrl);
}

View File

@ -1,31 +0,0 @@
/*
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.maxkey.persistence.mapper;
import org.dromara.maxkey.entity.UserInfoAdjoint;
import org.dromara.mybatis.jpa.IJpaMapper;
/**
* @author Crystal.Sea
*
*/
public interface UserInfoAdjointMapper extends IJpaMapper<UserInfoAdjoint>{
}

View File

@ -25,7 +25,6 @@ import org.dromara.maxkey.constants.ConstsStatus;
import org.dromara.maxkey.entity.ChangePassword;
import org.dromara.maxkey.entity.Organizations;
import org.dromara.maxkey.entity.UserInfo;
import org.dromara.maxkey.entity.UserInfoAdjoint;
import org.dromara.mybatis.jpa.IJpaMapper;
@ -46,8 +45,6 @@ public interface UserInfoMapper extends IJpaMapper<UserInfo>{
public List<Organizations> findDeptsByUserId(String userId);
public List<UserInfoAdjoint> findAdjointsByUserId(String userId);
public void updateLocked(UserInfo userInfo);
public void updateLockout(UserInfo userInfo);

View File

@ -1,45 +0,0 @@
/*
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.maxkey.persistence.service;
import org.dromara.maxkey.entity.UserInfoAdjoint;
import org.dromara.maxkey.persistence.mapper.UserInfoAdjointMapper;
import org.dromara.mybatis.jpa.JpaService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;
@Repository
public class UserInfoAdjointService extends JpaService<UserInfoAdjoint>{
final static Logger _logger = LoggerFactory.getLogger(UserInfoAdjointService.class);
public UserInfoAdjointService() {
super(UserInfoAdjointMapper.class);
}
/* (non-Javadoc)
* @see com.connsec.db.service.BaseService#getMapper()
*/
@Override
public UserInfoAdjointMapper getMapper() {
return (UserInfoAdjointMapper)super.getMapper();
}
}

View File

@ -166,7 +166,6 @@ public class UserInfoService extends JpaService<UserInfo> {
public UserInfo findUserRelated(String userId) {
UserInfo loadUserInfo =this.get(userId);
loadUserInfo.setDepts(getMapper().findDeptsByUserId(userId));
loadUserInfo.setAdjoints(getMapper().findAdjointsByUserId(userId));
return loadUserInfo;
}

View File

@ -1,52 +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.dromara.maxkey.persistence.mapper.UserInfoAdjointMapper">
<sql id="where_statement">
<if test="id != null and id != ''">
and id = #{id}
</if>
<if test="userId != null and userId != ''">
and userid = #{userId}
</if>
</sql>
<select id="fetchPageResults" parameterType="UserInfoAdjoint" resultType="UserInfoAdjoint">
select
*
from
mxk_userinfo_adjunct
where
instid = #{instId}
<include refid="where_statement"/>
</select>
<update id="logisticDelete" parameterType="UserInfoAdjoint" >
update mxk_userinfo_adjunct set
status = '2'
where instid = #{instId}
<if test="id != null">
and id = #{id}
</if>
<if test="name != name">
and NAME = #{name}
</if>
</update>
<update id="logisticBatchDelete" parameterType="java.util.List">
update mxk_userinfo_adjunct
set status='2'
where instid = #{instId}
and id in
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</update>
</mapper>

View File

@ -252,11 +252,4 @@
and ua.userid=#{value}
</select>
<select id="findAdjointsByUserId" parameterType="string" resultType="UserInfoAdjoint">
select
*
from mxk_userinfo_adjunct
where userid=#{value}
</select>
</mapper>

View File

@ -87,7 +87,7 @@ public class ConsumerEndpoint {
private BindingAdapter bindingAdapter;
@Autowired
@Qualifier("spKeyStoreLoader")
@Qualifier("serviceProviderKeyStoreLoader")
private KeyStoreLoader keyStoreLoader;
@Autowired

View File

@ -22,7 +22,6 @@ import org.dromara.maxkey.authn.annotation.CurrentUser;
import org.dromara.maxkey.entity.Localization;
import org.dromara.maxkey.entity.Message;
import org.dromara.maxkey.entity.UserInfo;
import org.dromara.maxkey.entity.UserInfoAdjoint;
import org.dromara.maxkey.persistence.repository.LocalizationRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -74,15 +73,15 @@ public class LocalizationController {
if(StringUtils.isBlank(localization.getId())){
localization.setId(localization.generateId());
if(localizationRepository.insert(localization)) {
return new Message<UserInfoAdjoint>(Message.SUCCESS).buildResponse();
return new Message<Localization>(Message.SUCCESS).buildResponse();
} else {
return new Message<UserInfoAdjoint>(Message.FAIL).buildResponse();
return new Message<Localization>(Message.FAIL).buildResponse();
}
}else {
if(localizationRepository.update(localization)) {
return new Message<UserInfoAdjoint>(Message.SUCCESS).buildResponse();
return new Message<Localization>(Message.SUCCESS).buildResponse();
} else {
return new Message<UserInfoAdjoint>(Message.FAIL).buildResponse();
return new Message<Localization>(Message.FAIL).buildResponse();
}
}
}

View File

@ -1,152 +0,0 @@
/*
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dromara.maxkey.web.idm.contorller;
import org.dromara.maxkey.authn.annotation.CurrentUser;
import org.dromara.maxkey.entity.Message;
import org.dromara.maxkey.entity.UserInfo;
import org.dromara.maxkey.entity.UserInfoAdjoint;
import org.dromara.maxkey.persistence.service.UserInfoAdjointService;
import org.dromara.mybatis.jpa.entity.JpaPageResults;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
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.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping(value={"/useradjoint"})
public class UserAdjointController {
final static Logger logger = LoggerFactory.getLogger(UserAdjointController.class);
@Autowired
UserInfoAdjointService userInfoAdjointService;
@RequestMapping(value={"/list/{userId}"})
public ModelAndView userinfoAdjointList(@PathVariable("userId") String userId){
ModelAndView modelAndView=new ModelAndView("/userinfo/userinfoAdjointList");
modelAndView.addObject("userId", userId);
return modelAndView;
}
@RequestMapping(value = { "/grid" })
@ResponseBody
public JpaPageResults<UserInfoAdjoint> queryDataGrid(
@ModelAttribute("userInfoAdjoint") UserInfoAdjoint userInfoAdjoint,
@CurrentUser UserInfo currentUser){
logger.debug("userInfoAdjoint {}" , userInfoAdjoint);
userInfoAdjoint.setInstId(currentUser.getInstId());
return userInfoAdjointService.fetchPageResults(userInfoAdjoint);
}
@RequestMapping(value = { "/forwardAdd/{userId}" })
public ModelAndView forwardAdd(@PathVariable("userId") String userId) {
ModelAndView modelAndView=new ModelAndView("/userinfo/userinfoAdjointAdd");
modelAndView.addObject("userId", userId);
return modelAndView;
}
@RequestMapping(value = { "/forwardUpdate/{id}" })
public ModelAndView forwardUpdate(@PathVariable("id") String id) {
ModelAndView modelAndView=new ModelAndView("/userinfo/userinfoAdjointUpdate");
UserInfoAdjoint userInfoAdjoint=userInfoAdjointService.get(id);
modelAndView.addObject("model",userInfoAdjoint);
return modelAndView;
}
@ResponseBody
@RequestMapping(value={"/add"})
public ResponseEntity<?> insert(
@ModelAttribute("userInfoAdjoint") UserInfoAdjoint userInfoAdjoint,
@CurrentUser UserInfo currentUser) {
logger.debug("-Add : {}" , userInfoAdjoint);
userInfoAdjoint.setInstId(currentUser.getInstId());
if (userInfoAdjointService.insert(userInfoAdjoint)) {
return new Message<UserInfoAdjoint>(Message.SUCCESS).buildResponse();
} else {
return new Message<UserInfoAdjoint>(Message.FAIL).buildResponse();
}
}
/**
* 查询
* @param group
* @return
*/
@ResponseBody
@RequestMapping(value={"/query"})
public ResponseEntity<?> query(
@ModelAttribute("userInfoAdjoint") UserInfoAdjoint userInfoAdjoint,
@CurrentUser UserInfo currentUser) {
logger.debug("-query : {} " , userInfoAdjoint);
userInfoAdjoint.setInstId(currentUser.getInstId());
if (userInfoAdjointService.query(userInfoAdjoint)!=null) {
return new Message<UserInfoAdjoint>(Message.SUCCESS).buildResponse();
} else {
return new Message<UserInfoAdjoint>(Message.FAIL).buildResponse();
}
}
/**
* 修改
* @param group
* @return
*/
@ResponseBody
@RequestMapping(value={"/update"})
public ResponseEntity<?> update(
@ModelAttribute("userInfoAdjoint") UserInfoAdjoint userInfoAdjoint,
@CurrentUser UserInfo currentUser) {
logger.debug("-update userInfoAdjoint : {}" , userInfoAdjoint);
userInfoAdjoint.setInstId(currentUser.getInstId());
if (userInfoAdjointService.update(userInfoAdjoint)) {
return new Message<UserInfoAdjoint>(Message.SUCCESS).buildResponse();
} else {
return new Message<UserInfoAdjoint>(Message.FAIL).buildResponse();
}
}
@ResponseBody
@RequestMapping(value={"/delete"})
public ResponseEntity<?> delete(@ModelAttribute("userInfoAdjoint") UserInfoAdjoint userInfoAdjoint) {
logger.debug("-delete group : {}" , userInfoAdjoint);
if (userInfoAdjointService.deleteBatch(userInfoAdjoint.getId())) {
return new Message<UserInfoAdjoint>(Message.SUCCESS).buildResponse();
} else {
return new Message<UserInfoAdjoint>(Message.FAIL).buildResponse();
}
}
}