Commit 8e9e0707 authored by zengtianlai3's avatar zengtianlai3

Merge branch 'm33' into 'master'

修改格式

See merge request !7
parents 673dae1d bef33545
...@@ -34,8 +34,8 @@ public class DeviceController { ...@@ -34,8 +34,8 @@ public class DeviceController {
*/ */
@PostMapping("add") @PostMapping("add")
public BaseResult addDevice(@RequestBody JSONObject jsonObject) { public BaseResult addDevice(@RequestBody JSONObject jsonObject) {
int userId = jsonObject.getInteger("user_id"); int userId = jsonObject.getInteger("userId");
int typeId = jsonObject.getInteger("type_id"); int typeId = jsonObject.getInteger("typeId");
int count = jsonObject.getInteger("count"); int count = jsonObject.getInteger("count");
boolean res = deviceService.addDevice(userId, typeId,count); boolean res = deviceService.addDevice(userId, typeId,count);
if (res) { if (res) {
...@@ -54,10 +54,10 @@ public class DeviceController { ...@@ -54,10 +54,10 @@ public class DeviceController {
* @return * @return
*/ */
@GetMapping("list") @GetMapping("list")
public PageResult getDeviceList(@RequestParam("page_no") int pageNo, public PageResult getDeviceList(@RequestParam("pageNo") int pageNo,
@RequestParam("page_size") int pageSize, @RequestParam("pageSize") int pageSize,
@RequestParam(value = "type_name",required = false) String typeName, @RequestParam(value = "typeName",required = false) String typeName,
@RequestParam(value = "user_id",required = false) Integer userId) { @RequestParam(value = "userId",required = false) Integer userId) {
PageInfoModel<DeviceTypeVo> records = deviceService.getDeviceList(pageNo,pageSize,typeName,userId); PageInfoModel<DeviceTypeVo> records = deviceService.getDeviceList(pageNo,pageSize,typeName,userId);
int total = records.getTotal(); int total = records.getTotal();
int pages = total/pageSize;//pages为总页数 int pages = total/pageSize;//pages为总页数
......
...@@ -2,7 +2,7 @@ package iot.sixiang.license.controller; ...@@ -2,7 +2,7 @@ package iot.sixiang.license.controller;
import iot.sixiang.license.entity.DeviceType; import iot.sixiang.license.entity.DeviceType;
import iot.sixiang.license.model.RespResult; import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.service.DeviceTypeService; import iot.sixiang.license.service.DeviceTypeService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -32,9 +32,9 @@ public class DeviceTypeController { ...@@ -32,9 +32,9 @@ public class DeviceTypeController {
* @return * @return
*/ */
@GetMapping("type") @GetMapping("type")
public RespResult getDeviceTypeList() { public ResResult getDeviceTypeList() {
List<DeviceType> records = deviceTypeService.getDeviceTypeList(); List<DeviceType> records = deviceTypeService.getDeviceTypeList();
return RespResult.success().record(records); return ResResult.success().record(records);
} }
} }
...@@ -4,7 +4,7 @@ package iot.sixiang.license.controller; ...@@ -4,7 +4,7 @@ package iot.sixiang.license.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import iot.sixiang.license.entity.License; import iot.sixiang.license.entity.License;
import iot.sixiang.license.model.BaseResult; import iot.sixiang.license.model.BaseResult;
import iot.sixiang.license.model.RespResult; import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.service.LicenseService; import iot.sixiang.license.service.LicenseService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -33,9 +33,9 @@ public class LicenseController { ...@@ -33,9 +33,9 @@ public class LicenseController {
*/ */
@PostMapping("add") @PostMapping("add")
public BaseResult addLicense(@RequestBody JSONObject jsonObject){ public BaseResult addLicense(@RequestBody JSONObject jsonObject){
String appId = jsonObject.getString("app_id"); String appId = jsonObject.getString("appId");
String appKey = jsonObject.getString("app_key"); String appKey = jsonObject.getString("appKey");
String userId = jsonObject.getString("user_id"); String userId = jsonObject.getString("userId");
boolean res = licenseService.addLicense(appId,appKey,userId); boolean res = licenseService.addLicense(appId,appKey,userId);
if (res) { if (res) {
return BaseResult.success(); return BaseResult.success();
...@@ -50,7 +50,7 @@ public class LicenseController { ...@@ -50,7 +50,7 @@ public class LicenseController {
* @return * @return
*/ */
@PostMapping("delete") @PostMapping("delete")
public BaseResult deleteLicense(@RequestParam("app_id") String appId) { public BaseResult deleteLicense(@RequestParam("appId") String appId) {
boolean res = licenseService.deleteLicense(appId); boolean res = licenseService.deleteLicense(appId);
if (res) { if (res) {
return BaseResult.success(); return BaseResult.success();
...@@ -66,9 +66,9 @@ public class LicenseController { ...@@ -66,9 +66,9 @@ public class LicenseController {
*/ */
@PostMapping("update") @PostMapping("update")
public BaseResult updateLicense(@RequestBody JSONObject jsonObject){ public BaseResult updateLicense(@RequestBody JSONObject jsonObject){
String appId = jsonObject.getString("app_id"); String appId = jsonObject.getString("appId");
String appKey = jsonObject.getString("app_key"); String appKey = jsonObject.getString("appKey");
String userId = jsonObject.getString("user_id"); String userId = jsonObject.getString("userId");
boolean res = licenseService.updateLicense(appId,appKey,userId); boolean res = licenseService.updateLicense(appId,appKey,userId);
if (res) { if (res) {
return BaseResult.success(); return BaseResult.success();
...@@ -84,9 +84,9 @@ public class LicenseController { ...@@ -84,9 +84,9 @@ public class LicenseController {
* @return * @return
*/ */
@GetMapping("list") @GetMapping("list")
public RespResult getLicenseList(@RequestParam("page_no") int pageNo, @RequestParam("page_size") int pageSize) { public ResResult getLicenseList(@RequestParam("pageNo") int pageNo, @RequestParam("pageSize") int pageSize) {
List<License> records = licenseService.getLicenseList(pageNo,pageSize); List<License> records = licenseService.getLicenseList(pageNo,pageSize);
return RespResult.success().record(records); return ResResult.success().record(records);
} }
......
...@@ -33,7 +33,7 @@ public class LoginController { ...@@ -33,7 +33,7 @@ public class LoginController {
*/ */
@GetMapping("login") @GetMapping("login")
public ResResult login(@RequestParam("user_name") String userName, @RequestParam("password") String password) { public ResResult login(@RequestParam("userName") String userName, @RequestParam("password") String password) {
// @RequestBody JSONObject jsonObject // @RequestBody JSONObject jsonObject
LoginUser user = new LoginUser(); LoginUser user = new LoginUser();
user.setUser_name(userName); user.setUser_name(userName);
...@@ -53,7 +53,7 @@ public class LoginController { ...@@ -53,7 +53,7 @@ public class LoginController {
} }
@GetMapping("logout") @GetMapping("logout")
public ResResult logout(@RequestParam("user_name") String userName, @RequestParam("password") String password) { public ResResult logout(@RequestParam("userName") String userName, @RequestParam("password") String password) {
// @RequestBody JSONObject jsonObject // @RequestBody JSONObject jsonObject
LoginUser user = new LoginUser(); LoginUser user = new LoginUser();
user.setUser_name(userName); user.setUser_name(userName);
......
...@@ -4,7 +4,7 @@ package iot.sixiang.license.controller; ...@@ -4,7 +4,7 @@ package iot.sixiang.license.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import iot.sixiang.license.entity.Server; import iot.sixiang.license.entity.Server;
import iot.sixiang.license.model.BaseResult; import iot.sixiang.license.model.BaseResult;
import iot.sixiang.license.model.RespResult; import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.service.ServerService; import iot.sixiang.license.service.ServerService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -33,7 +33,7 @@ public class ServerController { ...@@ -33,7 +33,7 @@ public class ServerController {
*/ */
@PostMapping("add") @PostMapping("add")
public BaseResult addServer(@RequestBody JSONObject jsonObject) { public BaseResult addServer(@RequestBody JSONObject jsonObject) {
String serverIp = jsonObject.getString("server_ip"); String serverIp = jsonObject.getString("serverIp");
int port = jsonObject.getInteger("port"); int port = jsonObject.getInteger("port");
boolean res = serverService.addServer(serverIp,port); boolean res = serverService.addServer(serverIp,port);
if (res) { if (res) {
...@@ -49,7 +49,7 @@ public class ServerController { ...@@ -49,7 +49,7 @@ public class ServerController {
* @return * @return
*/ */
@PostMapping("delete") @PostMapping("delete")
public BaseResult deleteServer(@RequestParam("server_ip") String serverIp) { public BaseResult deleteServer(@RequestParam("serverIp") String serverIp) {
boolean res = serverService.deleteServer(serverIp); boolean res = serverService.deleteServer(serverIp);
if (res) { if (res) {
return BaseResult.success(); return BaseResult.success();
...@@ -65,7 +65,7 @@ public class ServerController { ...@@ -65,7 +65,7 @@ public class ServerController {
*/ */
@PostMapping("update") @PostMapping("update")
public BaseResult updateServer(@RequestBody JSONObject jsonObject) { public BaseResult updateServer(@RequestBody JSONObject jsonObject) {
String serverIp = jsonObject.getString("server_ip"); String serverIp = jsonObject.getString("serverIp");
int port = jsonObject.getInteger("port"); int port = jsonObject.getInteger("port");
boolean res = serverService.updateServer(serverIp,port); boolean res = serverService.updateServer(serverIp,port);
if (res) { if (res) {
...@@ -83,9 +83,9 @@ public class ServerController { ...@@ -83,9 +83,9 @@ public class ServerController {
* @return * @return
*/ */
@GetMapping("list") @GetMapping("list")
public RespResult getServerList(@RequestParam("page_no") int pageNo, @RequestParam("page_size") int pageSize) { public ResResult getServerList(@RequestParam("pageNo") int pageNo, @RequestParam("pageSize") int pageSize) {
List<Server> records = serverService.getServerList(pageNo,pageSize); List<Server> records = serverService.getServerList(pageNo,pageSize);
return RespResult.success().record(records); return ResResult.success().record(records);
} }
} }
...@@ -35,7 +35,7 @@ public class UserController { ...@@ -35,7 +35,7 @@ public class UserController {
*/ */
@PostMapping("add") @PostMapping("add")
public BaseResult addUser(@RequestBody JSONObject jsonObject) { public BaseResult addUser(@RequestBody JSONObject jsonObject) {
String userName = (String) jsonObject.get("user_name"); String userName = (String) jsonObject.get("userName");
String company = (String) jsonObject.get("company"); String company = (String) jsonObject.get("company");
String password = CommonUtil.genRandomNum(18); String password = CommonUtil.genRandomNum(18);
boolean res = userService.addUser(userName, company, password); boolean res = userService.addUser(userName, company, password);
...@@ -52,7 +52,7 @@ public class UserController { ...@@ -52,7 +52,7 @@ public class UserController {
* @return * @return
*/ */
@PostMapping("delete") @PostMapping("delete")
public BaseResult deleteUser(@RequestParam("user_id") int userId) { public BaseResult deleteUser(@RequestParam("userId") int userId) {
boolean res = userService.deleteUser(userId); boolean res = userService.deleteUser(userId);
if (res) { if (res) {
return BaseResult.success(); return BaseResult.success();
...@@ -68,7 +68,7 @@ public class UserController { ...@@ -68,7 +68,7 @@ public class UserController {
*/ */
@PostMapping("update") @PostMapping("update")
public BaseResult updateUser(@RequestBody JSONObject jsonObject) { public BaseResult updateUser(@RequestBody JSONObject jsonObject) {
int userId = jsonObject.getInteger("user_id"); int userId = jsonObject.getInteger("userId");
String password = jsonObject.getString("password"); String password = jsonObject.getString("password");
boolean res = userService.updateUser(userId, password); boolean res = userService.updateUser(userId, password);
if (res) { if (res) {
...@@ -86,8 +86,8 @@ public class UserController { ...@@ -86,8 +86,8 @@ public class UserController {
* @return * @return
*/ */
@GetMapping("list") @GetMapping("list")
public PageResult getUserList(@RequestParam("page_no") int pageNo, @RequestParam("page_size") int pageSize, public PageResult getUserList(@RequestParam("pageNo") int pageNo, @RequestParam("pageSize") int pageSize,
@RequestParam(value = "user_name",required = false) String userName, @RequestParam(value = "company",required = false) String company) { @RequestParam(value = "userName",required = false) String userName, @RequestParam(value = "company",required = false) String company) {
PageInfoModel<UserVo> records = userService.getUserList(pageNo,pageSize,userName,company); PageInfoModel<UserVo> records = userService.getUserList(pageNo,pageSize,userName,company);
int total = records.getTotal(); int total = records.getTotal();
int pages = total/pageSize;//pages为总页数 int pages = total/pageSize;//pages为总页数
......
...@@ -7,14 +7,13 @@ import iot.sixiang.license.model.ResResult; ...@@ -7,14 +7,13 @@ import iot.sixiang.license.model.ResResult;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import javax.servlet.*; import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.Map; import java.util.Map;
@Slf4j @Slf4j
@WebFilter(filterName = "jwtFilter", urlPatterns = "/iot_license/*") //@WebFilter(filterName = "jwtFilter", urlPatterns = "/iot_license/*")
public class JwtFilter implements Filter { public class JwtFilter implements Filter {
......
package iot.sixiang.license.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class RespResult {
private int code;
private String msg;
private Object data;
public static RespResult success() {
RespResult respResult = new RespResult();
respResult.setCode(200);
respResult.setMsg("success");
return respResult;
}
public static RespResult fail() {
RespResult respResult = new RespResult();
respResult.setCode(400);
respResult.setMsg("fail");
return respResult;
}
public RespResult msg(String message) {
this.msg = message;
return this;
}
public RespResult record(Object data){
this.data = data;
return this;
}
}
package iot.sixiang.license.model.vo; package iot.sixiang.license.model.vo;
import iot.sixiang.license.entity.User; import iot.sixiang.license.entity.User;
import lombok.Data;
/** /**
* Created by m33 on 2022/6/8 17:26 * Created by m33 on 2022/6/8 17:26
*/ */
@Data
public class UserVo extends User { public class UserVo extends User {
public int count; public int count;
} }
...@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import iot.sixiang.license.entity.User; import iot.sixiang.license.entity.User;
import iot.sixiang.license.mapper.UserMapper; import iot.sixiang.license.mapper.UserMapper;
import iot.sixiang.license.model.PageInfoModel; import iot.sixiang.license.model.PageInfoModel;
import iot.sixiang.license.model.vo.DeviceTypeVo;
import iot.sixiang.license.model.vo.UserVo; import iot.sixiang.license.model.vo.UserVo;
import iot.sixiang.license.service.UserService; import iot.sixiang.license.service.UserService;
import iot.sixiang.license.util.JsonUtil; import iot.sixiang.license.util.JsonUtil;
......
package iot.sixiang.license.util;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
@Configuration
class MyCorsConfig {
// 跨域请求处理
@Bean
public CorsFilter corsFilter() {
CorsConfiguration config = new CorsConfiguration();
//允许所有域名进行跨域调用
config.addAllowedOrigin("*");
//允许所有请求头
config.addAllowedHeader("*");
//允许所有方法
config.addAllowedMethod("*");
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", config);
return new CorsFilter(source);
}
}
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