package com.jsh.erp.controller;
|
|
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONObject;
|
import com.jsh.erp.datasource.entities.SysDict;
|
import com.jsh.erp.dto.ConfigSecurityCreateOrUpdate;
|
import com.jsh.erp.dto.ConfigSecurityQuery;
|
import com.jsh.erp.datasource.entities.ConfigSecurity;
|
import com.jsh.erp.service.configSecurity.ConfigSecurityService;
|
import com.jsh.erp.utils.BaseResponseInfo;
|
import com.jsh.erp.utils.ErpInfo;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.annotation.Resource;
|
import javax.servlet.http.HttpServletRequest;
|
import javax.validation.Valid;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
import static com.jsh.erp.utils.ResponseJsonUtil.returnJson;
|
|
/**
|
* @author ji sheng hua jshERP
|
*/
|
@RestController
|
@RequestMapping(value = "/config-security")
|
@Api(tags = {"高级安全防护管理"})
|
public class ConfigSecurityController {
|
private Logger logger = LoggerFactory.getLogger(ConfigSecurityController.class);
|
|
@Resource
|
private ConfigSecurityService configSecurityService;
|
|
|
/**
|
* 高级安全防护列表
|
* @param currentPage
|
* @param pageSize
|
* @param type
|
* @param keyword
|
* @param request
|
* @return
|
* @throws Exception
|
*/
|
// @GetMapping(value = "/list")
|
// @ApiOperation(value = "高级安全防护列表")
|
// public BaseResponseInfo findAccountInOutList(@RequestParam("currentPage") Integer currentPage,
|
// @RequestParam("pageSize") Integer pageSize,
|
// @RequestParam(value = "type", required = false) String type ,
|
// @RequestParam(value = "keyword", required = false) String keyword,
|
// HttpServletRequest request) throws Exception{
|
// ConfigSecurityQuery configSecurityQuery = new ConfigSecurityQuery(keyword,type, null, null, null, null);
|
// configSecurityQuery.setCurrentPage(currentPage);
|
// configSecurityQuery.setPageSize(pageSize);
|
// BaseResponseInfo res = new BaseResponseInfo();
|
// Map<String, Object> map = new HashMap<String, Object>();
|
// try {
|
// List<ConfigSecurity> dataList = configSecurityService.findList(configSecurityQuery);
|
// Long total = configSecurityService.findListCount(configSecurityQuery);
|
// map.put("total", total);
|
// map.put("rows", dataList);
|
// res.code = 200;
|
// res.data = map;
|
// } catch(Exception e){
|
// logger.error(e.getMessage(), e);
|
// res.code = 500;
|
// res.data = "获取数据失败";
|
// }
|
// return res;
|
// }
|
|
|
@GetMapping(value = "/list")
|
@ApiOperation(value = "高级安全防护列表")
|
public BaseResponseInfo findAccountInOutList(ConfigSecurityQuery configSecurityQuery,
|
HttpServletRequest request) throws Exception{
|
BaseResponseInfo res = new BaseResponseInfo();
|
Map<String, Object> map = new HashMap<String, Object>();
|
try {
|
List<ConfigSecurity> dataList = configSecurityService.findList(configSecurityQuery);
|
Long total = configSecurityService.findListCount(configSecurityQuery);
|
map.put("total", total);
|
map.put("rows", dataList);
|
res.code = 200;
|
res.data = map;
|
} catch(Exception e){
|
logger.error(e.getMessage(), e);
|
res.code = 500;
|
res.data = "获取数据失败";
|
}
|
return res;
|
}
|
|
|
@PostMapping
|
public BaseResponseInfo add(@RequestBody @Valid ConfigSecurityCreateOrUpdate configSecurityCreateOrUpdate) {
|
ConfigSecurity configSecurity = new ConfigSecurity();
|
BeanUtils.copyProperties(configSecurityCreateOrUpdate, configSecurity);
|
BaseResponseInfo baseResponseInfo = new BaseResponseInfo();
|
try {
|
int result = configSecurityService.add(configSecurity);
|
if(result > 0) {
|
baseResponseInfo.code = 200;
|
baseResponseInfo.msg = "新增成功";
|
}
|
} catch(Exception e) {
|
baseResponseInfo.code = 500;
|
baseResponseInfo.msg = e.getMessage();
|
}
|
return baseResponseInfo;
|
}
|
|
@PutMapping
|
public BaseResponseInfo update(@RequestBody @Valid ConfigSecurityCreateOrUpdate configSecurityCreateOrUpdate) {
|
ConfigSecurity configSecurity = new ConfigSecurity();
|
BaseResponseInfo baseResponseInfo = new BaseResponseInfo();
|
try {
|
int result = configSecurityService.update(configSecurity);
|
if(result > 0) {
|
baseResponseInfo.code = 200;
|
baseResponseInfo.msg = "修改成功";
|
}
|
} catch(Exception e) {
|
baseResponseInfo.code = 500;
|
baseResponseInfo.msg = e.getMessage();
|
}
|
return baseResponseInfo;
|
}
|
|
@DeleteMapping("/delete/{id}")
|
public BaseResponseInfo delete(@PathVariable Long id) {
|
BaseResponseInfo baseResponseInfo = new BaseResponseInfo();
|
try {
|
int result = configSecurityService.deleteById(id);
|
if(result > 0) {
|
baseResponseInfo.code = 200;
|
baseResponseInfo.msg = "删除成功";
|
}
|
} catch(Exception e) {
|
baseResponseInfo.code = 500;
|
baseResponseInfo.msg = e.getMessage();
|
}
|
return baseResponseInfo;
|
}
|
|
@DeleteMapping("/deleteBatch")
|
public BaseResponseInfo deleteBatch(@RequestParam("ids") String ids) {
|
BaseResponseInfo baseResponseInfo = new BaseResponseInfo();
|
|
try {
|
int result= configSecurityService.deleteBatch(ids);
|
if(result > 0) {
|
baseResponseInfo.code = 200;
|
baseResponseInfo.msg = "删除成功";
|
}
|
} catch(Exception e) {
|
baseResponseInfo.code = 500;
|
baseResponseInfo.msg = e.getMessage();
|
}
|
return baseResponseInfo;
|
}
|
|
|
/**
|
* 批量设置状态-启用或者禁用
|
* @param jsonObject
|
* @param request
|
* @return
|
*/
|
@PostMapping(value = "/batchSetStatus")
|
@ApiOperation(value = "批量设置状态")
|
public String batchSetStatus(@RequestBody JSONObject jsonObject,
|
HttpServletRequest request)throws Exception {
|
Integer status = jsonObject.getInteger("status");
|
String ids = jsonObject.getString("ids");
|
Map<String, Object> objectMap = new HashMap<>();
|
int res = configSecurityService.batchSetStatus(status, ids);
|
if(res > 0) {
|
return returnJson(objectMap, ErpInfo.OK.name, ErpInfo.OK.code);
|
} else {
|
return returnJson(objectMap, ErpInfo.ERROR.name, ErpInfo.ERROR.code);
|
}
|
}
|
}
|