From 35523c167528054b35132bd5a4cda224ebb8cb74 Mon Sep 17 00:00:00 2001 From: aoshiguchen <1052045476@qq.com> Date: Sat, 6 Aug 2022 17:14:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Elicense=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E3=80=81=E9=87=8D=E7=BD=AE=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/db/mapper/SqlMapperInterceptor.java | 2 +- .../server/controller/LicenseController.java | 17 ++++++++++--- .../proxy/server/dal/LicenseMapper.java | 9 +++++++ .../proxy/server/service/LicenseService.java | 25 ++++++++++++++++++- 4 files changed, 47 insertions(+), 6 deletions(-) diff --git a/neutrino-core/src/main/java/fun/asgc/neutrino/core/db/mapper/SqlMapperInterceptor.java b/neutrino-core/src/main/java/fun/asgc/neutrino/core/db/mapper/SqlMapperInterceptor.java index c64f0f80..1572c908 100644 --- a/neutrino-core/src/main/java/fun/asgc/neutrino/core/db/mapper/SqlMapperInterceptor.java +++ b/neutrino-core/src/main/java/fun/asgc/neutrino/core/db/mapper/SqlMapperInterceptor.java @@ -72,7 +72,7 @@ public class SqlMapperInterceptor implements Interceptor { if (null == params) { res = jdbcTemplate.update(sql); } else if (params.getClass().isArray()){ - res = jdbcTemplate.update(sql, params); + res = jdbcTemplate.update(sql, (Object[])params); } else if (params instanceof Map) { res = jdbcTemplate.updateByMap(sql, (Map)params); } diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/LicenseController.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/LicenseController.java index 18b50d05..87f2ad8e 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/LicenseController.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/controller/LicenseController.java @@ -29,10 +29,7 @@ package fun.asgc.neutrino.proxy.server.controller; import fun.asgc.neutrino.core.annotation.Autowired; import fun.asgc.neutrino.core.annotation.NonIntercept; -import fun.asgc.neutrino.core.web.annotation.PostMapping; -import fun.asgc.neutrino.core.web.annotation.RequestBody; -import fun.asgc.neutrino.core.web.annotation.RequestMapping; -import fun.asgc.neutrino.core.web.annotation.RestController; +import fun.asgc.neutrino.core.web.annotation.*; import fun.asgc.neutrino.proxy.server.controller.req.LicenseCreateReq; import fun.asgc.neutrino.proxy.server.controller.req.LicenseUpdateEnableStatusReq; import fun.asgc.neutrino.proxy.server.controller.res.LicenseCreateRes; @@ -61,4 +58,16 @@ public class LicenseController { return licenseService.updateEnableStatus(req); } + @PostMapping("delete") + public void delete(@RequestParam("id") Integer id) { + // TODO 参数校验 + licenseService.delete(id); + } + + @PostMapping("reset") + public void reset(@RequestParam("id") Integer id) { + // TODO 参数校验 + licenseService.reset(id); + } + } diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/LicenseMapper.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/LicenseMapper.java index 792c4083..e49a47af 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/LicenseMapper.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/dal/LicenseMapper.java @@ -23,10 +23,13 @@ package fun.asgc.neutrino.proxy.server.dal; import fun.asgc.neutrino.core.annotation.Component; import fun.asgc.neutrino.core.annotation.Param; +import fun.asgc.neutrino.core.db.annotation.Delete; import fun.asgc.neutrino.core.db.annotation.Update; import fun.asgc.neutrino.core.db.mapper.SqlMapper; import fun.asgc.neutrino.proxy.server.dal.entity.LicenseDO; +import java.util.Date; + /** * * @author: aoshiguchen @@ -43,4 +46,10 @@ public interface LicenseMapper extends SqlMapper { @Update("update `license` set enable = :enable where id = :id") void updateEnableStatus(@Param("id") Integer id, @Param("enable") Integer enable); + + @Update("update `license` set key = :key,update_time = :updateTime where id = :id") + void reset(@Param("id") Integer id, @Param("key") String key, @Param("updateTime") Date updateTime); + + @Delete("delete from `license` where id = ?") + void delete(Integer id); } diff --git a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/LicenseService.java b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/LicenseService.java index 8467fea0..869ffc2d 100644 --- a/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/LicenseService.java +++ b/neutrino-proxy-server/src/main/java/fun/asgc/neutrino/proxy/server/service/LicenseService.java @@ -23,7 +23,6 @@ package fun.asgc.neutrino.proxy.server.service; import fun.asgc.neutrino.core.annotation.Autowired; import fun.asgc.neutrino.core.annotation.Component; -import fun.asgc.neutrino.core.web.annotation.RequestBody; import fun.asgc.neutrino.proxy.server.base.rest.constant.EnableStatusEnum; import fun.asgc.neutrino.proxy.server.base.rest.constant.OnlineStatusEnum; import fun.asgc.neutrino.proxy.server.controller.req.LicenseCreateReq; @@ -68,10 +67,34 @@ public class LicenseService { return new LicenseCreateRes(); } + /** + * 更新license启用状态 + * @param req + * @return + */ public LicenseUpdateEnableStatusRes updateEnableStatus(LicenseUpdateEnableStatusReq req) { licenseMapper.updateEnableStatus(req.getId(), req.getEnable()); return new LicenseUpdateEnableStatusRes(); } + /** + * 删除license + * @param id + */ + public void delete(Integer id) { + licenseMapper.delete(id); + } + + /** + * 重置license + * @param id + */ + public void reset(Integer id) { + String key = UUID.randomUUID().toString().replaceAll("-", ""); + Date now = new Date(); + + licenseMapper.reset(id, key, now); + } + }