代码优化

This commit is contained in:
ldj_willow
2022-09-24 10:22:34 +08:00
parent 751745f4f1
commit ec6ccb175d
13 changed files with 11 additions and 778 deletions

View File

@@ -1,9 +1,9 @@
package org.nl;
import cn.dev33.satoken.annotation.SaIgnore;
import com.alicp.jetcache.anno.config.EnableCreateCacheAnnotation;
import com.alicp.jetcache.anno.config.EnableMethodCache;
import io.swagger.annotations.Api;
import org.nl.modules.common.annotation.rest.AnonymousGetMapping;
import org.nl.wql.util.SpringContextHolder;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -14,6 +14,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
@@ -58,7 +59,8 @@ public class AppRun {
*
* @return /
*/
@AnonymousGetMapping("/")
@GetMapping("/")
@SaIgnore
public String index() {
return "Backend service started successfully";
}

View File

@@ -1,30 +0,0 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.nl.modules.common.annotation;
import java.lang.annotation.*;
/**
* @author jacky
* 用于标记匿名访问方法
*/
@Inherited
@Documented
@Target({ElementType.METHOD,ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface AnonymousAccess {
}

View File

@@ -1,86 +0,0 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.nl.modules.common.annotation.rest;
import org.nl.annotation.AnonymousAccess;
import org.springframework.core.annotation.AliasFor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.lang.annotation.*;
/**
* Annotation for mapping HTTP {@code DELETE} requests onto specific handler
* methods.
* 支持匿名访问 DeleteMapping
*
* @author liaojinlong
* @see AnonymousGetMapping
* @see AnonymousPostMapping
* @see AnonymousPutMapping
* @see AnonymousPatchMapping
* @see RequestMapping
*/
@AnonymousAccess
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@RequestMapping(method = RequestMethod.DELETE)
public @interface AnonymousDeleteMapping {
/**
* Alias for {@link RequestMapping#name}.
*/
@AliasFor(annotation = RequestMapping.class)
String name() default "";
/**
* Alias for {@link RequestMapping#value}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] value() default {};
/**
* Alias for {@link RequestMapping#path}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] path() default {};
/**
* Alias for {@link RequestMapping#params}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] params() default {};
/**
* Alias for {@link RequestMapping#headers}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] headers() default {};
/**
* Alias for {@link RequestMapping#consumes}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] consumes() default {};
/**
* Alias for {@link RequestMapping#produces}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] produces() default {};
}

View File

@@ -1,86 +0,0 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.nl.modules.common.annotation.rest;
import org.nl.annotation.AnonymousAccess;
import org.springframework.core.annotation.AliasFor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.lang.annotation.*;
/**
* Annotation for mapping HTTP {@code GET} requests onto specific handler
* methods.
* <p>
* 支持匿名访问 GetMapping
*
* @author liaojinlong
* @see RequestMapping
*/
@AnonymousAccess
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@RequestMapping(method = RequestMethod.GET)
public @interface AnonymousGetMapping {
/**
* Alias for {@link RequestMapping#name}.
*/
@AliasFor(annotation = RequestMapping.class)
String name() default "";
/**
* Alias for {@link RequestMapping#value}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] value() default {};
/**
* Alias for {@link RequestMapping#path}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] path() default {};
/**
* Alias for {@link RequestMapping#params}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] params() default {};
/**
* Alias for {@link RequestMapping#headers}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] headers() default {};
/**
* Alias for {@link RequestMapping#consumes}.
*
* @since 4.3.5
*/
@AliasFor(annotation = RequestMapping.class)
String[] consumes() default {};
/**
* Alias for {@link RequestMapping#produces}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] produces() default {};
}

View File

@@ -1,87 +0,0 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.nl.modules.common.annotation.rest;
import org.nl.annotation.AnonymousAccess;
import org.springframework.core.annotation.AliasFor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.lang.annotation.*;
/**
* Annotation for mapping HTTP {@code PATCH} requests onto specific handler
* methods.
* * 支持匿名访问 PatchMapping
*
* @author liaojinlong
* @see AnonymousGetMapping
* @see AnonymousPostMapping
* @see AnonymousPutMapping
* @see AnonymousDeleteMapping
* @see RequestMapping
*/
@AnonymousAccess
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@RequestMapping(method = RequestMethod.PATCH)
public @interface AnonymousPatchMapping {
/**
* Alias for {@link RequestMapping#name}.
*/
@AliasFor(annotation = RequestMapping.class)
String name() default "";
/**
* Alias for {@link RequestMapping#value}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] value() default {};
/**
* Alias for {@link RequestMapping#path}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] path() default {};
/**
* Alias for {@link RequestMapping#params}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] params() default {};
/**
* Alias for {@link RequestMapping#headers}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] headers() default {};
/**
* Alias for {@link RequestMapping#consumes}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] consumes() default {};
/**
* Alias for {@link RequestMapping#produces}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] produces() default {};
}

View File

@@ -1,87 +0,0 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.nl.modules.common.annotation.rest;
import org.nl.annotation.AnonymousAccess;
import org.springframework.core.annotation.AliasFor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.lang.annotation.*;
/**
* Annotation for mapping HTTP {@code POST} requests onto specific handler
* methods.
* 支持匿名访问 PostMapping
*
* @author liaojinlong
* @see AnonymousGetMapping
* @see AnonymousPostMapping
* @see AnonymousPutMapping
* @see AnonymousDeleteMapping
* @see RequestMapping
*/
@AnonymousAccess
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@RequestMapping(method = RequestMethod.POST)
public @interface AnonymousPostMapping {
/**
* Alias for {@link RequestMapping#name}.
*/
@AliasFor(annotation = RequestMapping.class)
String name() default "";
/**
* Alias for {@link RequestMapping#value}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] value() default {};
/**
* Alias for {@link RequestMapping#path}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] path() default {};
/**
* Alias for {@link RequestMapping#params}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] params() default {};
/**
* Alias for {@link RequestMapping#headers}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] headers() default {};
/**
* Alias for {@link RequestMapping#consumes}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] consumes() default {};
/**
* Alias for {@link RequestMapping#produces}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] produces() default {};
}

View File

@@ -1,87 +0,0 @@
/*
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.nl.modules.common.annotation.rest;
import org.nl.annotation.AnonymousAccess;
import org.springframework.core.annotation.AliasFor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.lang.annotation.*;
/**
* Annotation for mapping HTTP {@code PUT} requests onto specific handler
* methods.
* * 支持匿名访问 PutMapping
*
* @author liaojinlong
* @see AnonymousGetMapping
* @see AnonymousPostMapping
* @see AnonymousPutMapping
* @see AnonymousDeleteMapping
* @see RequestMapping
*/
@AnonymousAccess
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@RequestMapping(method = RequestMethod.PUT)
public @interface AnonymousPutMapping {
/**
* Alias for {@link RequestMapping#name}.
*/
@AliasFor(annotation = RequestMapping.class)
String name() default "";
/**
* Alias for {@link RequestMapping#value}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] value() default {};
/**
* Alias for {@link RequestMapping#path}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] path() default {};
/**
* Alias for {@link RequestMapping#params}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] params() default {};
/**
* Alias for {@link RequestMapping#headers}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] headers() default {};
/**
* Alias for {@link RequestMapping#consumes}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] consumes() default {};
/**
* Alias for {@link RequestMapping#produces}.
*/
@AliasFor(annotation = RequestMapping.class)
String[] produces() default {};
}

View File

@@ -1,245 +0,0 @@
[交易说明]
交易名: 业绩指标
所属模块:
功能简述:
版权所有:
表引用:
版本经历:
[数据库]
--指定数据库为空采用默认值默认为db.properties中列出的第一个库
[IO定义]
#################################################
## 表字段对应输入参数
#################################################
输入.flag TYPEAS s_string
输入.where TYPEAS f_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
[临时变量]
--所有中间过程变量均可在此处定义
[业务过程]
##########################################
# 1、输入输出检查 #
##########################################
##########################################
# 2、主过程前处理 #
##########################################
##########################################
# 3、业务主过程 #
##########################################
IF 输入.flag = "1"
QUERY
SELECT
work.workorder_id,
task.material_id,
task.pcsn
FROM
PDM_BI_WorkOrder work
LEFT JOIN PDM_BI_WorkTask task ON work.workorder_id = task.workorder_id
WHERE
work.is_delete = '0'
AND task.status = '99'
AND task.workprocedure_code = 'GX003'
AND task.nextworkprocedure_id = task.workprocedure_id
AND (
work.create_time>=date(now()) and work.create_time<DATE_ADD(date(now()),INTERVAL 1 DAY)
)
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "2"
QUERY
SELECT
SUM(line.qty) AS qty
FROM
(
SELECT
distinct bucketunique,
material_id,
pcsn,
qty
FROM
PDM_BI_ProcedureOffline
) AS line
WHERE
1=1
OPTION 输入.material_id <> ""
line.material_id = 输入.material_id
ENDOPTION
OPTION 输入.pcsn <> ""
line.pcsn = 输入.pcsn
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "3"
QUERY
SELECT
count(*) AS sum
FROM
PDM_BI_WorkTask work
WHERE
workprocedure_code = 'GX003'
AND status = '99'
OPTION 输入.where <> ""
输入.where
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "4"
QUERY
SELECT
count(*) AS sum
FROM
em_bi_deviceinfo
WHERE
workprocedure_code = 'GX003'
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "5"
QUERY
SELECT
count(*) AS sum
FROM
PDM_BI_WorkOrder work
LEFT JOIN QL_TEST_PhysicalMst phyMst ON work.material_id = phyMst.material_id AND work.pcsn = phyMst.pcsn
LEFT JOIN QL_TEST_InspectionSheetDtl shtDtl ON work.material_id = shtDtl.material_id AND work.pcsn = shtDtl.pcsn
LEFT JOIN QL_TEST_InspectionSheetMst shtMst ON shtMst.inspection_id = shtDtl.inspection_id
WHERE
work.status = '99'
AND work.finish_type = '01'
AND work.realend_time <= work.planend_time
AND phyMst.is_delete = '0'
AND phyMst.is_effective = '1'
AND shtMst.is_delete = '0'
AND shtMst.bill_status = '99'
AND shtDtl.bill_status = '99'
AND shtDtl.result = '01'
OPTION 输入.where <> ""
输入.where
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "6"
QUERY
SELECT
count(*) AS sum
FROM
PDM_BI_WorkOrder work
WHERE
work.status = '99'
AND work.is_delete = '0'
OPTION 输入.where <> ""
输入.where
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "7"
QUERY
SELECT
count(*) AS sum
FROM
QL_TEST_PhysicalMst phyMst
LEFT JOIN QL_TEST_InspectionSheetDtl shtDtl ON phyMst.material_id = shtDtl.material_id AND phyMst.pcsn = shtDtl.pcsn
LEFT JOIN QL_TEST_InspectionSheetMst shtMst ON shtMst.inspection_id = shtDtl.inspection_id
WHERE
phyMst.is_delete = '0'
AND phyMst.is_effective = '1'
AND shtMst.is_delete = '0'
AND shtMst.bill_status = '99'
AND shtDtl.bill_status = '99'
AND shtDtl.result = '01'
OPTION 输入.where <> ""
输入.where
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "8"
QUERY
SELECT
count(*) AS sum
FROM
QL_TEST_PhysicalMst phyMst
WHERE
phyMst.is_delete = '0'
AND phyMst.is_effective = '1'
OPTION 输入.where <> ""
输入.where
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "9"
QUERY
SELECT
count(*) AS sum
FROM
QL_TEST_WorkProcedureMst mst
WHERE
mst.bill_status = '99'
AND mst.is_delete = '0'
AND mst.result = '01'
AND mst.workprocedure_code = 'GX003'
OPTION 输入.where <> ""
输入.where
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "10"
QUERY
SELECT
count(*) AS sum
FROM
QL_TEST_WorkProcedureMst mst
WHERE
mst.bill_status = '99'
AND mst.is_delete = '0'
AND mst.workprocedure_code = 'GX003'
OPTION 输入.where <> ""
输入.where
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF

View File

@@ -1,55 +0,0 @@
[交易说明]
交易名: 日志
所属模块:
功能简述:
版权所有:
表引用:
版本经历:
[数据库]
--指定数据库为空采用默认值默认为db.properties中列出的第一个库
[IO定义]
#################################################
## 表字段对应输入参数
#################################################
输入.flag TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
[临时变量]
--所有中间过程变量均可在此处定义
[业务过程]
##########################################
# 1、输入输出检查 #
##########################################
##########################################
# 2、主过程前处理 #
##########################################
##########################################
# 3、业务主过程 #
##########################################
IF 输入.flag = "1"
PAGEQUERY
SELECT
TIMESTAMPDIFF(DAY,create_time,now()) AS time,request_ip
FROM
sys_log
WHERE
1=1
ENDSELECT
ENDPAGEQUERY
ENDIF

View File

@@ -25,9 +25,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.common.annotation.rest.AnonymousDeleteMapping;
import org.nl.modules.common.annotation.rest.AnonymousGetMapping;
import org.nl.modules.common.annotation.rest.AnonymousPostMapping;
import org.nl.modules.common.config.RsaProperties;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.common.utils.RedisUtils;
@@ -44,10 +41,7 @@ import org.nl.modules.system.service.dto.UserDto;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@@ -76,7 +70,7 @@ public class AuthorizationController {
private LoginProperties loginProperties;
@ApiOperation("登录授权")
@AnonymousPostMapping(value = "/login")
@PostMapping(value = "/login")
public ResponseEntity<Object> login(@Validated @RequestBody AuthUserDto authUser, HttpServletRequest request) throws Exception {
// 密码解密 - 前端的加密规则: encrypt
String password = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, authUser.getPassword());
@@ -136,7 +130,7 @@ public class AuthorizationController {
}
@ApiOperation("获取验证码")
@AnonymousGetMapping(value = "/code")
@GetMapping(value = "/code")
public ResponseEntity<Object> getCode() {
// 获取运算的结果
Captcha captcha = loginProperties.getCaptcha();
@@ -157,7 +151,7 @@ public class AuthorizationController {
}
@ApiOperation("退出登录")
@AnonymousDeleteMapping(value = "/logout")
@DeleteMapping(value = "/logout")
public ResponseEntity<Object> logout(HttpServletRequest request) {
onlineUserService.logout(StpUtil.getTokenValue());
StpUtil.logout();

View File

@@ -18,7 +18,7 @@ package org.nl.modules.system.rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.nl.modules.common.annotation.Limit;
import org.nl.modules.common.annotation.rest.AnonymousGetMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -38,7 +38,7 @@ public class LimitController {
/**
* 测试限流注解,下面配置说明该接口 60秒内最多只能访问 10次保存到redis的键名为 limit_test
*/
@AnonymousGetMapping
@GetMapping
@ApiOperation("测试")
@Limit(key = "test", period = 60, count = 10, name = "testLimit", prefix = "limit")
public int test() {