diff --git a/coolstore-partner-common/coolstore-partner-common.iml b/coolstore-partner-common/coolstore-partner-common.iml index 722cf3d7f..6ae94a6ff 100644 --- a/coolstore-partner-common/coolstore-partner-common.iml +++ b/coolstore-partner-common/coolstore-partner-common.iml @@ -57,5 +57,19 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/coolstore-partner-common/pom.xml b/coolstore-partner-common/pom.xml index f98b7579f..af73c2d2a 100644 --- a/coolstore-partner-common/pom.xml +++ b/coolstore-partner-common/pom.xml @@ -58,6 +58,18 @@ org.springframework.boot spring-boot-starter-web + + cn.hutool + hutool-all + + + com.github.pagehelper + pagehelper-spring-boot-starter + + + com.coolstore + coolstore-base + \ No newline at end of file diff --git a/coolstore-partner-common/src/main/java/com/cool/store/constants/CommonConstants.java b/coolstore-partner-common/src/main/java/com/cool/store/constants/CommonConstants.java index c3b1d79c7..e98b61ff8 100644 --- a/coolstore-partner-common/src/main/java/com/cool/store/constants/CommonConstants.java +++ b/coolstore-partner-common/src/main/java/com/cool/store/constants/CommonConstants.java @@ -22,6 +22,13 @@ public class CommonConstants { public static final int REFRESH_TOKEN_EXPIRE = 60*60*24*30; + /** + * 系统用户id + */ + public static final String SYSTEM_USER_ID = "system"; + public static final String COMMA = ","; + + public static final int ZERO = 0; public static final int ONE = 1; public static final int TWO = 2; diff --git a/coolstore-partner-common/src/main/java/com/cool/store/utils/ScriptUtil.java b/coolstore-partner-common/src/main/java/com/cool/store/utils/ScriptUtil.java new file mode 100644 index 000000000..98475246d --- /dev/null +++ b/coolstore-partner-common/src/main/java/com/cool/store/utils/ScriptUtil.java @@ -0,0 +1,422 @@ +package com.cool.store.utils; + +import org.apache.commons.collections4.MapUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.ibatis.session.ExecutorType; +import org.apache.ibatis.session.SqlSession; +import org.mybatis.spring.SqlSessionTemplate; +import org.mybatis.spring.SqlSessionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.support.EncodedResource; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; +import org.springframework.jdbc.datasource.init.*; +import org.springframework.lang.Nullable; +import org.springframework.stereotype.Component; +import org.springframework.util.Assert; +import org.springframework.util.StringUtils; + +import java.io.IOException; +import java.io.LineNumberReader; +import java.sql.Connection; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * @author zhangchenbiao + * @FileName: ScriptUtil + * @Description: 脚本工具 + * @date 2022-01-21 16:48 + */ +@Component +public class ScriptUtil { + + /** + * Default statement separator within SQL scripts: {@code ";"}. + */ + public static final String DEFAULT_STATEMENT_SEPARATOR = ";"; + + /** + * Fallback statement separator within SQL scripts: {@code "\n"}. + *

Used if neither a custom separator nor the + * {@link #DEFAULT_STATEMENT_SEPARATOR} is present in a given script. + */ + public static final String FALLBACK_STATEMENT_SEPARATOR = "\n"; + + + public static final String EOF_STATEMENT_SEPARATOR = "^^^ END OF SCRIPT ^^^"; + + /** + * Default prefix for single-line comments within SQL scripts: {@code "--"}. + */ + public static final String DEFAULT_COMMENT_PREFIX = "--"; + + /** + * Default start delimiter for block comments within SQL scripts: {@code "/*"}. + */ + public static final String DEFAULT_BLOCK_COMMENT_START_DELIMITER = "/*"; + + /** + * Default end delimiter for block comments within SQL scripts: "*/". + */ + public static final String DEFAULT_BLOCK_COMMENT_END_DELIMITER = "*/"; + + /** + * 变量开始字符$ + */ + public static final String VARIABLE_START_DELIMITER = "\\$\\{"; + + /** + * 变量开始字符# + */ + public static final String VARIABLE_START_DELIMITER2 = "\\#\\{"; + + /** + * 变量结束字符 + */ + public static final String VARIABLE_END_DELIMITER = "}"; + + /** + * 单引号 + */ + public static final String SINGLE_QUOTE = "'"; + + + private final SqlSessionTemplate sqlSessionTemplate; + private final DataSourceTransactionManager dataSourceTransactionManager; + + + @Autowired + public ScriptUtil(SqlSessionTemplate sqlSessionTemplate, DataSourceTransactionManager dataSourceTransactionManager) { + this.sqlSessionTemplate = sqlSessionTemplate; + this.dataSourceTransactionManager = dataSourceTransactionManager; + } + + + private static final Log logger = LogFactory.getLog(ScriptUtil.class); + + /** + * Split an SQL script into separate statements delimited by the provided + * separator string. Each individual statement will be added to the provided + * {@code List}. + *

Within the script, the provided {@code commentPrefix} will be honored: + * any text beginning with the comment prefix and extending to the end of the + * line will be omitted from the output. Similarly, the provided + * {@code blockCommentStartDelimiter} and {@code blockCommentEndDelimiter} + * delimiters will be honored: any text enclosed in a block comment will be + * omitted from the output. In addition, multiple adjacent whitespace characters + * will be collapsed into a single space. + * @param resource the resource from which the script was read + * @param script the SQL script; never {@code null} or empty + * @param separator text separating each statement — typically a ';' or + * newline character; never {@code null} + * @param commentPrefix the prefix that identifies SQL line comments — + * typically "--"; never {@code null} or empty + * @param blockCommentStartDelimiter the start block comment delimiter; + * never {@code null} or empty + * @param blockCommentEndDelimiter the end block comment delimiter; + * never {@code null} or empty + * @param statements the list that will contain the individual statements + * @throws ScriptException if an error occurred while splitting the SQL script + */ + public static void splitSqlScript(@Nullable EncodedResource resource, String script, + String separator, String commentPrefix, String blockCommentStartDelimiter, + String blockCommentEndDelimiter, List statements) throws ScriptException { + + Assert.hasText(script, "'script' must not be null or empty"); + Assert.notNull(separator, "'separator' must not be null"); + Assert.hasText(commentPrefix, "'commentPrefix' must not be null or empty"); + Assert.hasText(blockCommentStartDelimiter, "'blockCommentStartDelimiter' must not be null or empty"); + Assert.hasText(blockCommentEndDelimiter, "'blockCommentEndDelimiter' must not be null or empty"); + + StringBuilder sb = new StringBuilder(); + boolean inSingleQuote = false; + boolean inDoubleQuote = false; + boolean inEscape = false; + + for (int i = 0; i < script.length(); i++) { + char c = script.charAt(i); + if (inEscape) { + inEscape = false; + sb.append(c); + continue; + } + // MySQL style escapes + if (c == '\\') { + inEscape = true; + sb.append(c); + continue; + } + if (!inDoubleQuote && (c == '\'')) { + inSingleQuote = !inSingleQuote; + } + else if (!inSingleQuote && (c == '"')) { + inDoubleQuote = !inDoubleQuote; + } + if (!inSingleQuote && !inDoubleQuote) { + if (script.startsWith(separator, i)) { + // We've reached the end of the current statement + if (sb.length() > 0) { + statements.add(sb.toString()); + sb = new StringBuilder(); + } + i += separator.length() - 1; + continue; + } + else if (script.startsWith(commentPrefix, i)) { + // Skip over any content from the start of the comment to the EOL + int indexOfNextNewline = script.indexOf('\n', i); + if (indexOfNextNewline > i) { + i = indexOfNextNewline; + continue; + } + else { + // If there's no EOL, we must be at the end of the script, so stop here. + break; + } + } + else if (script.startsWith(blockCommentStartDelimiter, i)) { + // Skip over any block comments + int indexOfCommentEnd = script.indexOf(blockCommentEndDelimiter, i); + if (indexOfCommentEnd > i) { + i = indexOfCommentEnd + blockCommentEndDelimiter.length() - 1; + continue; + } + else { + throw new ScriptParseException( + "Missing block comment end delimiter: " + blockCommentEndDelimiter, resource); + } + } + else if (c == ' ' || c == '\n' || c == '\t') { + // Avoid multiple adjacent whitespace characters + if (sb.length() > 0 && sb.charAt(sb.length() - 1) != ' ') { + c = ' '; + } + else { + continue; + } + } + } + sb.append(c); + } + + if (StringUtils.hasText(sb)) { + statements.add(sb.toString()); + } + } + + /** + * Read a script from the provided resource, using the supplied comment prefix + * and statement separator, and build a {@code String} containing the lines. + *

Lines beginning with the comment prefix are excluded from the + * results; however, line comments anywhere else — for example, within + * a statement — will be included in the results. + * @param resource the {@code EncodedResource} containing the script + * to be processed + * @param commentPrefix the prefix that identifies comments in the SQL script — + * typically "--" + * @param separator the statement separator in the SQL script — typically ";" + * @return a {@code String} containing the script lines + * @throws IOException in case of I/O errors + */ + private static String readScript(EncodedResource resource, @Nullable String commentPrefix, + @Nullable String separator) throws IOException { + + LineNumberReader lnr = new LineNumberReader(resource.getReader()); + try { + return readScript(lnr, commentPrefix, separator); + } + finally { + lnr.close(); + } + } + + /** + * Read a script from the provided {@code LineNumberReader}, using the supplied + * comment prefix and statement separator, and build a {@code String} containing + * the lines. + *

Lines beginning with the comment prefix are excluded from the + * results; however, line comments anywhere else — for example, within + * a statement — will be included in the results. + * @param lineNumberReader the {@code LineNumberReader} containing the script + * to be processed + * @param commentPrefix the prefix that identifies comments in the SQL script — + * typically "--" + * @param separator the statement separator in the SQL script — typically ";" + * @return a {@code String} containing the script lines + * @throws IOException in case of I/O errors + */ + public static String readScript(LineNumberReader lineNumberReader, @Nullable String commentPrefix, + @Nullable String separator) throws IOException { + + String currentStatement = lineNumberReader.readLine(); + StringBuilder scriptBuilder = new StringBuilder(); + while (currentStatement != null) { + if (commentPrefix != null && !currentStatement.startsWith(commentPrefix)) { + if (scriptBuilder.length() > 0) { + scriptBuilder.append('\n'); + } + scriptBuilder.append(currentStatement); + } + currentStatement = lineNumberReader.readLine(); + } + appendSeparatorToScriptIfNecessary(scriptBuilder, separator); + return scriptBuilder.toString(); + } + + private static void appendSeparatorToScriptIfNecessary(StringBuilder scriptBuilder, @Nullable String separator) { + if (separator == null) { + return; + } + String trimmed = separator.trim(); + if (trimmed.length() == separator.length()) { + return; + } + // separator ends in whitespace, so we might want to see if the script is trying + // to end the same way + if (scriptBuilder.lastIndexOf(trimmed) == scriptBuilder.length() - trimmed.length()) { + scriptBuilder.append(separator.substring(trimmed.length())); + } + } + + /** + * Does the provided SQL script contain the specified delimiter? + * @param script the SQL script + * @param delim the string delimiting each statement - typically a ';' character + */ + public static boolean containsSqlScriptDelimiters(String script, String delim) { + boolean inLiteral = false; + boolean inEscape = false; + + for (int i = 0; i < script.length(); i++) { + char c = script.charAt(i); + if (inEscape) { + inEscape = false; + continue; + } + // MySQL style escapes + if (c == '\\') { + inEscape = true; + continue; + } + if (c == '\'') { + inLiteral = !inLiteral; + } + if (!inLiteral && script.startsWith(delim, i)) { + return true; + } + } + + return false; + } + + + public void executeSqlScript(EncodedResource resource, Map params) throws ScriptException { + String commentPrefix = DEFAULT_COMMENT_PREFIX; + String separator = DEFAULT_STATEMENT_SEPARATOR; + try { + if (logger.isDebugEnabled()) { + logger.debug("Executing SQL script from " + resource); + } + long startTime = System.currentTimeMillis(); + String script; + try { + script = readScript(resource, commentPrefix, separator); + }catch (IOException ex) { + throw new CannotReadScriptException(resource, ex); + } + if (!EOF_STATEMENT_SEPARATOR.equals(separator) && !containsSqlScriptDelimiters(script, separator)) { + separator = FALLBACK_STATEMENT_SEPARATOR; + } + List statements = new ArrayList<>(); + splitSqlScript(resource, script, separator, commentPrefix, DEFAULT_BLOCK_COMMENT_START_DELIMITER, + DEFAULT_BLOCK_COMMENT_END_DELIMITER, statements); + int stmtNumber = 0; + SqlSession sqlSession = SqlSessionUtils.getSqlSession( + sqlSessionTemplate.getSqlSessionFactory(), ExecutorType.BATCH, + sqlSessionTemplate.getPersistenceExceptionTranslator()); + Connection connection = null; + Statement stmt = null; + try { + connection = sqlSession.getConnection(); + stmt = connection.createStatement(); + connection.setAutoCommit(false); + for (String statement : statements) { + stmtNumber++; + try { + statement = sqlVariableReplace(statement, params); + stmt.execute(statement); + int rowsAffected = stmt.getUpdateCount(); + logger.info(rowsAffected + " returned as update count for SQL: " + statement); + }catch (SQLException ex) { + logger.error(ex); + ex.printStackTrace(); + connection.rollback(); + sqlSession.clearCache(); + throw new ScriptStatementFailedException(statement, stmtNumber, resource, ex); + } + } + connection.commit(); + sqlSession.clearCache(); + }catch (Exception e){ + logger.error(e); + e.printStackTrace(); + connection.rollback(); + sqlSession.clearCache(); + throw new Exception(e); + }finally { + try { + if(Objects.nonNull(stmt)){ + stmt.close(); + } + }catch (Throwable ex) { + logger.trace("Could not close JDBC Statement", ex); + } + try { + if(Objects.nonNull(connection)){ + connection.close(); + } + } catch (SQLException throwables) { + logger.trace("Could not close JDBC Statement", throwables); + } + } + long elapsedTime = System.currentTimeMillis() - startTime; + if (logger.isDebugEnabled()) { + logger.debug("Executed SQL script from " + resource + " in " + elapsedTime + " ms."); + } + }catch (Exception ex) { + if (ex instanceof ScriptException) { + throw (ScriptException) ex; + } + throw new UncategorizedScriptException( + "Failed to execute database script from resource [" + resource + "]", ex); + } + } + + /** + * 处理sql变量 + * @param statement + * @param params + * @return + */ + public String sqlVariableReplace(String statement, Map params){ + if(MapUtils.isEmpty(params)){ + return statement; + } + if(!statement.contains(VARIABLE_START_DELIMITER) && !statement.contains(VARIABLE_END_DELIMITER)){ + return statement; + } + for (String key : params.keySet()) { + String realKey = VARIABLE_START_DELIMITER + key + VARIABLE_END_DELIMITER; + String realKey2 = VARIABLE_START_DELIMITER2 + key + VARIABLE_END_DELIMITER; + statement = statement.replaceAll(realKey, params.get(key).toString()); + statement = statement.replaceAll(realKey2, SINGLE_QUOTE + params.get(key) + SINGLE_QUOTE); + + } + return statement; + } +} diff --git a/coolstore-partner-common/src/main/java/com/cool/store/utils/UUIDUtils.java b/coolstore-partner-common/src/main/java/com/cool/store/utils/UUIDUtils.java new file mode 100644 index 000000000..8ff73fd9b --- /dev/null +++ b/coolstore-partner-common/src/main/java/com/cool/store/utils/UUIDUtils.java @@ -0,0 +1,30 @@ +package com.cool.store.utils; + +import cn.hutool.core.util.IdUtil; +import org.apache.commons.lang3.StringUtils; + +/** + * 唯一性ID工具类 + * + * @author Aaron + * @ClassName UUIDUtils + * @Description 唯一性ID工具类 + */ +public class UUIDUtils { + + /** + * 简化的UUID,去掉了横线,使用性能更好的ThreadLocalRandom生成UUID + */ + public static String get32UUID() { + return IdUtil.fastSimpleUUID(); + } + public static String get8UUID() { + return StringUtils.substring(IdUtil.fastSimpleUUID(),1,9); + } + + public static Long get8LongUuid() { + long uuid = (int) (Math.random() * 90000000 + 10000000); + return uuid; + } + +} diff --git a/coolstore-partner-dao/coolstore-partner-dao.iml b/coolstore-partner-dao/coolstore-partner-dao.iml index 8a308b659..73fd10ece 100644 --- a/coolstore-partner-dao/coolstore-partner-dao.iml +++ b/coolstore-partner-dao/coolstore-partner-dao.iml @@ -84,12 +84,7 @@ - - - - - - + @@ -98,5 +93,12 @@ + + + + + + + \ No newline at end of file diff --git a/coolstore-partner-dao/pom.xml b/coolstore-partner-dao/pom.xml index a498b4666..7eed26b88 100644 --- a/coolstore-partner-dao/pom.xml +++ b/coolstore-partner-dao/pom.xml @@ -50,10 +50,6 @@ 1.3.7 test - - com.github.pagehelper - pagehelper-spring-boot-starter - \ No newline at end of file diff --git a/coolstore-partner-dao/src/main/java/com/cool/store/dao/EnterpriseUserDAO.java b/coolstore-partner-dao/src/main/java/com/cool/store/dao/EnterpriseUserDAO.java index 631f96b49..3eaa573fd 100644 --- a/coolstore-partner-dao/src/main/java/com/cool/store/dao/EnterpriseUserDAO.java +++ b/coolstore-partner-dao/src/main/java/com/cool/store/dao/EnterpriseUserDAO.java @@ -6,6 +6,8 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; /** * @author zhangchenbiao @@ -25,4 +27,18 @@ public class EnterpriseUserDAO { return enterpriseUserMapper.getUserInfoById(enterpriseId, userId); } + public void batchInsertOrUpdate(String eid, List users) { + List result = new ArrayList<>(); + users.forEach(user -> { + if (StringUtils.isBlank(user.getUnionid()) || StringUtils.isBlank(user.getUserId())) { + return; + } + if (StringUtils.isBlank(user.getName())) { + user.setName(user.getUserId()); + } + result.add(user); + }); + enterpriseUserMapper.batchInsertOrUpdate(eid, result); + } + } \ No newline at end of file diff --git a/coolstore-partner-dao/src/main/java/com/cool/store/dao/EnterpriseUserRoleDAO.java b/coolstore-partner-dao/src/main/java/com/cool/store/dao/EnterpriseUserRoleDAO.java index c52b5ebd7..59313499f 100644 --- a/coolstore-partner-dao/src/main/java/com/cool/store/dao/EnterpriseUserRoleDAO.java +++ b/coolstore-partner-dao/src/main/java/com/cool/store/dao/EnterpriseUserRoleDAO.java @@ -1,7 +1,13 @@ package com.cool.store.dao; +import com.cool.store.dto.enterprise.EnterpriseUserRole; +import com.cool.store.mapper.EnterpriseUserMapper; +import com.cool.store.mapper.EnterpriseUserRoleMapper; import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import java.util.List; + /** * @author zhangchenbiao * @date 2023-05-19 02:59 @@ -9,4 +15,11 @@ import org.springframework.stereotype.Service; @Service public class EnterpriseUserRoleDAO { + @Resource + private EnterpriseUserRoleMapper enterpriseUserRoleMapper; + + public Boolean insertBatchUserRole(String eid, List userRole) { + return enterpriseUserRoleMapper.insertBatchUserRole(eid, userRole); + } + } \ No newline at end of file diff --git a/coolstore-partner-dao/src/main/java/com/cool/store/dao/SysRoleDAO.java b/coolstore-partner-dao/src/main/java/com/cool/store/dao/SysRoleDAO.java index bc34287bf..98f44add5 100644 --- a/coolstore-partner-dao/src/main/java/com/cool/store/dao/SysRoleDAO.java +++ b/coolstore-partner-dao/src/main/java/com/cool/store/dao/SysRoleDAO.java @@ -1,6 +1,7 @@ package com.cool.store.dao; import com.cool.store.entity.SysRoleDO; +import com.cool.store.enums.RoleEnum; import com.cool.store.mapper.SysRoleMapper; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -30,4 +31,13 @@ public class SysRoleDAO { return sysRoleMapper.getHighestPrioritySysRoleDoByUserId(enterpriseId, userId); } + public Long getRoleIdByRoleEnum(String eid, String roleEnum) { + + SysRoleDO roleByRoleEnum = sysRoleMapper.getRoleByRoleEnum(eid, roleEnum); + if(roleByRoleEnum==null){ + return Long.valueOf(RoleEnum.getByCode(roleEnum).getId()); + } + return roleByRoleEnum.getId(); + } + } \ No newline at end of file diff --git a/coolstore-partner-dao/src/main/java/com/cool/store/mapper/EnterpriseUserMapper.java b/coolstore-partner-dao/src/main/java/com/cool/store/mapper/EnterpriseUserMapper.java index e3581e4ad..d37a776c6 100644 --- a/coolstore-partner-dao/src/main/java/com/cool/store/mapper/EnterpriseUserMapper.java +++ b/coolstore-partner-dao/src/main/java/com/cool/store/mapper/EnterpriseUserMapper.java @@ -3,6 +3,8 @@ package com.cool.store.mapper; import com.cool.store.entity.EnterpriseUserDO; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * @author zhangchenbiao * @date 2023-05-19 02:58 @@ -30,4 +32,12 @@ public interface EnterpriseUserMapper { * @return */ EnterpriseUserDO getUserInfoById(@Param("enterpriseId")String enterpriseId, @Param("userId")String userId); + + /** + * 批量插入或更新 + * @param enterpriseId + * @param users + */ + void batchInsertOrUpdate(@Param("enterpriseId") String enterpriseId, @Param("list") List users); + } \ No newline at end of file diff --git a/coolstore-partner-dao/src/main/java/com/cool/store/mapper/EnterpriseUserRoleMapper.java b/coolstore-partner-dao/src/main/java/com/cool/store/mapper/EnterpriseUserRoleMapper.java index 1486761f4..9a8b6257e 100644 --- a/coolstore-partner-dao/src/main/java/com/cool/store/mapper/EnterpriseUserRoleMapper.java +++ b/coolstore-partner-dao/src/main/java/com/cool/store/mapper/EnterpriseUserRoleMapper.java @@ -1,8 +1,11 @@ package com.cool.store.mapper; +import com.cool.store.dto.enterprise.EnterpriseUserRole; import com.cool.store.entity.EnterpriseUserRoleDO; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * @author zhangchenbiao * @date 2023-05-19 02:59 @@ -22,4 +25,12 @@ public interface EnterpriseUserRoleMapper { * dateTime:2023-05-19 02:59 */ int updateByPrimaryKeySelective(@Param("record") EnterpriseUserRoleDO record, @Param("enterpriseId") String enterpriseId); + + /** + * 批量插入用户角色 + * @param enterpriseId + * @param userRoles + * @return + */ + Boolean insertBatchUserRole(@Param("eid") String enterpriseId, @Param("userRoles") List userRoles); } \ No newline at end of file diff --git a/coolstore-partner-dao/src/main/java/com/cool/store/mapper/SysRoleMapper.java b/coolstore-partner-dao/src/main/java/com/cool/store/mapper/SysRoleMapper.java index e771d0804..ef52867e4 100644 --- a/coolstore-partner-dao/src/main/java/com/cool/store/mapper/SysRoleMapper.java +++ b/coolstore-partner-dao/src/main/java/com/cool/store/mapper/SysRoleMapper.java @@ -1,8 +1,11 @@ package com.cool.store.mapper; +import com.cool.store.dto.enterprise.EnterpriseUserRole; import com.cool.store.entity.SysRoleDO; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * @author zhangchenbiao * @date 2023-05-19 03:00 @@ -25,4 +28,6 @@ public interface SysRoleMapper { SysRoleDO getHighestPrioritySysRoleDoByUserId(@Param("enterpriseId") String enterpriseId, @Param("userId") String userId); + + SysRoleDO getRoleByRoleEnum(@Param("eid") String enterpriseId, @Param("roleEnum") String roleEnum); } \ No newline at end of file diff --git a/coolstore-partner-dao/src/main/resources/mapper/EnterpriseUserMapper.xml b/coolstore-partner-dao/src/main/resources/mapper/EnterpriseUserMapper.xml index 9cb19f248..35fab65d4 100644 --- a/coolstore-partner-dao/src/main/resources/mapper/EnterpriseUserMapper.xml +++ b/coolstore-partner-dao/src/main/resources/mapper/EnterpriseUserMapper.xml @@ -398,4 +398,73 @@ where user_id = #{userId} + + + + insert into enterprise_user_${eid} ( + id, + user_id, + `name`, + mobile, + email, + active, + order_in_depts, + main_admin, + is_admin, + is_boss, + dingId, + unionid, + is_leader_in_depts, + is_hide, + departments, + `position`, + avatar, + jobnumber, + extattr, + roles, + is_leader, + create_time + ) values + + + + ( + #{it.id, jdbcType=VARCHAR}, + #{it.userId, jdbcType=VARCHAR}, + #{it.name, jdbcType=VARCHAR}, + #{it.mobile, jdbcType=VARCHAR}, + #{it.email, jdbcType=VARCHAR}, + #{it.active, jdbcType=BOOLEAN}, + #{it.orderInDepts, jdbcType=VARCHAR}, + #{it.mainAdmin, jdbcType=BOOLEAN}, + #{it.isAdmin, jdbcType=BOOLEAN}, + #{it.isBoss, jdbcType=BOOLEAN}, + #{it.dingid, jdbcType=VARCHAR}, + #{it.unionid, jdbcType=VARCHAR}, + #{it.isLeaderInDepts, jdbcType=VARCHAR}, + #{it.isHide, jdbcType=BOOLEAN}, + #{it.departments, jdbcType=VARCHAR}, + #{it.position, jdbcType=VARCHAR}, + #{it.avatar, jdbcType=VARCHAR}, + #{it.jobnumber, jdbcType=VARCHAR}, + #{it.extattr, jdbcType=VARCHAR}, + #{it.roles, jdbcType=VARCHAR}, + #{it.isLeader, jdbcType=BOOLEAN}, + sysdate() + ) + + ON DUPLICATE KEY UPDATE + departments=values(departments), + `name`=values(name), + main_admin=values(main_admin), + is_admin=values(is_admin), + mobile = values(mobile), + order_in_depts=values(order_in_depts), + is_leader_in_depts=values(is_leader_in_depts), + avatar=values(avatar), + active=values(active), + `position`=values(position), + roles=values(roles), + jobnumber=values(jobnumber) + \ No newline at end of file diff --git a/coolstore-partner-dao/src/main/resources/mapper/EnterpriseUserRoleMapper.xml b/coolstore-partner-dao/src/main/resources/mapper/EnterpriseUserRoleMapper.xml index a0d6235ba..57a24dc13 100644 --- a/coolstore-partner-dao/src/main/resources/mapper/EnterpriseUserRoleMapper.xml +++ b/coolstore-partner-dao/src/main/resources/mapper/EnterpriseUserRoleMapper.xml @@ -60,4 +60,13 @@ where id = #{record.id} + + + insert ignore into enterprise_user_role_${eid} + (role_id, user_id ,create_time) + values + + (#{userRole.roleId}, #{userRole.userId} ,#{userRole.createTime}) + + \ No newline at end of file diff --git a/coolstore-partner-dao/src/main/resources/mapper/SysRoleMapper.xml b/coolstore-partner-dao/src/main/resources/mapper/SysRoleMapper.xml index 3f6325e90..81b592558 100644 --- a/coolstore-partner-dao/src/main/resources/mapper/SysRoleMapper.xml +++ b/coolstore-partner-dao/src/main/resources/mapper/SysRoleMapper.xml @@ -180,4 +180,21 @@ c.priority is null, c.priority, position_type desc LIMIT 1 + + \ No newline at end of file diff --git a/coolstore-partner-model/coolstore-partner-model.iml b/coolstore-partner-model/coolstore-partner-model.iml index ae178e8ab..90f710f02 100644 --- a/coolstore-partner-model/coolstore-partner-model.iml +++ b/coolstore-partner-model/coolstore-partner-model.iml @@ -58,6 +58,20 @@ + + + + + + + + + + + + + + diff --git a/coolstore-partner-model/src/main/java/com/cool/store/dto/enterprise/EnterpriseInitDTO.java b/coolstore-partner-model/src/main/java/com/cool/store/dto/enterprise/EnterpriseInitDTO.java new file mode 100644 index 000000000..78a68eb1d --- /dev/null +++ b/coolstore-partner-model/src/main/java/com/cool/store/dto/enterprise/EnterpriseInitDTO.java @@ -0,0 +1,21 @@ +package com.cool.store.dto.enterprise; + +import lombok.Data; + +/** + * @author chenyupeng + * @since 2022/1/26 + */ +@Data +public class EnterpriseInitDTO { + + private String appType; + + private String corpId; + + private String eid; + + private String dbName; + + private String userId; +} diff --git a/coolstore-partner-model/src/main/java/com/cool/store/dto/enterprise/EnterpriseOpenMsg.java b/coolstore-partner-model/src/main/java/com/cool/store/dto/enterprise/EnterpriseOpenMsg.java new file mode 100644 index 000000000..ed14718ff --- /dev/null +++ b/coolstore-partner-model/src/main/java/com/cool/store/dto/enterprise/EnterpriseOpenMsg.java @@ -0,0 +1,42 @@ +package com.cool.store.dto.enterprise; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 企业开通相关的参数 + * @author :xugangkun + * @date :2022/2/11 14:14 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class EnterpriseOpenMsg { + + /** + * 企业id + */ + private String eid; + + /** + * corpId + */ + private String corpId; + + /** + * 开通类型 + */ + private String appType; + + /** + * 授权用户id + */ + private String authUserId; + + /** + * 数据库名 + */ + private String dbName; + +} diff --git a/coolstore-partner-model/src/main/java/com/cool/store/dto/enterprise/EnterpriseUserDTO.java b/coolstore-partner-model/src/main/java/com/cool/store/dto/enterprise/EnterpriseUserDTO.java new file mode 100644 index 000000000..ad9c8295d --- /dev/null +++ b/coolstore-partner-model/src/main/java/com/cool/store/dto/enterprise/EnterpriseUserDTO.java @@ -0,0 +1,156 @@ +package com.cool.store.dto.enterprise; + +import com.alibaba.fastjson.JSONObject; +import com.cool.store.entity.EnterpriseUserDO; +import com.cool.store.utils.UUIDUtils; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * + * @author zhangchenbiao + * @date 2022-01-18 04:40 + */ +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class EnterpriseUserDTO implements Serializable { + + @ApiModelProperty("分机号") + private String tel; + + @ApiModelProperty("") + private String workPlace; + + @ApiModelProperty("备注") + private String remark; + + @ApiModelProperty("用户主键id") + private String id; + + @ApiModelProperty("钉钉用户id") + private String userId; + + @ApiModelProperty("") + private String name; + + @ApiModelProperty("是否已经激活, true表示已激活, false表示未激活") + private Boolean active; + + @ApiModelProperty("是否是主管理员,0:否,1:是") + private Byte mainAdmin; + + @ApiModelProperty("是否为企业的管理员, true表示是, false表示不是") + private Boolean isAdmin; + + @ApiModelProperty("手机号码") + private String mobile; + + @ApiModelProperty("员工的电子邮箱") + private String email; + + @ApiModelProperty("在当前isv全局范围内唯一标识一个用户的身份,用户无法修改") + private String unionid; + + @ApiModelProperty("是否号码隐藏, true表示隐藏, false表示不隐藏") + private Boolean isHide; + + @ApiModelProperty("") + private String position; + + @ApiModelProperty("员工的企业邮箱") + private String orgEmail; + + @ApiModelProperty("是否为企业的老板, true表示是, false表示不是") + private Boolean isBoss; + + @ApiModelProperty("钉钉Id,在钉钉全局范围内标识用户的身份,但用户可以自行修改一次") + private String dingid; + + @ApiModelProperty("头像url") + private String avatar; + + @ApiModelProperty("") + private String roles; + + @ApiModelProperty("是否是部门的主管, true表示是, false表示不是") + private Boolean isLeader; + + @ApiModelProperty("扩展属性,可以设置多种属性(但手机上最多只能显示10个扩展属性,具体显示哪些属性,请到OA管理后台->设置->通讯录信息设置和OA管理后台->设置->手机端显示信息设置)性") + private String extattr; + + @ApiModelProperty("") + private Boolean isEnterprise; + + @ApiModelProperty("用户创建时间") + private Date createTime; + + @ApiModelProperty("第三方OA系统唯一标识") + private String thirdOaUniqueFlag; + + @ApiModelProperty("") + private String orderInDepts; + + @ApiModelProperty("") + private List isLeaderInDepts; + + @ApiModelProperty("用户语言环境:en_us/英语_美国,zh_cn/中文_简体,zh_hk/中文_繁体_HK") + private String language; + + @ApiModelProperty("用户来源:默认dingding钉钉,qw企业微信 mobile") + private String appType; + + @ApiModelProperty("登录密码") + private String password; + + @ApiModelProperty("") + private String monitoredDepartments; + + @ApiModelProperty("工号") + private String jobnumber; + + private String openUserid; + + @ApiModelProperty("") + private List departmentLists; + + /** + * 管理范围 + */ + private List scopeList; + + private List storeList; + + + public static EnterpriseUserDO transUserDtoToDo(EnterpriseUserDTO enterpriseUserDTO) { + EnterpriseUserDO enterpriseUserDO = new EnterpriseUserDO(); + enterpriseUserDO.setTel(enterpriseUserDTO.getTel()); + enterpriseUserDO.setWorkPlace(enterpriseUserDTO.getWorkPlace()); + enterpriseUserDO.setRemark(enterpriseUserDTO.getRemark()); + enterpriseUserDO.setPosition(enterpriseUserDTO.getPosition()); + enterpriseUserDO.setMobile(enterpriseUserDTO.getMobile()); + enterpriseUserDO.setId(UUIDUtils.get32UUID()); + enterpriseUserDO.setUserId(enterpriseUserDTO.getUserId()); + enterpriseUserDO.setName(enterpriseUserDTO.getName()); + enterpriseUserDO.setEmail(enterpriseUserDTO.getEmail()); + enterpriseUserDO.setOrgEmail(enterpriseUserDTO.getOrgEmail()); + enterpriseUserDO.setActive(Boolean.TRUE); + enterpriseUserDO.setIsBoss(enterpriseUserDTO.getIsBoss()); + enterpriseUserDO.setUnionid(enterpriseUserDTO.getUnionid()); + enterpriseUserDO.setAvatar(enterpriseUserDTO.getAvatar()); + enterpriseUserDO.setIsLeaderInDepts(JSONObject.toJSONString(enterpriseUserDTO.getIsLeaderInDepts())); + enterpriseUserDO.setExtattr(enterpriseUserDTO.getExtattr()); + enterpriseUserDO.setCreateTime(new Date()); + enterpriseUserDO.setJobnumber(enterpriseUserDTO.getJobnumber()); + return enterpriseUserDO; + } + +} \ No newline at end of file diff --git a/coolstore-partner-model/src/main/java/com/cool/store/dto/enterprise/EnterpriseUserRole.java b/coolstore-partner-model/src/main/java/com/cool/store/dto/enterprise/EnterpriseUserRole.java new file mode 100644 index 000000000..abc1cf8b1 --- /dev/null +++ b/coolstore-partner-model/src/main/java/com/cool/store/dto/enterprise/EnterpriseUserRole.java @@ -0,0 +1,32 @@ +package com.cool.store.dto.enterprise; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @ClassName EnterpriseUserRole + * @Description 用一句话描述什么 + * @author 首亮 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class EnterpriseUserRole { + private Long id; + private String roleId; + private String userId; + + //创建时间 + private Date createTime; + //更新时间 + public EnterpriseUserRole(String roleId, String userId) { + this.roleId = roleId; + this.userId = userId; + this.createTime = new Date(); + } + + private Date updateTime; +} diff --git a/coolstore-partner-model/src/main/java/com/cool/store/dto/login/UserIdInfoDTO.java b/coolstore-partner-model/src/main/java/com/cool/store/dto/login/UserIdInfoDTO.java new file mode 100644 index 000000000..5b5afe5cd --- /dev/null +++ b/coolstore-partner-model/src/main/java/com/cool/store/dto/login/UserIdInfoDTO.java @@ -0,0 +1,28 @@ +package com.cool.store.dto.login; + +import lombok.Data; + +/** + * @author zhangchenbiao + * @FileName: UserIdInfoDTO + * @Description: + * @date 2023-05-29 10:58 + */ +@Data +public class UserIdInfoDTO { + + private String openId; + + private String unionId; + + private String userId; + + private String corpId; + + public UserIdInfoDTO(String openId, String unionId, String userId, String corpId) { + this.openId = openId; + this.unionId = unionId; + this.userId = userId; + this.corpId = corpId; + } +} diff --git a/coolstore-partner-model/src/main/java/com/cool/store/entity/EnterpriseUserDO.java b/coolstore-partner-model/src/main/java/com/cool/store/entity/EnterpriseUserDO.java index 3d6af363c..866587065 100644 --- a/coolstore-partner-model/src/main/java/com/cool/store/entity/EnterpriseUserDO.java +++ b/coolstore-partner-model/src/main/java/com/cool/store/entity/EnterpriseUserDO.java @@ -53,7 +53,7 @@ public class EnterpriseUserDO implements Serializable { private String orderInDepts; @ApiModelProperty("是否是主管理员,0:否,1:是") - private Integer mainAdmin; + private Boolean mainAdmin; @ApiModelProperty("是否为企业的管理员, true表示是, false表示不是") private Boolean isAdmin; diff --git a/coolstore-partner-service/coolstore-partner-service.iml b/coolstore-partner-service/coolstore-partner-service.iml index ed510e6c7..60ef29dc3 100644 --- a/coolstore-partner-service/coolstore-partner-service.iml +++ b/coolstore-partner-service/coolstore-partner-service.iml @@ -57,6 +57,16 @@ + + + + + + + + + + @@ -67,14 +77,6 @@ - - - - - - - - @@ -99,5 +101,24 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/coolstore-partner-service/pom.xml b/coolstore-partner-service/pom.xml index 4fb5720da..efb47940c 100644 --- a/coolstore-partner-service/pom.xml +++ b/coolstore-partner-service/pom.xml @@ -33,6 +33,18 @@ org.apache.shiro shiro-core + + com.aliyun.openservices + ons-client + + + com.aliyun + tea-openapi + + + com.aliyun + ons20190214 + \ No newline at end of file diff --git a/coolstore-partner-service/src/main/java/com/cool/store/http/ISVHttpRequest.java b/coolstore-partner-service/src/main/java/com/cool/store/http/ISVHttpRequest.java index f487cf6b2..5f2462cd0 100644 --- a/coolstore-partner-service/src/main/java/com/cool/store/http/ISVHttpRequest.java +++ b/coolstore-partner-service/src/main/java/com/cool/store/http/ISVHttpRequest.java @@ -1,7 +1,10 @@ package com.cool.store.http; import com.alibaba.fastjson.JSONObject; +import com.cool.store.dto.enterprise.EnterpriseUserDTO; +import com.cool.store.dto.login.UserIdInfoDTO; import com.cool.store.utils.RestTemplateUtil; +import com.coolstore.base.dto.ResultDTO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; @@ -26,18 +29,33 @@ public class ISVHttpRequest { private String getUserIdByCode; - public JSONObject getUserIdByCode(String paramStr){ - String url = isvDomain + getUserIdByCode + paramStr; - ResponseEntity responseEntity = null; + public UserIdInfoDTO getUserIdByCode(String paramStr){ + String url = isvDomain + "/isv/user/getUserIdByCode" + paramStr; + ResponseEntity responseEntity = null; try { - responseEntity = RestTemplateUtil.loadGet(url, JSONObject.class); + responseEntity = RestTemplateUtil.loadGet(url, ResultDTO.class); log.info("url:{}, response:{}", url, JSONObject.toJSONString(responseEntity)); + if(Objects.nonNull(responseEntity.getBody()) && responseEntity.getBody().isSuccess()){ + return JSONObject.parseObject(JSONObject.toJSONString(responseEntity.getBody().getData()), UserIdInfoDTO.class); + } } catch (Exception e) { log.info("调用isv出错{}", e); } - if(Objects.isNull(responseEntity)){ - return null; + return null; + } + + public EnterpriseUserDTO getUserDetailByUserId(String corpId, String userId, String appType){ + String url = isvDomain + "/isv/user/getUserDetail"; + ResponseEntity responseEntity = null; + try { + responseEntity = RestTemplateUtil.loadGet(url, ResultDTO.class); + log.info("url:{}, response:{}", url, JSONObject.toJSONString(responseEntity)); + if(Objects.nonNull(responseEntity.getBody()) && responseEntity.getBody().isSuccess()){ + return JSONObject.parseObject(JSONObject.toJSONString(responseEntity.getBody().getData()), EnterpriseUserDTO.class); + } + } catch (Exception e) { + log.info("调用isv出错{}", e); } - return responseEntity.getBody(); + return null; } } diff --git a/coolstore-partner-service/src/main/java/com/cool/store/mq/OrderMessageService.java b/coolstore-partner-service/src/main/java/com/cool/store/mq/OrderMessageService.java new file mode 100644 index 000000000..dc7b316d4 --- /dev/null +++ b/coolstore-partner-service/src/main/java/com/cool/store/mq/OrderMessageService.java @@ -0,0 +1,23 @@ +package com.cool.store.mq; + +import com.aliyun.openservices.ons.api.SendResult; +import com.coolstore.base.enums.RocketMqTagEnum; + +/** + * @author zhangchenbiao + * @FileName: OrderMessageService + * @Description: 顺序消息生产者 + * @date 2021-12-22 17:37 + */ +public interface OrderMessageService { + + /** + * 发送顺序消息 + * @param message + * @param tag + * @param shardingKey + * @return + */ + SendResult send(String message, RocketMqTagEnum tag, final String shardingKey); + +} diff --git a/coolstore-partner-service/src/main/java/com/cool/store/mq/ProducerClient.java b/coolstore-partner-service/src/main/java/com/cool/store/mq/ProducerClient.java new file mode 100644 index 000000000..f086d3ac5 --- /dev/null +++ b/coolstore-partner-service/src/main/java/com/cool/store/mq/ProducerClient.java @@ -0,0 +1,45 @@ +package com.cool.store.mq; + +import com.aliyun.openservices.ons.api.bean.OrderProducerBean; +import com.aliyun.openservices.ons.api.bean.ProducerBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; + +/** + * @author zhangchenbiao + * @FileName: ProducerClient + * @Description: 普通消息client + * @date 2021-12-21 11:33 + */ +@Configuration +public class ProducerClient { + + @Autowired + private RocketMqConfig rocketMqConfig; + + /** + * 普通消息 + * @return + */ + @Primary + @Bean(initMethod = "start", destroyMethod = "shutdown") + public ProducerBean producerBean() { + ProducerBean producer = new ProducerBean(); + producer.setProperties(rocketMqConfig.getMqProperties()); + return producer; + } + + /** + * 分区顺序消息 + * @return + */ + @Bean(initMethod = "start", destroyMethod = "shutdown") + public OrderProducerBean orderProducerBean() { + OrderProducerBean producer = new OrderProducerBean(); + producer.setProperties(rocketMqConfig.getMqProperties()); + return producer; + } + +} diff --git a/coolstore-partner-service/src/main/java/com/cool/store/mq/RocketMqConfig.java b/coolstore-partner-service/src/main/java/com/cool/store/mq/RocketMqConfig.java new file mode 100644 index 000000000..864b76551 --- /dev/null +++ b/coolstore-partner-service/src/main/java/com/cool/store/mq/RocketMqConfig.java @@ -0,0 +1,78 @@ +package com.cool.store.mq; + +import com.aliyun.openservices.ons.api.PropertyKeyConst; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +import java.util.Properties; + +/** + * @author zhangchenbiao + * @FileName: RocketMqConfig + * @Description: 该服务的rocketmq的配置 以及生产者的topic + * @date 2021-12-21 11:33 + */ +@Configuration +@ConfigurationProperties(prefix = "rocketmq") +public class RocketMqConfig { + + private String accessKey; + private String secretKey; + private String nameSrvAdder; + /** + * 普通消息的topic + */ + private String topic; + /** + * 分区顺序消息topic + */ + private String orderTopic; + + public Properties getMqProperties() { + Properties properties = new Properties(); + properties.setProperty(PropertyKeyConst.AccessKey, this.accessKey); + properties.setProperty(PropertyKeyConst.SecretKey, this.secretKey); + properties.setProperty(PropertyKeyConst.NAMESRV_ADDR, this.nameSrvAdder); + return properties; + } + + public String getAccessKey() { + return accessKey; + } + + public void setAccessKey(String accessKey) { + this.accessKey = accessKey; + } + + public String getSecretKey() { + return secretKey; + } + + public void setSecretKey(String secretKey) { + this.secretKey = secretKey; + } + + public String getNameSrvAdder() { + return nameSrvAdder; + } + + public void setNameSrvAdder(String nameSrvAdder) { + this.nameSrvAdder = nameSrvAdder; + } + + public String getTopic() { + return topic; + } + + public void setTopic(String topic) { + this.topic = topic; + } + + public String getOrderTopic() { + return orderTopic; + } + + public void setOrderTopic(String orderTopic) { + this.orderTopic = orderTopic; + } +} diff --git a/coolstore-partner-service/src/main/java/com/cool/store/mq/SimpleMessageService.java b/coolstore-partner-service/src/main/java/com/cool/store/mq/SimpleMessageService.java new file mode 100644 index 000000000..1e5343cb7 --- /dev/null +++ b/coolstore-partner-service/src/main/java/com/cool/store/mq/SimpleMessageService.java @@ -0,0 +1,46 @@ +package com.cool.store.mq; + +import com.aliyun.openservices.ons.api.SendCallback; +import com.aliyun.openservices.ons.api.SendResult; +import com.coolstore.base.enums.RocketMqTagEnum; + +/** + * @author zhangchenbiao + * @FileName: MessageProducerService + * @Description: rocketmq 消息生产者 + * @date 2021-12-22 16:12 + */ +public interface SimpleMessageService { + + /** + * 同步发送 + * @param message 消息 + * @param tag tag + * @return + */ + SendResult send(String message, RocketMqTagEnum tag); + + /** + * 单向发送 + * @param message 消息 + * @param tag tag + */ + void sendOneway(String message, RocketMqTagEnum tag); + + /** + * 异步发送 + * @param message 消息 + * @param tag tag + * @param sendCallback 回调 + */ + void sendAsync(String message, RocketMqTagEnum tag, SendCallback sendCallback); + + /** + * 同步发送(延时) + * @param message + * @param tag + * @param startDeliverTime + * @return + */ + SendResult send(String message, RocketMqTagEnum tag, Long startDeliverTime); +} diff --git a/coolstore-partner-service/src/main/java/com/cool/store/mq/impl/OrderMessageServiceImpl.java b/coolstore-partner-service/src/main/java/com/cool/store/mq/impl/OrderMessageServiceImpl.java new file mode 100644 index 000000000..4da451ec5 --- /dev/null +++ b/coolstore-partner-service/src/main/java/com/cool/store/mq/impl/OrderMessageServiceImpl.java @@ -0,0 +1,57 @@ +package com.cool.store.mq.impl; + +import com.aliyun.openservices.ons.api.Message; +import com.aliyun.openservices.ons.api.SendResult; +import com.aliyun.openservices.ons.api.bean.OrderProducerBean; +import com.cool.store.constants.CommonConstants; +import com.cool.store.mq.OrderMessageService; +import com.cool.store.mq.RocketMqConfig; +import com.cool.store.utils.UUIDUtils; +import com.coolstore.base.enums.RocketMqTagEnum; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.MDC; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Objects; +import java.util.Properties; + +/** + * @author zhangchenbiao + * @FileName: OrderMessageServiceImpl + * @Description: 顺序消息生产实现 + * @date 2021-12-22 17:38 + */ +@Slf4j +@Service +public class OrderMessageServiceImpl implements OrderMessageService { + + @Resource + private RocketMqConfig rocketMqConfig; + + @Resource + private OrderProducerBean orderProducerBean; + + @Override + public SendResult send(String message, RocketMqTagEnum tag, String shardingKey) { + if(StringUtils.isAnyBlank(message, shardingKey) || Objects.isNull(tag)){ + return new SendResult(); + } + try { + Message msg = new Message(rocketMqConfig.getOrderTopic(), tag.getTag(), message.getBytes("UTF-8")); + Properties properties = new Properties(); + String requestId = MDC.get(CommonConstants.REQUEST_ID); + if(StringUtils.isBlank(requestId)){ + requestId = UUIDUtils.get32UUID(); + } + properties.setProperty(CommonConstants.REQUEST_ID, requestId); + msg.setUserProperties(properties); + SendResult send = orderProducerBean.send(msg, shardingKey); + return send; + } catch (Exception e) { + log.error("send@@@@@@@@@ddd", e); + } + return null; + } +} diff --git a/coolstore-partner-service/src/main/java/com/cool/store/mq/impl/SimpleMessageServiceImpl.java b/coolstore-partner-service/src/main/java/com/cool/store/mq/impl/SimpleMessageServiceImpl.java new file mode 100644 index 000000000..1b749261b --- /dev/null +++ b/coolstore-partner-service/src/main/java/com/cool/store/mq/impl/SimpleMessageServiceImpl.java @@ -0,0 +1,129 @@ +package com.cool.store.mq.impl; + +import com.alibaba.fastjson.JSONObject; +import com.aliyun.openservices.ons.api.Message; +import com.aliyun.openservices.ons.api.SendCallback; +import com.aliyun.openservices.ons.api.SendResult; +import com.aliyun.openservices.ons.api.bean.ProducerBean; +import com.cool.store.constants.CommonConstants; +import com.cool.store.mq.RocketMqConfig; +import com.cool.store.mq.SimpleMessageService; +import com.cool.store.utils.UUIDUtils; +import com.coolstore.base.enums.RocketMqTagEnum; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.MDC; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.Objects; +import java.util.Properties; + +/** + * @author zhangchenbiao + * @FileName: MessageProducerServiceImpl + * @Description: 消息生产者实现 + * @date 2021-12-22 16:12 + */ +@Service +@Slf4j +public class SimpleMessageServiceImpl implements SimpleMessageService { + + @Resource + private RocketMqConfig rocketMqConfig; + + @Resource + private ProducerBean producer; + + @Override + public SendResult send(String message, RocketMqTagEnum tag) { + if(StringUtils.isBlank(message) || Objects.isNull(tag)){ + return new SendResult(); + } + try { + Message msg = new Message(rocketMqConfig.getTopic(), tag.getTag(), message.getBytes("UTF-8")); + Properties properties = new Properties(); + String requestId = MDC.get(CommonConstants.REQUEST_ID); + if(StringUtils.isBlank(requestId)){ + requestId = UUIDUtils.get32UUID(); + } + properties.setProperty(CommonConstants.REQUEST_ID, requestId); + msg.setUserProperties(properties); + SendResult send = producer.send(msg); + log.info("消息发送send response:{}", JSONObject.toJSONString(send)); + return send; + } catch (Exception e) { + log.error("send#######", e); + } + return new SendResult(); + + } + + @Override + public void sendOneway(String message, RocketMqTagEnum tag) { + if(StringUtils.isBlank(message) || Objects.isNull(tag)){ + return; + } + try { + Message msg = new Message(rocketMqConfig.getTopic(), tag.getTag(), message.getBytes("UTF-8")); + Properties properties = new Properties(); + String requestId = MDC.get(CommonConstants.REQUEST_ID); + if(StringUtils.isBlank(requestId)){ + requestId = UUIDUtils.get32UUID(); + } + properties.setProperty(CommonConstants.REQUEST_ID, requestId); + msg.setUserProperties(properties); + producer.sendOneway(msg); + } catch (Exception e) { + log.error("send@@@@@@", e); + } + } + + @Override + public void sendAsync(String message, RocketMqTagEnum tag, SendCallback sendCallback) { + if(StringUtils.isBlank(message) || Objects.isNull(tag)){ + return; + } + try { + Message msg = new Message(rocketMqConfig.getTopic(), tag.getTag(), message.getBytes("UTF-8")); + Properties properties = new Properties(); + String requestId = MDC.get(CommonConstants.REQUEST_ID); + if(StringUtils.isBlank(requestId)){ + requestId = UUIDUtils.get32UUID(); + } + properties.setProperty(CommonConstants.REQUEST_ID, requestId); + msg.setUserProperties(properties); + producer.sendAsync(msg, sendCallback); + } catch (Exception e) { + log.error("sendAsync@@@@@@", e); + } + } + + @Override + public SendResult send(String message, RocketMqTagEnum tag, Long startDeliverTime) { + if(StringUtils.isBlank(message) || Objects.isNull(tag)){ + return new SendResult(); + } + try { + Message msg = new Message(rocketMqConfig.getTopic(), tag.getTag(), message.getBytes("UTF-8")); + if(Objects.nonNull(startDeliverTime)) { + log.info("{} startDeliverTime:{}", tag.getTag(),new Date(startDeliverTime)); + msg.setStartDeliverTime(startDeliverTime); + } + Properties properties = new Properties(); + String requestId = MDC.get(CommonConstants.REQUEST_ID); + if(StringUtils.isBlank(requestId)){ + requestId = UUIDUtils.get32UUID(); + } + properties.setProperty(CommonConstants.REQUEST_ID, requestId); + msg.setUserProperties(properties); + SendResult send = producer.send(msg); + log.info("发送消息:data:{}", JSONObject.toJSONString(send)); + return send; + } catch (Exception e) { + log.error("send@@@@@@@@@", e); + } + return new SendResult(); + } +} diff --git a/coolstore-partner-service/src/main/java/com/cool/store/mq/util/RocketMqUtil.java b/coolstore-partner-service/src/main/java/com/cool/store/mq/util/RocketMqUtil.java new file mode 100644 index 000000000..5411223c3 --- /dev/null +++ b/coolstore-partner-service/src/main/java/com/cool/store/mq/util/RocketMqUtil.java @@ -0,0 +1,197 @@ +package com.cool.store.mq.util; + +import com.aliyun.ons20190214.*; +import com.aliyun.ons20190214.models.*; +import com.aliyun.teaopenapi.models.Config; +import com.cool.store.constants.CommonConstants; +import com.coolstore.base.enums.RocketMqGroupEnum; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.ListUtils; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @author chenyupeng + * @since 2022/1/5 + */ +@Slf4j +public class RocketMqUtil { + + private static final String INSTANCE_ID = "MQ_INST_1947409023213164_BX3sLZnA"; + + /** + * 本地 + */ + private static final String LOCAL_INSTANCE_ID = "MQ_INST_1255228665351616_BX3wfyPO"; + + private static final String INSTANCE_ID_ONLINE_HD_PRE = "MQ_INST_1947409023213164_BX5N7rwl"; + private static final String ACCESS_KEY = "LTAI5t5ouXZuFgxJMbQea3b2"; + private static final String ACCESS_SECRET = "yuomDstRjSdihtN5zo8viDbWu8Z0ig"; + /** + * 使用AK&SK初始化账号Client + * @param accessKeyId + * @param accessKeySecret + * @return Client + * @throws Exception + */ + public static Client createClient(String accessKeyId, String accessKeySecret) throws Exception { + Config config = new Config() + // 您的AccessKey ID + .setAccessKeyId(accessKeyId) + // 您的AccessKey Secret + .setAccessKeySecret(accessKeySecret); + // 访问的域名 + config.endpoint = "ons.cn-hangzhou.aliyuncs.com"; + return new Client(config); + } + + public static Client createLocalClient(String accessKeyId, String accessKeySecret) throws Exception { + Config config = new Config() + // 您的AccessKey ID + .setAccessKeyId(accessKeyId) + // 您的AccessKey Secret + .setAccessKeySecret(accessKeySecret); + // 访问的域名 + config.endpoint = "ons.mq-internet-access.aliyuncs.com"; + return new Client(config); + } + + /** + * 新增测试、开发环境的group + * @author chenyupeng + * @date 2022/1/13 + * @param profiles 环境后缀,逗号分隔 例如: dev,dev2 + * @return void + */ + public static void initGroup(String profiles) throws Exception { + Client client = RocketMqUtil.createClient(ACCESS_KEY, ACCESS_SECRET); + List profileList = Arrays.asList(profiles.split(CommonConstants.COMMA)); + if(CollectionUtils.isEmpty(profileList)){ + return; + } + + OnsGroupListRequest onsGroupListRequest = new OnsGroupListRequest(); + onsGroupListRequest.setInstanceId(INSTANCE_ID); + OnsGroupListResponse onsGroupListResponse = client.onsGroupList(onsGroupListRequest); + List subscribeInfoDo = onsGroupListResponse.getBody().getData().getSubscribeInfoDo(); + Map collect = ListUtils.emptyIfNull(subscribeInfoDo).stream(). + collect(Collectors.toMap(OnsGroupListResponseBody.OnsGroupListResponseBodyDataSubscribeInfoDo::getGroupId, data -> data, (a, b) -> a)); + + for (String profile : profileList) { + for (RocketMqGroupEnum groupEnum : RocketMqGroupEnum.values()) { + String groupId = groupEnum.getDefaultGroup() + "_" + profile; + //已经创建就继续 + if(collect.get(groupId) != null){ + continue; + } + OnsGroupCreateRequest onsGroupCreateRequest = new OnsGroupCreateRequest(); + onsGroupCreateRequest.setGroupId(groupId); + onsGroupCreateRequest.setInstanceId(INSTANCE_ID); + // 复制代码运行请自行打印 API 的返回值 + try { + client.onsGroupCreate(onsGroupCreateRequest); + }catch (Exception e){ + log.error("initGroupAndTag fail",e); + } + Thread.sleep(1000); + } + } + } + + public static void initLocalGroup(String profiles) throws Exception { + Client client = RocketMqUtil.createLocalClient("LTAI5tPWCTeCyngfYLqoSGWk", "jkzIXlvNF17ne5TPPEFP1sQhcfg4Je"); + List profileList = Arrays.asList(profiles.split(CommonConstants.COMMA)); + if(CollectionUtils.isEmpty(profileList)){ + return; + } + + OnsGroupListRequest onsGroupListRequest = new OnsGroupListRequest(); + onsGroupListRequest.setInstanceId(LOCAL_INSTANCE_ID); + OnsGroupListResponse onsGroupListResponse = client.onsGroupList(onsGroupListRequest); + List subscribeInfoDo = onsGroupListResponse.getBody().getData().getSubscribeInfoDo(); + Map collect = ListUtils.emptyIfNull(subscribeInfoDo).stream(). + collect(Collectors.toMap(OnsGroupListResponseBody.OnsGroupListResponseBodyDataSubscribeInfoDo::getGroupId, data -> data, (a, b) -> a)); + + for (String profile : profileList) { + for (RocketMqGroupEnum groupEnum : RocketMqGroupEnum.values()) { + String groupId = groupEnum.getDefaultGroup() + "_" + profile; + //已经创建就继续 + if(collect.get(groupId) != null){ + continue; + } + OnsGroupCreateRequest onsGroupCreateRequest = new OnsGroupCreateRequest(); + onsGroupCreateRequest.setGroupId(groupId); + onsGroupCreateRequest.setInstanceId(LOCAL_INSTANCE_ID); + // 复制代码运行请自行打印 API 的返回值 + try { + client.onsGroupCreate(onsGroupCreateRequest); + }catch (Exception e){ + log.error("initGroupAndTag fail",e); + } + Thread.sleep(1000); + } + } + } + + /** + * 新增线上、灰度、预发环境的group + * @author chenyupeng + * @date 2022/1/13 + * @param profiles 环境后缀,逗号分隔 例如: online,hd,pre + * @return void + */ + public static void initOnlineAndHdAndPreGroup(String profiles) throws Exception { + Client client = RocketMqUtil.createClient(ACCESS_KEY, ACCESS_SECRET); + List profileList = Arrays.asList(profiles.split(CommonConstants.COMMA)); + if(CollectionUtils.isEmpty(profileList)){ + return; + } + + OnsGroupListRequest onsGroupListRequest = new OnsGroupListRequest(); + onsGroupListRequest.setInstanceId(INSTANCE_ID_ONLINE_HD_PRE); + OnsGroupListResponse onsGroupListResponse = client.onsGroupList(onsGroupListRequest); + List subscribeInfoDo = onsGroupListResponse.getBody().getData().getSubscribeInfoDo(); + Map collect = ListUtils.emptyIfNull(subscribeInfoDo).stream(). + collect(Collectors.toMap(OnsGroupListResponseBody.OnsGroupListResponseBodyDataSubscribeInfoDo::getGroupId, data -> data, (a, b) -> a)); + + for (String profile : profileList) { + for (RocketMqGroupEnum groupEnum : RocketMqGroupEnum.values()) { + String groupId = groupEnum.getDefaultGroup() + "_" + profile; + //已经创建就继续 + if(collect.get(groupId) != null){ + continue; + } + OnsGroupCreateRequest onsGroupCreateRequest = new OnsGroupCreateRequest(); + onsGroupCreateRequest.setGroupId(groupId); + onsGroupCreateRequest.setInstanceId(INSTANCE_ID_ONLINE_HD_PRE); + // 复制代码运行请自行打印 API 的返回值 + try { + client.onsGroupCreate(onsGroupCreateRequest); + }catch (Exception e){ + log.error("initGroupAndTag fail",e); + } + Thread.sleep(1000); + } + } + + } + + /** + * 删除测试、开发环境的group + * @author chenyupeng + * @date 2022/1/13 + * @param groupId + * @return void + */ + public static void deleteGroupById(String groupId) throws Exception { + Client client = RocketMqUtil.createClient(ACCESS_KEY, ACCESS_SECRET); + OnsGroupDeleteRequest request = new OnsGroupDeleteRequest(); + request.setGroupId(groupId); + request.setInstanceId(INSTANCE_ID); + client.onsGroupDelete(request); + } +} diff --git a/coolstore-partner-service/src/main/java/com/cool/store/service/impl/EnterpriseInitServiceImpl.java b/coolstore-partner-service/src/main/java/com/cool/store/service/impl/EnterpriseInitServiceImpl.java new file mode 100644 index 000000000..b767a2343 --- /dev/null +++ b/coolstore-partner-service/src/main/java/com/cool/store/service/impl/EnterpriseInitServiceImpl.java @@ -0,0 +1,110 @@ +package com.cool.store.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.cool.store.constants.CommonConstants; +import com.cool.store.dao.EnterpriseUserDAO; +import com.cool.store.dao.EnterpriseUserRoleDAO; +import com.cool.store.dao.SysRoleDAO; +import com.cool.store.dto.enterprise.EnterpriseInitDTO; +import com.cool.store.dto.enterprise.EnterpriseOpenMsg; +import com.cool.store.dto.enterprise.EnterpriseUserDTO; +import com.cool.store.dto.enterprise.EnterpriseUserRole; +import com.cool.store.entity.EnterpriseUserDO; +import com.cool.store.enums.RoleEnum; +import com.cool.store.http.ISVHttpRequest; +import com.cool.store.mq.SimpleMessageService; +import com.cool.store.utils.DataSourceHelper; +import com.cool.store.utils.ScriptUtil; +import com.cool.store.utils.UUIDUtils; +import com.coolstore.base.enums.RocketMqTagEnum; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.core.io.ClassPathResource; +import org.springframework.core.io.support.EncodedResource; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.*; + +/** + * @author zhangchenbiao + * @FileName: EnterpriseInitService + * @Description: 企业初始化 + * @date 2023-05-26 16:28 + */ +@Slf4j +@Service +public class EnterpriseInitServiceImpl { + + @Resource + protected ScriptUtil scriptUtil; + @Resource + private SysRoleDAO sysRoleDAO; + @Resource + private EnterpriseUserRoleDAO enterpriseUserRoleDAO; + @Resource + private EnterpriseUserDAO enterpriseUserDAO; + @Resource + private SimpleMessageService simpleMessageService; + @Resource + private ISVHttpRequest isvHttpRequest; + + public void runEnterpriseScript(EnterpriseOpenMsg msg) { + runEnterpriseScriptAndInitAuthUser(msg); + //抛出开始数据同步消息 + EnterpriseInitDTO enterpriseInitDTO = new EnterpriseInitDTO(); + enterpriseInitDTO.setEid(msg.getEid()); + enterpriseInitDTO.setAppType(msg.getAppType()); + enterpriseInitDTO.setCorpId(msg.getCorpId()); + enterpriseInitDTO.setDbName(msg.getDbName()); + enterpriseInitDTO.setUserId(msg.getAuthUserId()); + log.info("send msg to enterprise_open_data_sync, eid:{}, appType:{}, corpId:{}, dbName:{}", msg.getEid(), msg.getAppType(), msg.getCorpId(), msg.getDbName(), msg.getAuthUserId()); + simpleMessageService.send(JSONObject.toJSONString(enterpriseInitDTO), RocketMqTagEnum.ENTERPRISE_OPEN_DATA_SYNC); + } + + public void runEnterpriseScriptAndInitAuthUser(EnterpriseOpenMsg msg) { + DataSourceHelper.changeToSpecificDataSource(msg.getDbName()); + //执行脚本代码 + ClassPathResource rc = new ClassPathResource("script/enterpriseInit.sql"); + EncodedResource er = new EncodedResource(rc, "utf-8"); + HashMap objectObjectHashMap = new HashMap<>(); + objectObjectHashMap.put("enterpriseId", msg.getEid()); + String userId = msg.getAuthUserId(); + if(StringUtils.isBlank(userId)){ + objectObjectHashMap.put("userId", CommonConstants.SYSTEM_USER_ID); + } else { + objectObjectHashMap.put("userId", userId); + } + String groupId = UUIDUtils.get32UUID(); + objectObjectHashMap.put("groupId", groupId); + scriptUtil.executeSqlScript(er, objectObjectHashMap); + log.info("初始化开通用户"); + if (StringUtils.isNotBlank(msg.getAuthUserId())) { + //初始化开通用户 + initAuthUser(msg.getEid(), msg.getCorpId(), msg.getAppType(), msg.getAuthUserId(), userId, msg.getDbName()); + } + } + + public void initAuthUser(String eid, String corpId, String appType, String authUserId, String userId, String dbName) { + List userRoles = new ArrayList<>(); + Long roleIdByRoleEnum = sysRoleDAO.getRoleIdByRoleEnum(eid, RoleEnum.MASTER.getRoleEnum()); + Long shopOwner = sysRoleDAO.getRoleIdByRoleEnum(eid, RoleEnum.SHOPOWNER.getRoleEnum()); + Long subMaster = sysRoleDAO.getRoleIdByRoleEnum(eid, RoleEnum.SUB_MASTER.getRoleEnum()); + //钉钉或者企业走用户,app开通不需要 + EnterpriseUserDTO userDTO = null; + try { + userDTO = isvHttpRequest.getUserDetailByUserId(corpId, authUserId, appType); + } catch (Exception e) { + log.error("getUserDetailByUserId error", e); + } + EnterpriseUserDO userDO = EnterpriseUserDTO.transUserDtoToDo(userDTO); + userDO.setMainAdmin(true); + userDO.setIsAdmin(true); + enterpriseUserDAO.batchInsertOrUpdate(eid, Collections.singletonList(userDO)); + userRoles.add(new EnterpriseUserRole(roleIdByRoleEnum.toString(), userId)); + userRoles.add(new EnterpriseUserRole(shopOwner.toString(), userId)); + userRoles.add(new EnterpriseUserRole(subMaster.toString(), userId)); + enterpriseUserRoleDAO.insertBatchUserRole(eid, userRoles); + } + +} diff --git a/coolstore-partner-webb/coolstore-partner-webb.iml b/coolstore-partner-webb/coolstore-partner-webb.iml index e79bb2351..ffd8bbebe 100644 --- a/coolstore-partner-webb/coolstore-partner-webb.iml +++ b/coolstore-partner-webb/coolstore-partner-webb.iml @@ -23,6 +23,16 @@ + + + + + + + + + + @@ -32,14 +42,6 @@ - - - - - - - - @@ -64,6 +66,25 @@ + + + + + + + + + + + + + + + + + + + diff --git a/coolstore-partner-webb/src/main/java/com/cool/store/config/TokenValidateFilter.java b/coolstore-partner-webb/src/main/java/com/cool/store/config/TokenValidateFilter.java index eec83b2d9..226c8648c 100644 --- a/coolstore-partner-webb/src/main/java/com/cool/store/config/TokenValidateFilter.java +++ b/coolstore-partner-webb/src/main/java/com/cool/store/config/TokenValidateFilter.java @@ -40,7 +40,7 @@ public class TokenValidateFilter implements Filter { private static List patternList = - Lists.newArrayList("/web/check/ok","/check/ok", "/partner/doc.html", + Lists.newArrayList("/web/check/ok","/check/ok", "/partner/doc.html","/**/test/**", "/**/swagger*/**", "/**/webjars/**"); diff --git a/coolstore-partner-webb/src/main/java/com/cool/store/controller/LoginController.java b/coolstore-partner-webb/src/main/java/com/cool/store/controller/LoginController.java index f86da1f54..798e6ceed 100644 --- a/coolstore-partner-webb/src/main/java/com/cool/store/controller/LoginController.java +++ b/coolstore-partner-webb/src/main/java/com/cool/store/controller/LoginController.java @@ -3,6 +3,7 @@ package com.cool.store.controller; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.cool.store.dto.login.FeiShuLoginDTO; +import com.cool.store.dto.login.UserIdInfoDTO; import com.cool.store.enums.AppTypeEnum; import com.cool.store.enums.ErrorCodeEnum; import com.cool.store.exception.ServiceException; @@ -42,17 +43,13 @@ public class LoginController { String userId = "", corpId = "", appType = AppTypeEnum.FEI_SHU.getValue(); try { String value = "code=" + code + "&appType=" + appType + "&appId=" + appId; - JSONObject userInfo = isvHttpRequest.getUserIdByCode(value); + UserIdInfoDTO userInfo = isvHttpRequest.getUserIdByCode(value); if(Objects.isNull(userInfo)){ throw new ServiceException(ErrorCodeEnum.LOGIN_ERROR); } log.info("userInfo:{}", JSONObject.toJSONString(userInfo)); - userId = userInfo.getString("openId"); - corpId = userInfo.getString("corpId"); - String errorCode = userInfo.getString("error_code"); - if (StringUtils.isBlank(userId) && StringUtils.isNotBlank(errorCode)) { - throw new ServiceException(ErrorCodeEnum.LOGIN_ERROR); - } + userId = userInfo.getOpenId(); + corpId = userInfo.getCorpId(); return loginService.feiShuLogin(userId, corpId, Boolean.TRUE, appType, StringUtils.EMPTY); } catch (ServiceException e) { log.error(e.getMessage(), e); diff --git a/coolstore-partner-webb/src/main/java/com/cool/store/controller/TestController.java b/coolstore-partner-webb/src/main/java/com/cool/store/controller/TestController.java new file mode 100644 index 000000000..7f2d54d29 --- /dev/null +++ b/coolstore-partner-webb/src/main/java/com/cool/store/controller/TestController.java @@ -0,0 +1,30 @@ +package com.cool.store.controller; + +import com.cool.store.entity.EnterpriseConfigDO; +import com.cool.store.service.EnterpriseConfigService; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * @author zhangchenbiao + * @FileName: TestController + * @Description: + * @date 2023-05-26 11:32 + */ +@RestController +@RequestMapping("test/") +public class TestController { + + @Resource + private EnterpriseConfigService enterpriseConfigService; + + @GetMapping("/selectByEnterpriseId") + public EnterpriseConfigDO selectByEnterpriseId(@RequestParam("enterpriseId") String enterpriseId){ + return enterpriseConfigService.selectByEnterpriseId(enterpriseId); + } + +} diff --git a/coolstore-partner-webb/src/main/resources/application-ab.properties b/coolstore-partner-webb/src/main/resources/application-ab.properties index f486788e3..cb8bbc2c6 100644 --- a/coolstore-partner-webb/src/main/resources/application-ab.properties +++ b/coolstore-partner-webb/src/main/resources/application-ab.properties @@ -34,4 +34,10 @@ mybatis.configuration.call-setters-on-nulls=true mybatis.configuration.map-underscore-to-camel-case=true isv.domain = https://tstore-isv.coolcollege.cn -get.user.id.by.code = /isv/v2/get_user_id_by_code + +#rocketmq \u914D\u7F6E +rocketmq.accessKey=LTAI5t5ouXZuFgxJMbQea3b2 +rocketmq.secretKey=yuomDstRjSdihtN5zo8viDbWu8Z0ig +rocketmq.nameSrvAdder=http://MQ_INST_1947409023213164_BX3sLZnA.cn-hangzhou.mq-internal.aliyuncs.com:8080 +rocketmq.topic=simple_message +rocketmq.orderTopic=order_message diff --git a/coolstore-partner-webb/src/main/resources/application-dev.properties b/coolstore-partner-webb/src/main/resources/application-dev.properties index 5652d7677..74a62b60d 100644 --- a/coolstore-partner-webb/src/main/resources/application-dev.properties +++ b/coolstore-partner-webb/src/main/resources/application-dev.properties @@ -38,4 +38,10 @@ mybatis.configuration.call-setters-on-nulls=true mybatis.configuration.map-underscore-to-camel-case=true isv.domain = https://dstore-isv.coolcollege.cn -get.user.id.by.code = /isv/v2/get_user_id_by_code \ No newline at end of file + +#rocketmq \u914D\u7F6E +rocketmq.accessKey=LTAI5t5ouXZuFgxJMbQea3b2 +rocketmq.secretKey=yuomDstRjSdihtN5zo8viDbWu8Z0ig +rocketmq.nameSrvAdder=http://MQ_INST_1947409023213164_BX3sLZnA.cn-hangzhou.mq-internal.aliyuncs.com:8080 +rocketmq.topic=simple_message +rocketmq.orderTopic=order_message \ No newline at end of file diff --git a/coolstore-partner-webb/src/main/resources/application-hd.properties b/coolstore-partner-webb/src/main/resources/application-hd.properties index da65850ce..6cb958e9e 100644 --- a/coolstore-partner-webb/src/main/resources/application-hd.properties +++ b/coolstore-partner-webb/src/main/resources/application-hd.properties @@ -34,4 +34,10 @@ mybatis.configuration.call-setters-on-nulls=true mybatis.configuration.map-underscore-to-camel-case=true isv.domain = https://hdstore-isv.coolcollege.cn -get.user.id.by.code = /isv/v2/get_user_id_by_code \ No newline at end of file + +#rocketmq \u914D\u7F6E +rocketmq.accessKey=LTAI5t5ouXZuFgxJMbQea3b2 +rocketmq.secretKey=yuomDstRjSdihtN5zo8viDbWu8Z0ig +rocketmq.nameSrvAdder=http://MQ_INST_1947409023213164_BX5N7rwl.cn-hangzhou.mq-internal.aliyuncs.com:8080 +rocketmq.topic=simple_message +rocketmq.orderTopic=order_message \ No newline at end of file diff --git a/coolstore-partner-webb/src/main/resources/application-local.properties b/coolstore-partner-webb/src/main/resources/application-local.properties index c389a67ea..231241b5a 100644 --- a/coolstore-partner-webb/src/main/resources/application-local.properties +++ b/coolstore-partner-webb/src/main/resources/application-local.properties @@ -41,4 +41,10 @@ mybatis.configuration.call-setters-on-nulls=true mybatis.configuration.map-underscore-to-camel-case=true isv.domain = https://tstore-isv.coolcollege.cn -get.user.id.by.code = /isv/v2/get_user_id_by_code \ No newline at end of file + +#rocketmq \u914D\u7F6E +rocketmq.accessKey=LTAI5t5ouXZuFgxJMbQea3b2 +rocketmq.secretKey=yuomDstRjSdihtN5zo8viDbWu8Z0ig +rocketmq.nameSrvAdder=http://MQ_INST_1947409023213164_BX3sLZnA.cn-hangzhou.mq-internal.aliyuncs.com:8080 +rocketmq.topic=simple_message +rocketmq.orderTopic=order_message \ No newline at end of file diff --git a/coolstore-partner-webb/src/main/resources/application-online.properties b/coolstore-partner-webb/src/main/resources/application-online.properties index 389f5d03e..21fe024d9 100644 --- a/coolstore-partner-webb/src/main/resources/application-online.properties +++ b/coolstore-partner-webb/src/main/resources/application-online.properties @@ -34,4 +34,10 @@ mybatis.configuration.call-setters-on-nulls=true mybatis.configuration.map-underscore-to-camel-case=true isv.domain = https://store-isv.coolcollege.cn -get.user.id.by.code = /isv/v2/get_user_id_by_code \ No newline at end of file + +#rocketmq \u914D\u7F6E +rocketmq.accessKey=LTAI5t5ouXZuFgxJMbQea3b2 +rocketmq.secretKey=yuomDstRjSdihtN5zo8viDbWu8Z0ig +rocketmq.nameSrvAdder=http://MQ_INST_1947409023213164_BX5N7rwl.cn-hangzhou.mq-internal.aliyuncs.com:8080 +rocketmq.topic=simple_message +rocketmq.orderTopic=order_message \ No newline at end of file diff --git a/coolstore-partner-webb/src/main/resources/application-pre.properties b/coolstore-partner-webb/src/main/resources/application-pre.properties index 389f5d03e..21fe024d9 100644 --- a/coolstore-partner-webb/src/main/resources/application-pre.properties +++ b/coolstore-partner-webb/src/main/resources/application-pre.properties @@ -34,4 +34,10 @@ mybatis.configuration.call-setters-on-nulls=true mybatis.configuration.map-underscore-to-camel-case=true isv.domain = https://store-isv.coolcollege.cn -get.user.id.by.code = /isv/v2/get_user_id_by_code \ No newline at end of file + +#rocketmq \u914D\u7F6E +rocketmq.accessKey=LTAI5t5ouXZuFgxJMbQea3b2 +rocketmq.secretKey=yuomDstRjSdihtN5zo8viDbWu8Z0ig +rocketmq.nameSrvAdder=http://MQ_INST_1947409023213164_BX5N7rwl.cn-hangzhou.mq-internal.aliyuncs.com:8080 +rocketmq.topic=simple_message +rocketmq.orderTopic=order_message \ No newline at end of file diff --git a/coolstore-partner-webb/src/main/resources/application-test.properties b/coolstore-partner-webb/src/main/resources/application-test.properties index adc2ccb37..04cdb1ed2 100644 --- a/coolstore-partner-webb/src/main/resources/application-test.properties +++ b/coolstore-partner-webb/src/main/resources/application-test.properties @@ -34,4 +34,10 @@ mybatis.configuration.call-setters-on-nulls=true mybatis.configuration.map-underscore-to-camel-case=true isv.domain = https://tstore-isv.coolcollege.cn -get.user.id.by.code = /isv/v2/get_user_id_by_code \ No newline at end of file + +#rocketmq \u914D\u7F6E +rocketmq.accessKey=LTAI5t5ouXZuFgxJMbQea3b2 +rocketmq.secretKey=yuomDstRjSdihtN5zo8viDbWu8Z0ig +rocketmq.nameSrvAdder=http://MQ_INST_1947409023213164_BX3sLZnA.cn-hangzhou.mq-internal.aliyuncs.com:8080 +rocketmq.topic=simple_message +rocketmq.orderTopic=order_message \ No newline at end of file diff --git a/coolstore-partner-webc/coolstore-partner-webc.iml b/coolstore-partner-webc/coolstore-partner-webc.iml index 1a8f4c002..558af1366 100644 --- a/coolstore-partner-webc/coolstore-partner-webc.iml +++ b/coolstore-partner-webc/coolstore-partner-webc.iml @@ -23,6 +23,16 @@ + + + + + + + + + + @@ -32,14 +42,6 @@ - - - - - - - - @@ -64,6 +66,25 @@ + + + + + + + + + + + + + + + + + + + diff --git a/coolstore-partner-webc/src/main/resources/application-ab.properties b/coolstore-partner-webc/src/main/resources/application-ab.properties index 546d21a83..dfb8b733b 100644 --- a/coolstore-partner-webc/src/main/resources/application-ab.properties +++ b/coolstore-partner-webc/src/main/resources/application-ab.properties @@ -32,3 +32,11 @@ mybatis.mapper-locations=classpath*:mapper/**/*Mapper.xml mybatis.configuration.call-setters-on-nulls=true mybatis.configuration.map-underscore-to-camel-case=true + + +#rocketmq \u914D\u7F6E +rocketmq.accessKey=LTAI5t5ouXZuFgxJMbQea3b2 +rocketmq.secretKey=yuomDstRjSdihtN5zo8viDbWu8Z0ig +rocketmq.nameSrvAdder=http://MQ_INST_1947409023213164_BX3sLZnA.cn-hangzhou.mq-internal.aliyuncs.com:8080 +rocketmq.topic=simple_message +rocketmq.orderTopic=order_message \ No newline at end of file diff --git a/coolstore-partner-webc/src/main/resources/application-dev.properties b/coolstore-partner-webc/src/main/resources/application-dev.properties index ebdc6418f..c9a440805 100644 --- a/coolstore-partner-webc/src/main/resources/application-dev.properties +++ b/coolstore-partner-webc/src/main/resources/application-dev.properties @@ -35,4 +35,11 @@ spring.mvc.async.request-timeout=60000 mybatis.mapper-locations=classpath*:mapper/**/*Mapper.xml mybatis.configuration.call-setters-on-nulls=true -mybatis.configuration.map-underscore-to-camel-case=true \ No newline at end of file +mybatis.configuration.map-underscore-to-camel-case=true + +#rocketmq \u914D\u7F6E +rocketmq.accessKey=LTAI5t5ouXZuFgxJMbQea3b2 +rocketmq.secretKey=yuomDstRjSdihtN5zo8viDbWu8Z0ig +rocketmq.nameSrvAdder=http://MQ_INST_1947409023213164_BX3sLZnA.cn-hangzhou.mq-internal.aliyuncs.com:8080 +rocketmq.topic=simple_message +rocketmq.orderTopic=order_message \ No newline at end of file diff --git a/coolstore-partner-webc/src/main/resources/application-hd.properties b/coolstore-partner-webc/src/main/resources/application-hd.properties index 58a7dbde2..ea9ed3913 100644 --- a/coolstore-partner-webc/src/main/resources/application-hd.properties +++ b/coolstore-partner-webc/src/main/resources/application-hd.properties @@ -31,4 +31,11 @@ spring.mvc.async.request-timeout=60000 mybatis.mapper-locations=classpath*:mapper/**/*Mapper.xml mybatis.configuration.call-setters-on-nulls=true -mybatis.configuration.map-underscore-to-camel-case=true \ No newline at end of file +mybatis.configuration.map-underscore-to-camel-case=true + +#rocketmq \u914D\u7F6E +rocketmq.accessKey=LTAI5t5ouXZuFgxJMbQea3b2 +rocketmq.secretKey=yuomDstRjSdihtN5zo8viDbWu8Z0ig +rocketmq.nameSrvAdder=http://MQ_INST_1947409023213164_BX5N7rwl.cn-hangzhou.mq-internal.aliyuncs.com:8080 +rocketmq.topic=simple_message +rocketmq.orderTopic=order_message \ No newline at end of file diff --git a/coolstore-partner-webc/src/main/resources/application-local.properties b/coolstore-partner-webc/src/main/resources/application-local.properties index 76c957a9d..084d2b680 100644 --- a/coolstore-partner-webc/src/main/resources/application-local.properties +++ b/coolstore-partner-webc/src/main/resources/application-local.properties @@ -39,3 +39,10 @@ customize_sub_table_size=10 mybatis.configuration.call-setters-on-nulls=true mybatis.configuration.map-underscore-to-camel-case=true + +#rocketmq \u914D\u7F6E +rocketmq.accessKey=LTAI5t5ouXZuFgxJMbQea3b2 +rocketmq.secretKey=yuomDstRjSdihtN5zo8viDbWu8Z0ig +rocketmq.nameSrvAdder=http://MQ_INST_1947409023213164_BX3sLZnA.cn-hangzhou.mq-internal.aliyuncs.com:8080 +rocketmq.topic=simple_message +rocketmq.orderTopic=order_message diff --git a/coolstore-partner-webc/src/main/resources/application-online.properties b/coolstore-partner-webc/src/main/resources/application-online.properties index 58a7dbde2..ea9ed3913 100644 --- a/coolstore-partner-webc/src/main/resources/application-online.properties +++ b/coolstore-partner-webc/src/main/resources/application-online.properties @@ -31,4 +31,11 @@ spring.mvc.async.request-timeout=60000 mybatis.mapper-locations=classpath*:mapper/**/*Mapper.xml mybatis.configuration.call-setters-on-nulls=true -mybatis.configuration.map-underscore-to-camel-case=true \ No newline at end of file +mybatis.configuration.map-underscore-to-camel-case=true + +#rocketmq \u914D\u7F6E +rocketmq.accessKey=LTAI5t5ouXZuFgxJMbQea3b2 +rocketmq.secretKey=yuomDstRjSdihtN5zo8viDbWu8Z0ig +rocketmq.nameSrvAdder=http://MQ_INST_1947409023213164_BX5N7rwl.cn-hangzhou.mq-internal.aliyuncs.com:8080 +rocketmq.topic=simple_message +rocketmq.orderTopic=order_message \ No newline at end of file diff --git a/coolstore-partner-webc/src/main/resources/application-pre.properties b/coolstore-partner-webc/src/main/resources/application-pre.properties index 58a7dbde2..ea9ed3913 100644 --- a/coolstore-partner-webc/src/main/resources/application-pre.properties +++ b/coolstore-partner-webc/src/main/resources/application-pre.properties @@ -31,4 +31,11 @@ spring.mvc.async.request-timeout=60000 mybatis.mapper-locations=classpath*:mapper/**/*Mapper.xml mybatis.configuration.call-setters-on-nulls=true -mybatis.configuration.map-underscore-to-camel-case=true \ No newline at end of file +mybatis.configuration.map-underscore-to-camel-case=true + +#rocketmq \u914D\u7F6E +rocketmq.accessKey=LTAI5t5ouXZuFgxJMbQea3b2 +rocketmq.secretKey=yuomDstRjSdihtN5zo8viDbWu8Z0ig +rocketmq.nameSrvAdder=http://MQ_INST_1947409023213164_BX5N7rwl.cn-hangzhou.mq-internal.aliyuncs.com:8080 +rocketmq.topic=simple_message +rocketmq.orderTopic=order_message \ No newline at end of file diff --git a/coolstore-partner-webc/src/main/resources/application-test.properties b/coolstore-partner-webc/src/main/resources/application-test.properties index 87a6395cd..4fdad7b99 100644 --- a/coolstore-partner-webc/src/main/resources/application-test.properties +++ b/coolstore-partner-webc/src/main/resources/application-test.properties @@ -31,4 +31,11 @@ spring.mvc.async.request-timeout=60000 mybatis.mapper-locations=classpath*:mapper/**/*Mapper.xml mybatis.configuration.call-setters-on-nulls=true -mybatis.configuration.map-underscore-to-camel-case=true \ No newline at end of file +mybatis.configuration.map-underscore-to-camel-case=true + +#rocketmq \u914D\u7F6E +rocketmq.accessKey=LTAI5t5ouXZuFgxJMbQea3b2 +rocketmq.secretKey=yuomDstRjSdihtN5zo8viDbWu8Z0ig +rocketmq.nameSrvAdder=http://MQ_INST_1947409023213164_BX3sLZnA.cn-hangzhou.mq-internal.aliyuncs.com:8080 +rocketmq.topic=simple_message +rocketmq.orderTopic=order_message \ No newline at end of file diff --git a/pom.xml b/pom.xml index ce88a6960..beef29113 100644 --- a/pom.xml +++ b/pom.xml @@ -131,6 +131,26 @@ ons-client 1.8.8.3.Final + + cn.hutool + hutool-all + 5.0.7 + + + com.coolstore + coolstore-base + 1.5.3 + + + com.aliyun + tea-openapi + 0.0.19 + + + com.aliyun + ons20190214 + 1.0.0 +