Commit a0caf9d2 authored by zengtianlai3's avatar zengtianlai3

修改格式

parent abbdb77b
<component name="libraryTable">
<library name="Maven: com.alibaba:fastjson:1.2.28">
<CLASSES>
<root url="jar://C:/tools/Spring/mvn_repository/com/alibaba/fastjson/1.2.28/fastjson-1.2.28.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://C:/tools/Spring/mvn_repository/com/alibaba/fastjson/1.2.28/fastjson-1.2.28-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://C:/tools/Spring/mvn_repository/com/alibaba/fastjson/1.2.28/fastjson-1.2.28-sources.jar!/" />
</SOURCES>
</library>
</component>
\ No newline at end of file
...@@ -57,6 +57,12 @@ ...@@ -57,6 +57,12 @@
<artifactId>velocity-engine-core</artifactId> <artifactId>velocity-engine-core</artifactId>
<version>2.0</version> <version>2.0</version>
</dependency> </dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.28</version>
</dependency>
</dependencies> </dependencies>
......
package iot.sixiang.license.controller; package iot.sixiang.license.controller;
import com.alibaba.fastjson.JSONObject;
import iot.sixiang.license.entity.License; import iot.sixiang.license.entity.License;
import iot.sixiang.license.model.RespResult; import iot.sixiang.license.model.RespResult;
import iot.sixiang.license.service.LicenseService; import iot.sixiang.license.service.LicenseService;
...@@ -18,7 +19,7 @@ import java.util.List; ...@@ -18,7 +19,7 @@ import java.util.List;
* @since 2022-06-06 * @since 2022-06-06
*/ */
@RestController @RestController
@RequestMapping("/iot_sixiang_license/license") @RequestMapping("/iot_license/license")
public class LicenseController { public class LicenseController {
@Autowired @Autowired
...@@ -26,12 +27,15 @@ public class LicenseController { ...@@ -26,12 +27,15 @@ public class LicenseController {
/** /**
* 添加license * 添加license
* @param license * @param jsonObject
* @return * @return
*/ */
@PostMapping("add") @PostMapping("add")
public RespResult addLicense(@RequestBody License license){ public RespResult addLicense(@RequestBody JSONObject jsonObject){
boolean save = licenseService.addLicense(license); String appId = (String) jsonObject.get("app_id");
String appKey = (String) jsonObject.get("app_key");
String userId = (String) jsonObject.get("user_id");
boolean save = licenseService.addLicense(appId,appKey,userId);
if (save) { if (save) {
return RespResult.success(); return RespResult.success();
} else { } else {
...@@ -45,7 +49,7 @@ public class LicenseController { ...@@ -45,7 +49,7 @@ public class LicenseController {
* @return * @return
*/ */
@PostMapping("delete") @PostMapping("delete")
public RespResult deleteLicense(@RequestParam("appId") String appId) { public RespResult deleteLicense(@RequestParam("app_id") String appId) {
boolean flag = licenseService.deleteLicense(appId); boolean flag = licenseService.deleteLicense(appId);
if (flag) { if (flag) {
return RespResult.success(); return RespResult.success();
...@@ -61,7 +65,7 @@ public class LicenseController { ...@@ -61,7 +65,7 @@ public class LicenseController {
* @return * @return
*/ */
@GetMapping("get_license_list") @GetMapping("get_license_list")
public RespResult getLicenseList(@RequestParam("pageNo") int pageNo, @RequestParam("pageSize") int pageSize) { public RespResult getLicenseList(@RequestParam("page_no") int pageNo, @RequestParam("page_size") int pageSize) {
List<License> records = licenseService.getLicenseList(pageNo,pageSize); List<License> records = licenseService.getLicenseList(pageNo,pageSize);
return RespResult.success().record(records); return RespResult.success().record(records);
} }
......
package iot.sixiang.license.controller; package iot.sixiang.license.controller;
import com.alibaba.fastjson.JSONObject;
import iot.sixiang.license.entity.Server; import iot.sixiang.license.entity.Server;
import iot.sixiang.license.model.RespResult; import iot.sixiang.license.model.RespResult;
import iot.sixiang.license.service.ServerService; import iot.sixiang.license.service.ServerService;
...@@ -18,19 +19,21 @@ import java.util.List; ...@@ -18,19 +19,21 @@ import java.util.List;
* @since 2022-06-06 * @since 2022-06-06
*/ */
@RestController @RestController
@RequestMapping("/iot_sixiang_license/server") @RequestMapping("/iot_license/server")
public class ServerController { public class ServerController {
@Autowired @Autowired
private ServerService serverService; private ServerService serverService;
/** /**
* 添加server * 添加server
* @param server * @param jsonObject
* @return * @return
*/ */
@PostMapping("add") @PostMapping("add")
public RespResult addServer(@RequestBody Server server) { public RespResult addServer(@RequestBody JSONObject jsonObject) {
boolean save = serverService.addServer(server); String serverIp = (String) jsonObject.get("server_ip");
int port = (int)jsonObject.get("port");
boolean save = serverService.addServer(serverIp,port);
if (save) { if (save) {
return RespResult.success(); return RespResult.success();
} else { } else {
...@@ -44,7 +47,7 @@ public class ServerController { ...@@ -44,7 +47,7 @@ public class ServerController {
* @return * @return
*/ */
@PostMapping("delete") @PostMapping("delete")
public RespResult deleteServer(@RequestParam("serverIp") String serverIp) { public RespResult deleteServer(@RequestParam("server_ip") String serverIp) {
boolean flag = serverService.deleteServer(serverIp); boolean flag = serverService.deleteServer(serverIp);
if (flag) { if (flag) {
return RespResult.success(); return RespResult.success();
...@@ -60,7 +63,7 @@ public class ServerController { ...@@ -60,7 +63,7 @@ public class ServerController {
* @return * @return
*/ */
@GetMapping("get_server_list") @GetMapping("get_server_list")
public RespResult getServerList(@RequestParam("pageNo") int pageNo, @RequestParam("pageSize") int pageSize) { public RespResult getServerList(@RequestParam("page_no") int pageNo, @RequestParam("page_size") int pageSize) {
List<Server> records = serverService.getServerList(pageNo,pageSize); List<Server> records = serverService.getServerList(pageNo,pageSize);
return RespResult.success().record(records); return RespResult.success().record(records);
} }
......
...@@ -2,6 +2,7 @@ package iot.sixiang.license.controller; ...@@ -2,6 +2,7 @@ package iot.sixiang.license.controller;
import com.alibaba.fastjson.JSONObject;
import iot.sixiang.license.entity.User; import iot.sixiang.license.entity.User;
import iot.sixiang.license.model.RespResult; import iot.sixiang.license.model.RespResult;
import iot.sixiang.license.service.UserService; import iot.sixiang.license.service.UserService;
...@@ -19,7 +20,7 @@ import java.util.List; ...@@ -19,7 +20,7 @@ import java.util.List;
* @since 2022-06-06 * @since 2022-06-06
*/ */
@RestController @RestController
@RequestMapping("/iot_sixiang_license/user") @RequestMapping("/iot_license/user")
public class UserController { public class UserController {
@Autowired @Autowired
...@@ -27,12 +28,14 @@ public class UserController { ...@@ -27,12 +28,14 @@ public class UserController {
/** /**
* 添加user * 添加user
* @param user * @param jsonObject
* @return * @return
*/ */
@PostMapping("add") @PostMapping("add")
public RespResult addUser(@RequestBody User user) { public RespResult addUser(@RequestBody JSONObject jsonObject) {
boolean save = userService.addUser(user); String userId = (String) jsonObject.get("user_id");
String password = (String) jsonObject.get("password");
boolean save = userService.addUser(userId, password);
if (save) { if (save) {
return RespResult.success(); return RespResult.success();
} else { } else {
...@@ -46,7 +49,7 @@ public class UserController { ...@@ -46,7 +49,7 @@ public class UserController {
* @return * @return
*/ */
@PostMapping("delete") @PostMapping("delete")
public RespResult deleteUser(@RequestParam("userId") String userId) { public RespResult deleteUser(@RequestParam("user_id") String userId) {
boolean flag = userService.deleteUser(userId); boolean flag = userService.deleteUser(userId);
if (flag) { if (flag) {
return RespResult.success(); return RespResult.success();
...@@ -62,7 +65,7 @@ public class UserController { ...@@ -62,7 +65,7 @@ public class UserController {
* @return * @return
*/ */
@GetMapping("get_user_list") @GetMapping("get_user_list")
public RespResult getUserList(@RequestParam("pageNo") int pageNo, @RequestParam("pageSize") int pageSize) { public RespResult getUserList(@RequestParam("page_no") int pageNo, @RequestParam("page_size") int pageSize) {
List<User> records = userService.getUserList(pageNo,pageSize); List<User> records = userService.getUserList(pageNo,pageSize);
return RespResult.success().record(records); return RespResult.success().record(records);
} }
......
...@@ -13,7 +13,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -13,7 +13,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/ */
public interface LicenseMapper extends BaseMapper<License> { public interface LicenseMapper extends BaseMapper<License> {
boolean addLicense(License license);
boolean deleteLicense(String appId); boolean deleteLicense(String appId);
boolean addLicense(String appId, String appKey, String userId);
} }
...@@ -13,7 +13,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -13,7 +13,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/ */
public interface ServerMapper extends BaseMapper<Server> { public interface ServerMapper extends BaseMapper<Server> {
boolean addServer(Server server);
boolean deleteServer(String serverIp); boolean deleteServer(String serverIp);
boolean addServer(String serverIp, int port);
} }
...@@ -13,7 +13,8 @@ import iot.sixiang.license.entity.User; ...@@ -13,7 +13,8 @@ import iot.sixiang.license.entity.User;
*/ */
public interface UserMapper extends BaseMapper<User> { public interface UserMapper extends BaseMapper<User> {
boolean addUser(User user);
boolean deleteUser(String user); boolean deleteUser(String user);
boolean addUser(String userId, String password);
} }
...@@ -15,9 +15,9 @@ import java.util.List; ...@@ -15,9 +15,9 @@ import java.util.List;
*/ */
public interface LicenseService extends IService<License> { public interface LicenseService extends IService<License> {
boolean addLicense(License license);
List<License> getLicenseList(int pageNo, int pageSize); List<License> getLicenseList(int pageNo, int pageSize);
boolean deleteLicense(String appId); boolean deleteLicense(String appId);
boolean addLicense(String appId, String appKey, String userId);
} }
...@@ -15,9 +15,9 @@ import java.util.List; ...@@ -15,9 +15,9 @@ import java.util.List;
*/ */
public interface ServerService extends IService<Server> { public interface ServerService extends IService<Server> {
boolean addServer(Server server);
List<Server> getServerList(int pageNo, int pageSize); List<Server> getServerList(int pageNo, int pageSize);
boolean deleteServer(String serverIp); boolean deleteServer(String serverIp);
boolean addServer(String serverIp, int port);
} }
...@@ -15,9 +15,9 @@ import java.util.List; ...@@ -15,9 +15,9 @@ import java.util.List;
*/ */
public interface UserService extends IService<User> { public interface UserService extends IService<User> {
boolean addUser(User user);
List<User> getUserList(int pageNo, int pageSize); List<User> getUserList(int pageNo, int pageSize);
boolean deleteUser(String user); boolean deleteUser(String user);
boolean addUser(String userId, String password);
} }
...@@ -23,10 +23,6 @@ public class LicenseServiceImpl extends ServiceImpl<LicenseMapper, License> impl ...@@ -23,10 +23,6 @@ public class LicenseServiceImpl extends ServiceImpl<LicenseMapper, License> impl
@Resource @Resource
LicenseMapper licenseMapper; LicenseMapper licenseMapper;
@Override
public boolean addLicense(License license) {
return licenseMapper.addLicense(license);
}
@Override @Override
public List<License> getLicenseList(int pageNo, int pageSize) { public List<License> getLicenseList(int pageNo, int pageSize) {
...@@ -41,4 +37,9 @@ public class LicenseServiceImpl extends ServiceImpl<LicenseMapper, License> impl ...@@ -41,4 +37,9 @@ public class LicenseServiceImpl extends ServiceImpl<LicenseMapper, License> impl
return licenseMapper.deleteLicense(appId); return licenseMapper.deleteLicense(appId);
} }
@Override
public boolean addLicense(String appId, String appKey, String userId) {
return licenseMapper.addLicense(appId,appKey,userId);
}
} }
...@@ -24,10 +24,6 @@ public class ServerServiceImpl extends ServiceImpl<ServerMapper, Server> impleme ...@@ -24,10 +24,6 @@ public class ServerServiceImpl extends ServiceImpl<ServerMapper, Server> impleme
@Resource @Resource
ServerMapper serverMapper; ServerMapper serverMapper;
@Override
public boolean addServer(Server server) {
return serverMapper.addServer(server);
}
@Override @Override
public List<Server> getServerList(int pageNo, int pageSize) { public List<Server> getServerList(int pageNo, int pageSize) {
...@@ -41,4 +37,9 @@ public class ServerServiceImpl extends ServiceImpl<ServerMapper, Server> impleme ...@@ -41,4 +37,9 @@ public class ServerServiceImpl extends ServiceImpl<ServerMapper, Server> impleme
public boolean deleteServer(String serverIp) { public boolean deleteServer(String serverIp) {
return serverMapper.deleteServer(serverIp); return serverMapper.deleteServer(serverIp);
} }
@Override
public boolean addServer(String serverIp, int port) {
return baseMapper.addServer(serverIp,port);
}
} }
...@@ -24,10 +24,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us ...@@ -24,10 +24,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
@Resource @Resource
UserMapper userMapper; UserMapper userMapper;
@Override
public boolean addUser(User user) {
return userMapper.addUser(user);
}
@Override @Override
public List<User> getUserList(int pageNo, int pageSize) { public List<User> getUserList(int pageNo, int pageSize) {
...@@ -41,4 +37,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us ...@@ -41,4 +37,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
public boolean deleteUser(String user) { public boolean deleteUser(String user) {
return userMapper.deleteUser(user); return userMapper.deleteUser(user);
} }
@Override
public boolean addUser(String userId, String password) {
return userMapper.addUser(userId,password);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment