Commit fc99621e authored by AfirSraftGarrier's avatar AfirSraftGarrier

修改

parent a8e382c2
...@@ -28,6 +28,7 @@ import iot.sixiang.license.service.ServerService; ...@@ -28,6 +28,7 @@ import iot.sixiang.license.service.ServerService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.owasp.esapi.ESAPI; import org.owasp.esapi.ESAPI;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -56,6 +57,11 @@ public class OperateController { ...@@ -56,6 +57,11 @@ public class OperateController {
@Autowired @Autowired
HttpServletResponse response; HttpServletResponse response;
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.setDisallowedFields(new String[]{"adminCome"});
}
@ApiOperation(value = "服务接口", notes = "用于获取服务列表") @ApiOperation(value = "服务接口", notes = "用于获取服务列表")
@GetMapping("monitor/server") @GetMapping("monitor/server")
@MyLog(title = "获取服务列表", businessType = BusinessType.SELECT) @MyLog(title = "获取服务列表", businessType = BusinessType.SELECT)
...@@ -95,7 +101,7 @@ public class OperateController { ...@@ -95,7 +101,7 @@ public class OperateController {
@GetMapping("alarm/list") @GetMapping("alarm/list")
@MyLog(title = "获取告警列表", businessType = BusinessType.SELECT) @MyLog(title = "获取告警列表", businessType = BusinessType.SELECT)
public ResResult<List<AlarmVo>> getAlarmList() { public ResResult<List<AlarmVo>> getAlarmList() {
response.setHeader("Set-Cookie","cookiename=cookievalue; path=/; Domain=domainvaule; Max-age=seconds; HttpOnly"); response.setHeader("Set-Cookie", "cookiename=cookievalue; path=/; Domain=domainvaule; Max-age=seconds; HttpOnly");
String user = UserUtils.getLoginUserId(); String user = UserUtils.getLoginUserId();
int userI = Integer.valueOf(user); int userI = Integer.valueOf(user);
List<AlarmVo> alarmList = alarmService.getAlarmList(userI); List<AlarmVo> alarmList = alarmService.getAlarmList(userI);
......
...@@ -18,13 +18,14 @@ import iot.sixiang.license.model.vo.UserVo; ...@@ -18,13 +18,14 @@ import iot.sixiang.license.model.vo.UserVo;
import iot.sixiang.license.service.UserService; import iot.sixiang.license.service.UserService;
import iot.sixiang.license.util.CommonUtil; import iot.sixiang.license.util.CommonUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
/** /**
* <p> * <p>
* 前端控制器 * 前端控制器
* </p> * </p>
* *
* @author m33 * @author m33
...@@ -38,17 +39,23 @@ public class UserController { ...@@ -38,17 +39,23 @@ public class UserController {
@Autowired @Autowired
private UserService userService; private UserService userService;
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.setDisallowedFields(new String[]{"adminCome"});
}
/** /**
* 添加user * 添加user
*
* @param jsonObject * @param jsonObject
* @return * @return
*/ */
@ApiOperation(value = "用户添加接口", notes = "用于添加用户") @ApiOperation(value = "用户添加接口", notes = "用于添加用户")
@PostMapping("add") @PostMapping("add")
@MyLog(title = "添加用户", optParam = "#{jsonObject}", businessType = BusinessType.INSERT) @MyLog(title = "添加用户", optParam = "#{jsonObject}", businessType = BusinessType.INSERT)
@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject",properties = { @ApiOperationSupport(params = @DynamicParameters(name = "jsonObject", properties = {
@DynamicParameter(name = "userName",value = "账户名",required = true,dataTypeClass = String.class), @DynamicParameter(name = "userName", value = "账户名", required = true, dataTypeClass = String.class),
@DynamicParameter(name = "company",value = "公司名",required = true,dataTypeClass = String.class) @DynamicParameter(name = "company", value = "公司名", required = true, dataTypeClass = String.class)
})) }))
public BaseResult addUser(@RequestBody JSONObject jsonObject) { public BaseResult addUser(@RequestBody JSONObject jsonObject) {
String userName = (String) jsonObject.get("userName"); String userName = (String) jsonObject.get("userName");
...@@ -64,6 +71,7 @@ public class UserController { ...@@ -64,6 +71,7 @@ public class UserController {
/** /**
* 删除user * 删除user
*
* @param userId * @param userId
* @return * @return
*/ */
...@@ -81,15 +89,16 @@ public class UserController { ...@@ -81,15 +89,16 @@ public class UserController {
/** /**
* 修改user * 修改user
*
* @param jsonObject * @param jsonObject
* @return * @return
*/ */
@ApiOperation(value = "用户修改接口", notes = "修改用户") @ApiOperation(value = "用户修改接口", notes = "修改用户")
@PostMapping("update") @PostMapping("update")
@MyLog(title = "修改用户", optParam = "#{userId},#{password}", businessType = BusinessType.UPDATE) @MyLog(title = "修改用户", optParam = "#{userId},#{password}", businessType = BusinessType.UPDATE)
@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject",properties = { @ApiOperationSupport(params = @DynamicParameters(name = "jsonObject", properties = {
@DynamicParameter(name = "userId",value = "用户Id",required = true,dataTypeClass = Integer.class), @DynamicParameter(name = "userId", value = "用户Id", required = true, dataTypeClass = Integer.class),
@DynamicParameter(name = "password",value = "密码",required = true,dataTypeClass = String.class) @DynamicParameter(name = "password", value = "密码", required = true, dataTypeClass = String.class)
})) }))
public BaseResult updateUser(@RequestBody JSONObject jsonObject) { public BaseResult updateUser(@RequestBody JSONObject jsonObject) {
int userId = jsonObject.getInteger("userId"); int userId = jsonObject.getInteger("userId");
...@@ -105,6 +114,7 @@ public class UserController { ...@@ -105,6 +114,7 @@ public class UserController {
/** /**
* 分页查询所有的user * 分页查询所有的user
*
* @param pageNo * @param pageNo
* @param pageSize * @param pageSize
* @return * @return
...@@ -113,24 +123,24 @@ public class UserController { ...@@ -113,24 +123,24 @@ public class UserController {
@GetMapping("list") @GetMapping("list")
@MyLog(title = "获取用户列表", optParam = "#{pageNo},#{pageSize},#{userName},#{company}", businessType = BusinessType.SELECT) @MyLog(title = "获取用户列表", optParam = "#{pageNo},#{pageSize},#{userName},#{company}", businessType = BusinessType.SELECT)
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "pageNo",value = "当前在第几页", required = true,dataType = "int"), @ApiImplicitParam(name = "pageNo", value = "当前在第几页", required = true, dataType = "int"),
@ApiImplicitParam(name = "pageSize",value = "每页显示多少条", required = true, dataType = "int"), @ApiImplicitParam(name = "pageSize", value = "每页显示多少条", required = true, dataType = "int"),
@ApiImplicitParam(name = "userName",value = "用户名"), @ApiImplicitParam(name = "userName", value = "用户名"),
@ApiImplicitParam(name = "company",value = "公司名") @ApiImplicitParam(name = "company", value = "公司名")
}) })
public PageResult<UserVo> getUserList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo, public PageResult<UserVo> getUserList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo,
@RequestParam(value = "pageSize",defaultValue = "0") int pageSize, @RequestParam(value = "pageSize", defaultValue = "0") int pageSize,
@RequestParam(value = "userName",required = false) String userName, @RequestParam(value = "userName", required = false) String userName,
@RequestParam(value = "company",required = false) String company) { @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为总页数
int mod = total%pageSize; int mod = total % pageSize;
if(mod!=0){ if (mod != 0) {
pages = pages + 1; pages = pages + 1;
} }
List<UserVo> result = records.getResult(); List<UserVo> result = records.getResult();
return new PageResult(200,"查找成功",pageNo,pages,total,result); return new PageResult(200, "查找成功", pageNo, pages, total, result);
} }
} }
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