提交 193e06b0 authored 作者: 李炎's avatar 李炎

lic添加项目名称和模块多选支持

上级 2167c36e
......@@ -2,12 +2,17 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.system.dao.LicInfoMapper">
<resultMap id="BaseResultMap" type="com.system.transfer.lic.LicInfoListOutVoRecords">
<result column="module_verification" property="moduleVerification" jdbcType="VARCHAR"
typeHandler="com.system.handler.JacksonTypeHandler"/>
</resultMap>
<select id="licInfoList" parameterType="com.system.transfer.lic.LicInfoListInVo" resultType="com.system.transfer.lic.LicInfoListOutVoRecords">
<select id="licInfoList" parameterType="com.system.transfer.lic.LicInfoListInVo"
resultMap="BaseResultMap">
SELECT
id, lq_lic_name, mac_address, effective_time, file_effective_time, verification_interval, module_verification, remark, create_time
id, lq_lic_name, mac_address, effective_time, file_effective_time, verification_interval, module_verification,
remark, create_time
FROM tb_lic_info
<where>
<if test="inVo.macAddress != null and inVo.macAddress != ''">
......@@ -19,30 +24,31 @@
</select>
<insert id="licInfoCreate" parameterType="com.system.transfer.lic.LicInfoCreateInVo">
INSERT INTO tb_lic_info (
lq_lic_name, mac_address, effective_time, file_effective_time, verification_interval, module_verification, remark
) VALUES (
#{lqLicName}, #{macAddress}, #{effectiveTime}, #{fileEffectiveTime}, #{verificationInterval}, #{moduleVerification}, #{remark}
#{lqLicName}, #{macAddress}, #{effectiveTime}, #{fileEffectiveTime}, #{verificationInterval},
#{moduleVerification,jdbcType=VARCHAR,typeHandler=com.system.handler.JacksonTypeHandler},
#{remark}
)
</insert>
<update id="licInfoUpdate" parameterType="com.system.transfer.lic.LicInfoUpdateInVo">
UPDATE tb_lic_info SET
lq_lic_name = #{lqLicName}, mac_address = #{macAddress}, effective_time = #{effectiveTime}, file_effective_time = #{fileEffectiveTime},
verification_interval = #{verificationInterval}, module_verification = #{moduleVerification}, remark = #{remark}
verification_interval = #{verificationInterval},
module_verification = #{moduleVerification,jdbcType=VARCHAR,typeHandler=com.system.handler.JacksonTypeHandler},
remark = #{remark}
WHERE id = #{id}
</update>
<delete id="licInfoDelete" parameterType="com.system.transfer.lic.LicInfoDeleteInVo">
DELETE FROM tb_lic_info WHERE id = #{id}
......@@ -50,8 +56,8 @@
</delete>
<select id="getLicInfoByMacAddress" parameterType="java.lang.String" resultType="com.system.transfer.lic.LicInfoListOutVoRecords">
<select id="getLicInfoByMacAddress" parameterType="java.lang.String"
resultType="com.system.transfer.lic.LicInfoListOutVoRecords">
SELECT
id, lq_lic_name, mac_address, effective_time, file_effective_time, verification_interval, module_verification, create_time
......@@ -60,5 +66,4 @@
</select>
</mapper>
package com.system.handler;
import java.io.IOException;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.exceptions.PersistenceException;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
/**
JSON 字段类型处理器
**/
@Slf4j
@MappedJdbcTypes(JdbcType.VARCHAR)
public class JacksonTypeHandler<T extends Object> extends BaseTypeHandler<T> {
private static ObjectMapper objectMapper;
private Class<T> type;
static {
objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
public JacksonTypeHandler(Class<T> type) {
if (log.isTraceEnabled()) {
log.trace("JacksonTypeHandler(" + type + ")");
}
if (null == type) {
throw new PersistenceException("Type argument cannot be null");
}
this.type = type;
}
private T parse(String json) {
try {
if (json == null || json.length() == 0) {
return null;
}
return objectMapper.readValue(json, type);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private String toJsonString(T obj) {
try {
return objectMapper.writeValueAsString(obj);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
@Override
public T getNullableResult(ResultSet rs, String columnName) throws SQLException {
return parse(rs.getString(columnName));
}
@Override
public T getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
return parse(rs.getString(columnIndex));
}
@Override
public T getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
return parse(cs.getString(columnIndex));
}
@Override
public void setNonNullParameter(PreparedStatement ps, int columnIndex, T parameter, JdbcType jdbcType)
throws SQLException {
ps.setString(columnIndex, toJsonString(parameter));
}
}
package com.system.oauth.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
......@@ -28,11 +29,13 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
// return service;
// }
// @Override
// @Override
// public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
// resources.tokenStore(jwtTokenStore)
// .resourceId(DEMO_RESOURCE_ID).tokenServices(tokenService());
// }
@Value("${spring.profiles.active}")
private String active;
@Override
public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
......@@ -44,21 +47,24 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
if (active.equals("test")) {
http.authorizeRequests().anyRequest().permitAll() .and().csrf().disable()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
} else {
http.authorizeRequests()
// .antMatchers(FeignInsideAuthConfig.FEIGN_INSIDE_URL_PREFIX+"/**").permitAll()
.antMatchers("/auth/login").permitAll()//登录接口
.antMatchers("/auth/getCaptcha").permitAll()
.antMatchers("/user/image").permitAll()
.antMatchers("/swagger-ui.html", "/webjars/**", "/swagger-resources/**", "/v2/**", "doc.html", "/").permitAll()
.antMatchers("/test").permitAll()
.antMatchers("/webSocketApi/**").permitAll()
.antMatchers("/websocket/**").permitAll()
.antMatchers("/api/lic/online/verification").permitAll()
.anyRequest().authenticated()
.antMatchers("/auth/login").permitAll()//登录接口
.antMatchers("/auth/getCaptcha").permitAll()
.antMatchers("/user/image").permitAll()
.antMatchers("/swagger-ui.html", "/webjars/**", "/swagger-resources/**", "/v2/**", "doc.html", "/").permitAll()
.antMatchers("/test").permitAll()
.antMatchers("/webSocketApi/**").permitAll()
.antMatchers("/websocket/**").permitAll()
.antMatchers("/api/lic/online/verification").permitAll()
.anyRequest().authenticated()
// .antMatchers("/**").access("#oauth2.hasScope('ROLE_ADMIN')")
.and().csrf().disable()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
.and().csrf().disable()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
}
}
}
\ No newline at end of file
......@@ -11,12 +11,12 @@ import org.springframework.web.socket.server.standard.ServerEndpointExporter;
* @author daiyg
* @date 2021/8/24 17:19
*/
@Service
@Configuration
@EnableWebSocket
//@Service
//@Configuration
//@EnableWebSocket
public class WebSocketConfig {
@Bean
// @Bean
public ServerEndpointExporter serverEndpointExporter(){
return new ServerEndpointExporter();
}
......
......@@ -2,6 +2,8 @@ package com.system.transfer.lic;
import lombok.Data;
import java.util.List;
/**
* @author Inori
*/
......@@ -40,7 +42,7 @@ public class LicInfoCreateInVo {
/**
* 模块验证
*/
private String moduleVerification;
private List<String> moduleVerification;
/**
......
......@@ -2,6 +2,8 @@ package com.system.transfer.lic;
import lombok.Data;
import java.util.List;
/**
* @author Inori
*/
......@@ -45,7 +47,7 @@ public class LicInfoListOutVoRecords {
/**
* 模块验证
*/
private String moduleVerification;
private List<String> moduleVerification;
/**
......
......@@ -23,7 +23,7 @@ spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/db_lic?autoReconnect=true&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
username: root
password: 123456
password: root
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论