新增license详情、更新接口。

This commit is contained in:
aoshiguchen
2022-08-06 17:25:53 +08:00
parent 35523c1675
commit 2b8c538a7b
6 changed files with 202 additions and 0 deletions
@@ -32,8 +32,11 @@ import fun.asgc.neutrino.core.annotation.NonIntercept;
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.req.LicenseUpdateReq;
import fun.asgc.neutrino.proxy.server.controller.res.LicenseCreateRes;
import fun.asgc.neutrino.proxy.server.controller.res.LicenseDetailRes;
import fun.asgc.neutrino.proxy.server.controller.res.LicenseUpdateEnableStatusRes;
import fun.asgc.neutrino.proxy.server.controller.res.LicenseUpdateRes;
import fun.asgc.neutrino.proxy.server.service.LicenseService;
@NonIntercept
@@ -51,6 +54,18 @@ public class LicenseController {
return licenseService.create(req);
}
@PostMapping("update")
public LicenseUpdateRes update(@RequestBody LicenseUpdateReq req) {
// TODO 参数校验
return licenseService.update(req);
}
@GetMapping("detail")
public LicenseDetailRes detail(@RequestParam("id") Integer id) {
// TODO 参数校验
return licenseService.detail(id);
}
@PostMapping("update/enable-status")
public LicenseUpdateEnableStatusRes updateEnableStatus(@RequestBody LicenseUpdateEnableStatusReq req) {
// TODO 参数校验
@@ -0,0 +1,41 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package fun.asgc.neutrino.proxy.server.controller.req;
import lombok.Data;
/**
*
* @author: aoshiguchen
* @date: 2022/8/6
*/
@Data
public class LicenseUpdateReq {
/**
* id
*/
private Integer id;
/**
* license名称
*/
private String name;
}
@@ -0,0 +1,73 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package fun.asgc.neutrino.proxy.server.controller.res;
import fun.asgc.neutrino.proxy.server.base.rest.constant.OnlineStatusEnum;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
*
* @author: aoshiguchen
* @date: 2022/8/6
*/
@Accessors(chain = true)
@Data
public class LicenseDetailRes {
private Integer id;
/**
* 名称
*/
private String name;
/**
* licenseKey
*/
private String key;
/**
* 用户ID
*/
private Integer userId;
/**
* 用户名
*/
private String userName;
/**
* 是否在线
* {@link OnlineStatusEnum}
*/
private Integer isOnline;
/**
* 启用状态
* {@link fun.asgc.neutrino.proxy.server.base.rest.constant.EnableStatusEnum}
*/
private Integer enable;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
}
@@ -0,0 +1,31 @@
/**
* Copyright (c) 2022 aoshiguchen
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package fun.asgc.neutrino.proxy.server.controller.res;
/**
*
* @author: aoshiguchen
* @date: 2022/8/6
*/
public class LicenseUpdateRes {
}
@@ -24,6 +24,7 @@ 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.Select;
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;
@@ -52,4 +53,10 @@ public interface LicenseMapper extends SqlMapper {
@Delete("delete from `license` where id = ?")
void delete(Integer id);
@Select("select * from `license` where id = ?")
LicenseDO findById(Integer id);
@Update("update `license` set name = :name where id = :id")
void update(@Param("id") Integer id, @Param("name") String name);
}
@@ -27,10 +27,15 @@ 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;
import fun.asgc.neutrino.proxy.server.controller.req.LicenseUpdateEnableStatusReq;
import fun.asgc.neutrino.proxy.server.controller.req.LicenseUpdateReq;
import fun.asgc.neutrino.proxy.server.controller.res.LicenseCreateRes;
import fun.asgc.neutrino.proxy.server.controller.res.LicenseDetailRes;
import fun.asgc.neutrino.proxy.server.controller.res.LicenseUpdateEnableStatusRes;
import fun.asgc.neutrino.proxy.server.controller.res.LicenseUpdateRes;
import fun.asgc.neutrino.proxy.server.dal.LicenseMapper;
import fun.asgc.neutrino.proxy.server.dal.UserMapper;
import fun.asgc.neutrino.proxy.server.dal.entity.LicenseDO;
import fun.asgc.neutrino.proxy.server.dal.entity.UserDO;
import java.util.Date;
import java.util.UUID;
@@ -45,6 +50,8 @@ public class LicenseService {
@Autowired
private LicenseMapper licenseMapper;
@Autowired
private UserMapper userMapper;
/**
* 创建license
@@ -67,6 +74,34 @@ public class LicenseService {
return new LicenseCreateRes();
}
public LicenseUpdateRes update(LicenseUpdateReq req) {
licenseMapper.update(req.getId(), req.getName());
return new LicenseUpdateRes();
}
public LicenseDetailRes detail(Integer id) {
LicenseDO licenseDO = licenseMapper.findById(id);
if (null == licenseDO) {
return null;
}
UserDO userDO = userMapper.findById(licenseDO.getUserId());
String userName = "";
if (null != userDO) {
userName = userDO.getName();
}
return new LicenseDetailRes()
.setId(licenseDO.getId())
.setName(licenseDO.getName())
.setKey(licenseDO.getKey())
.setUserId(licenseDO.getUserId())
.setUserName(userName)
.setIsOnline(licenseDO.getIsOnline())
.setEnable(licenseDO.getEnable())
.setCreateTime(licenseDO.getCreateTime())
.setUpdateTime(licenseDO.getUpdateTime())
;
}
/**
* 更新license启用状态
* @param req