Bladeren bron

部分接口

PC 2 jaren geleden
bovenliggende
commit
fd259866f4

+ 43 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/handle/CustomDataSource.java

@@ -0,0 +1,43 @@
+package com.sckw.core.handle;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.jdbc.DataSourceBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import javax.sql.DataSource;
+
+/**
+ * @author czh
+ * @desc TODO
+ * @date 2023/6/9
+ */
+@Slf4j
+@Configuration
+public class CustomDataSource {
+
+    @Value("${spring.datasource.dynamic.datasource.master.url}")
+    private String url;
+
+    @Value("${spring.datasource.dynamic.datasource.master.username}")
+    private String username;
+
+    @Value("${spring.datasource.dynamic.datasource.master.password}")
+    private String password;
+
+    @Value("${spring.datasource.dynamic.datasource.master.driver-class-name}")
+    private String driver;
+
+    @Bean
+    @ConfigurationProperties(prefix = "spring.datasource.dynamic.datasource.master")
+    public DataSource dataSource() {
+        log.info("url:{}", url);
+        log.info("username:{}", username);
+        log.info("password:{}", password);
+        log.info("driver:{}", driver);
+        return DataSourceBuilder.create().url(url).username(username).password(password).driverClassName(driver).build();
+
+    }
+}

+ 47 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/handle/CustomMetaHandle.java

@@ -0,0 +1,47 @@
+package com.sckw.core.handle;
+
+import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
+import com.sckw.core.model.auth.context.LoginUserHolder;
+import com.sckw.core.model.constant.Global;
+import com.sckw.core.utils.IdWorker;
+import com.sckw.core.utils.StringUtils;
+import org.apache.ibatis.reflection.MetaObject;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+import java.util.Objects;
+
+/**
+ * @author czh
+ * @desc TODO
+ * @date 2023/6/9
+ */
+@Component
+public class CustomMetaHandle implements MetaObjectHandler {
+
+    @Override
+    public void insertFill(MetaObject metaObject) {
+        Long userId = Objects.isNull(LoginUserHolder.getUserId()) ? 1 : LoginUserHolder.getUserId();
+        String userName = StringUtils.isBlank(LoginUserHolder.getUserName()) ? "无" : LoginUserHolder.getUserName();
+        Date date = new Date();
+        metaObject.setValue("createBy", userId);
+        metaObject.setValue("updateBy", userId);
+//        metaObject.setValue("createByName", userName);
+        metaObject.setValue("createTime", date);
+        metaObject.setValue("updateTime", date);
+        metaObject.setValue("status",  Global.NO);
+        metaObject.setValue("delFlag", Global.NO);
+        metaObject.setValue("id", new IdWorker(1).nextId());
+    }
+
+    @Override
+    public void updateFill(MetaObject metaObject) {
+        Long userId = Objects.isNull(LoginUserHolder.getUserId()) ? 1 : LoginUserHolder.getUserId();
+        String userName = StringUtils.isBlank(LoginUserHolder.getUserName()) ? "无" : LoginUserHolder.getUserName();
+        metaObject.setValue("updateBy", userId);
+//        metaObject.setValue("updateByName", userName);
+        metaObject.setValue("updateTime", new Date());
+    }
+}

+ 57 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/handle/MyConfig.java

@@ -0,0 +1,57 @@
+package com.sckw.core.handle;
+
+import com.baomidou.mybatisplus.annotation.DbType;
+import com.baomidou.mybatisplus.core.MybatisConfiguration;
+import com.baomidou.mybatisplus.core.MybatisXMLLanguageDriver;
+import com.baomidou.mybatisplus.core.config.GlobalConfig;
+import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
+import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
+import jakarta.annotation.Resource;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.apache.ibatis.type.JdbcType;
+import org.mybatis.spring.annotation.MapperScan;
+import org.mybatis.spring.transaction.SpringManagedTransactionFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+import org.springframework.stereotype.Component;
+import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
+
+import javax.sql.DataSource;
+
+
+/**
+ * @author czh
+ * @desc TODO
+ * @date 2023/6/9
+ */
+@Configuration
+public class MyConfig {
+
+    @Autowired
+    private CustomDataSource customDataSource;
+
+    @Bean
+    public MybatisPlusInterceptor mybatisPlusInterceptor() {
+        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
+        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
+        return interceptor;
+    }
+
+    @Bean
+    public SqlSessionFactory sqlSessionFactory() throws Exception {
+        MybatisSqlSessionFactoryBean factoryBean = new MybatisSqlSessionFactoryBean();
+        factoryBean.setDataSource(customDataSource.dataSource());
+        factoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath*:/mapper/*.xml "));
+        factoryBean.setTypeAliases();
+        MybatisConfiguration configuration = new MybatisConfiguration();
+        configuration.setMapUnderscoreToCamelCase(true);
+        factoryBean.setConfiguration(configuration);
+        factoryBean.setGlobalConfig(new GlobalConfig().setMetaObjectHandler(new CustomMetaHandle()));
+        return factoryBean.getObject();
+    }
+}

+ 3 - 3
sckw-common/sckw-common-redis/src/main/java/com/sckw/redis/configure/RedissonConfiguration.java

@@ -21,8 +21,8 @@ public class RedissonConfiguration {
     @Value("${spring.data.redis.port}")
     private String port;
 
-    @Value("${spring.data.redis.password}")
-    private String password;
+//    @Value("${spring.data.redis.password}")
+//    private String password;
 
     @Value("${spring.data.redis.database}")
     private String database;
@@ -36,7 +36,7 @@ public class RedissonConfiguration {
         config.setCodec(new JsonJacksonCodec());
         config.useSingleServer()
                 .setAddress(address())
-                .setPassword(password)
+//                .setPassword(password)
                 .setDatabase(Integer.parseInt(database))
                 .setConnectTimeout(Integer.parseInt(timeout));
         return Redisson.create(config);

+ 0 - 13
sckw-modules/sckw-system/src/main/java/com/sckw/system/handle/CustomMetaHandle.java

@@ -1,13 +0,0 @@
-package com.sckw.system.handle;
-
-
-import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
-import com.sckw.core.utils.IdWorker;
-import org.apache.ibatis.reflection.MetaObject;
-import org.springframework.context.annotation.Configuration;
-
-//@Configuration
-public class CustomMetaHandle  {
-
-
-}

+ 0 - 34
sckw-modules/sckw-system/src/main/java/com/sckw/system/handle/MyConfig.java

@@ -1,34 +0,0 @@
-package com.sckw.system.handle;
-
-import com.baomidou.mybatisplus.core.MybatisConfiguration;
-import com.baomidou.mybatisplus.core.MybatisXMLLanguageDriver;
-import com.baomidou.mybatisplus.core.config.GlobalConfig;
-import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
-import org.apache.ibatis.session.SqlSessionFactory;
-import org.apache.ibatis.type.JdbcType;
-import org.mybatis.spring.transaction.SpringManagedTransactionFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-import javax.sql.DataSource;
-
-
-//@Configuration
-public class MyConfig {
-
-//    @Bean
-    public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
-        MybatisSqlSessionFactoryBean mybatisSqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
-        mybatisSqlSessionFactoryBean.setTypeAliasesPackage("com.sckw.*.model");
-        mybatisSqlSessionFactoryBean.setDataSource(dataSource);
-        MybatisConfiguration configuration = new MybatisConfiguration();
-        configuration.setDefaultScriptingLanguage(MybatisXMLLanguageDriver.class);
-        configuration.setJdbcTypeForNull(JdbcType.NULL);
-        mybatisSqlSessionFactoryBean.setConfiguration(configuration);
-
-        mybatisSqlSessionFactoryBean.setTransactionFactory(new SpringManagedTransactionFactory());
-//        mybatisSqlSessionFactoryBean.setGlobalConfig(new GlobalConfig().setMetaObjectHandler(new CustomMetaHandle()));
-        return mybatisSqlSessionFactoryBean.getObject();
-    }
-
-}

+ 181 - 0
sckw-modules/sckw-system/src/main/resources/mapper/KwsEnterpriseDao.xml

@@ -631,6 +631,187 @@
       </if>
     </trim>
   </insert>
+  <insert id="insertPPPPP" parameterType="com.sckw.system.model.KwsEnterprise">
+    insert into kws_enterprise
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="firmName != null">
+        firm_name,
+      </if>
+      <if test="code != null">
+        code,
+      </if>
+      <if test="contacts != null">
+        contacts,
+      </if>
+      <if test="telephone != null">
+        telephone,
+      </if>
+      <if test="legalName != null">
+        legal_name,
+      </if>
+      <if test="legalTelephone != null">
+        legal_telephone,
+      </if>
+      <if test="head != null">
+        head,
+      </if>
+      <if test="integral != null">
+        integral,
+      </if>
+      <if test="balance != null">
+        balance,
+      </if>
+      <if test="experience != null">
+        experience,
+      </if>
+      <if test="memberLevel != null">
+        member_level,
+      </if>
+      <if test="regTime != null">
+        reg_time,
+      </if>
+      <if test="regSource != null">
+        reg_source,
+      </if>
+      <if test="orgCode != null">
+        org_code,
+      </if>
+      <if test="cityCode != null">
+        city_code,
+      </if>
+      <if test="detailAddress != null">
+        detail_address,
+      </if>
+      <if test="lat != null">
+        lat,
+      </if>
+      <if test="lng != null">
+        lng,
+      </if>
+      <if test="approval != null">
+        approval,
+      </if>
+      <if test="approvalTime != null">
+        approval_time,
+      </if>
+      <if test="manager != null">
+        manager,
+      </if>
+      <if test="remark != null">
+        remark,
+      </if>
+      <if test="status != null">
+        status,
+      </if>
+      <if test="createBy != null">
+        create_by,
+      </if>
+      <if test="createTime != null">
+        create_time,
+      </if>
+      <if test="updateBy != null">
+        update_by,
+      </if>
+      <if test="updateTime != null">
+        update_time,
+      </if>
+      <if test="delFlag != null">
+        del_flag,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=BIGINT},
+      </if>
+      <if test="firmName != null">
+        #{firmName,jdbcType=VARCHAR},
+      </if>
+      <if test="code != null">
+        #{code,jdbcType=VARCHAR},
+      </if>
+      <if test="contacts != null">
+        #{contacts,jdbcType=VARCHAR},
+      </if>
+      <if test="telephone != null">
+        #{telephone,jdbcType=VARCHAR},
+      </if>
+      <if test="legalName != null">
+        #{legalName,jdbcType=VARCHAR},
+      </if>
+      <if test="legalTelephone != null">
+        #{legalTelephone,jdbcType=VARCHAR},
+      </if>
+      <if test="head != null">
+        #{head,jdbcType=VARCHAR},
+      </if>
+      <if test="integral != null">
+        #{integral,jdbcType=INTEGER},
+      </if>
+      <if test="balance != null">
+        #{balance,jdbcType=DECIMAL},
+      </if>
+      <if test="experience != null">
+        #{experience,jdbcType=INTEGER},
+      </if>
+      <if test="memberLevel != null">
+        #{memberLevel,jdbcType=INTEGER},
+      </if>
+      <if test="regTime != null">
+        #{regTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="regSource != null">
+        #{regSource,jdbcType=VARCHAR},
+      </if>
+      <if test="orgCode != null">
+        #{orgCode,jdbcType=VARCHAR},
+      </if>
+      <if test="cityCode != null">
+        #{cityCode,jdbcType=INTEGER},
+      </if>
+      <if test="detailAddress != null">
+        #{detailAddress,jdbcType=VARCHAR},
+      </if>
+      <if test="lat != null">
+        #{lat,jdbcType=VARCHAR},
+      </if>
+      <if test="lng != null">
+        #{lng,jdbcType=VARCHAR},
+      </if>
+      <if test="approval != null">
+        #{approval,jdbcType=INTEGER},
+      </if>
+      <if test="approvalTime != null">
+        #{approvalTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="manager != null">
+        #{manager,jdbcType=BIGINT},
+      </if>
+      <if test="remark != null">
+        #{remark,jdbcType=VARCHAR},
+      </if>
+      <if test="status != null">
+        #{status,jdbcType=INTEGER},
+      </if>
+      <if test="createBy != null">
+        #{createBy,jdbcType=BIGINT},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateBy != null">
+        #{updateBy,jdbcType=BIGINT},
+      </if>
+      <if test="updateTime != null">
+        #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="delFlag != null">
+        #{delFlag,jdbcType=INTEGER},
+      </if>
+    </trim>
+  </insert>
 
   <update id="update" parameterType="com.sckw.system.model.KwsEnterprise">
     update kws_enterprise