Browse Source

增加qad访问控制功能

master
liuchen864 9 months ago
parent
commit
0e2c24d6b1
  1. 1
      win-admin/src/main/java/com/win/web/controller/base/CommandController.java
  2. 141
      win-admin/src/main/java/com/win/web/controller/base/QadAccessController.java
  3. 1
      win-admin/src/main/java/com/win/web/controller/base/ShellController.java
  4. 3
      win-framework/src/main/java/com/win/framework/config/SecurityConfig.java
  5. 45
      win-system/src/main/java/com/win/system/domain/QadAccess.java
  6. 16
      win-system/src/main/java/com/win/system/mapper/QadAccessMapper.java
  7. 12
      win-system/src/main/java/com/win/system/service/LinuxAccessService.java
  8. 41
      win-system/src/main/java/com/win/system/service/QadAccessService.java
  9. 29
      win-system/src/main/resources/mapper/system/QadAccessMapper.xml

1
win-admin/src/main/java/com/win/web/controller/base/CommandController.java

@ -42,7 +42,6 @@ public class CommandController {
* @return 结果
*/
@PostMapping("/api")
@SuppressWarnings("unchecked")
public AjaxResult api(HttpServletRequest request, @RequestBody String body) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
String interfaceName = request.getHeader("interface");
String sign = request.getHeader("sign");

141
win-admin/src/main/java/com/win/web/controller/base/QadAccessController.java

@ -0,0 +1,141 @@
package com.win.web.controller.base;
import java.time.LocalDateTime;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.win.common.annotation.Log;
import com.win.common.core.controller.BaseController;
import com.win.common.core.domain.AjaxResult;
import com.win.common.core.page.TableDataInfo;
import com.win.common.enums.BusinessType;
import com.win.common.utils.bean.BeanValidators;
import com.win.common.utils.poi.ExcelUtil;
import com.win.system.domain.QadAccess;
import com.win.system.service.QadAccessService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.Validator;
/**
* qad访问控制Controller
*
* @author win
* @date 2024-03-13
*/
@RestController
@RequestMapping("/base/qadAccess")
public class QadAccessController extends BaseController {
@Autowired
protected Validator validator;
@Autowired
private QadAccessService qadAccessService;
/**
* 查询qad访问控制列表
*/
@ApiOperation("查询qad访问控制列表")
@GetMapping("/list")
public TableDataInfo list(QadAccess qadAccess) {
startPage();
QueryWrapper<QadAccess> queryWrapper = new QueryWrapper<>();
queryWrapper.isNull("delete_time");
if(qadAccess.getCompanyCode() != null && !qadAccess.getCompanyCode().isEmpty()) {
queryWrapper.eq("company_code", qadAccess.getCompanyCode());
}
if(qadAccess.getCompanyName() != null && !qadAccess.getCompanyName().isEmpty()) {
queryWrapper.like("company_name", qadAccess.getCompanyName());
}
List<QadAccess> list = qadAccessService.list(queryWrapper);
return getDataTable(list);
}
/**
* 导出qad访问控制列表
*/
@ApiOperation("导出qad访问控制列表")
@PostMapping("/export")
public void export(HttpServletResponse response, QadAccess qadAccess) {
QueryWrapper<QadAccess> queryWrapper = new QueryWrapper<>();
queryWrapper.isNull("delete_time");
if(qadAccess.getCompanyCode() != null && !qadAccess.getCompanyCode().isEmpty()) {
queryWrapper.eq("company_code", qadAccess.getCompanyCode());
}
if(qadAccess.getCompanyName() != null && !qadAccess.getCompanyName().isEmpty()) {
queryWrapper.like("company_name", qadAccess.getCompanyName());
}
List<QadAccess> list = qadAccessService.list(queryWrapper);
ExcelUtil<QadAccess> util = new ExcelUtil<>(QadAccess.class);
util.exportExcel(response, list, "qad访问控制数据");
}
/**
* 导入qad访问控制
*/
@ApiOperation("导入qad访问控制模板")
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response) {
ExcelUtil<QadAccess> util = new ExcelUtil<>(QadAccess.class);
util.importTemplateExcel(response, "qad访问控制数据");
}
/**
* 获取qad访问控制详细信息
*/
@ApiOperation("获取qad访问控制详细信息")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return AjaxResult.success(qadAccessService.getById(id));
}
/**
* 新增qad访问控制
*/
@ApiOperation("新增qad访问控制")
@Log(title = "qad访问控制", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Valid @RequestBody QadAccess qadAccess) {
BeanValidators.validateWithException(validator, qadAccess);
qadAccess.setDeptId(getDeptId());
qadAccess.setUserId(getUserId());
qadAccess.setCreateBy(getUserId());
qadAccess.setCreateTime(LocalDateTime.now());
return toAjax(qadAccessService.save(qadAccess));
}
/**
* 修改qad访问控制
*/
@ApiOperation("修改qad访问控制")
@Log(title = "qad访问控制", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Valid @RequestBody QadAccess qadAccess) {
BeanValidators.validateWithException(validator, qadAccess);
qadAccess.setUpdateBy(getUserId());
qadAccess.setUpdateTime(LocalDateTime.now());
return toAjax(qadAccessService.updateById(qadAccess));
}
/**
* 批量删除qad访问控制
*/
@ApiOperation("批量删除qad访问控制")
@Log(title = "qad访问控制", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult batchRemove(@PathVariable Long[] ids) {
return toAjax(qadAccessService.deleteQadAccessByIds(ids, getUserId()));
}
}

1
win-admin/src/main/java/com/win/web/controller/base/ShellController.java

@ -46,7 +46,6 @@ public class ShellController {
* @return 结果
*/
@PostMapping("/api")
@SuppressWarnings("unchecked")
public AjaxResult api(HttpServletRequest request, @RequestBody String body) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
String interfaceName = request.getHeader("interface");
String sign = request.getHeader("sign");

3
win-framework/src/main/java/com/win/framework/config/SecurityConfig.java

@ -111,7 +111,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers("/login", "/register", "/captchaImage").permitAll()
// 静态资源,可匿名访问
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs").permitAll()
//.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs").permitAll()
.antMatchers("/command/**", "/shell/**").permitAll()
// 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated()
.and()

45
win-system/src/main/java/com/win/system/domain/QadAccess.java

@ -0,0 +1,45 @@
package com.win.system.domain;
import com.win.common.annotation.Excel;
import com.win.common.core.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
* qad访问控制对象 qad_access
*
* @author win
* @date 2024-03-13
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class QadAccess extends BaseEntity<QadAccess> {
private static final long serialVersionUID = 1L;
/** 公司编码 */
@Excel(name = "公司编码")
private String companyCode;
/** 公司名称 */
@Excel(name = "公司名称")
private String companyName;
/** 用户 */
@Excel(name = "用户")
private String userName;
/** 密码 */
@Excel(name = "密码")
private String password;
/** 域 */
@Excel(name = "域")
private String domain;
}

16
win-system/src/main/java/com/win/system/mapper/QadAccessMapper.java

@ -0,0 +1,16 @@
package com.win.system.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.win.system.domain.QadAccess;
/**
* qad访问控制Mapper接口
*
* @author win
* @date 2024-03-13
*/
@InterceptorIgnore(tenantLine = "true")
public interface QadAccessMapper extends BaseMapper<QadAccess> {
}

12
win-system/src/main/java/com/win/system/service/LinuxAccessService.java

@ -1,13 +1,22 @@
package com.win.system.service;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import com.win.common.constant.HttpStatus;
import com.win.common.core.domain.AjaxResult;
import com.win.common.utils.shell.ShellUtil;
import com.win.common.utils.shell.ShellVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.win.system.mapper.LinuxAccessMapper;
import com.win.system.domain.LinuxAccess;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.time.LocalDateTime;
/**
@ -20,6 +29,9 @@ import java.time.LocalDateTime;
@Service
public class LinuxAccessService extends ServiceImpl<LinuxAccessMapper, LinuxAccess> implements IService<LinuxAccess> {
@Autowired
private ShellUtil shellUtil;
/**
* 批量删除请填写功能名称
*

41
win-system/src/main/java/com/win/system/service/QadAccessService.java

@ -0,0 +1,41 @@
package com.win.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import com.win.system.mapper.QadAccessMapper;
import com.win.system.domain.QadAccess;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
/**
* qad访问控制Service业务层处理
*
* @author win
* @date 2024-03-13
*/
@Slf4j
@Service
public class QadAccessService extends ServiceImpl<QadAccessMapper, QadAccess> implements IService<QadAccess> {
/**
* 批量删除qad访问控制
*
* @param ids 需要删除的qad访问控制主键
* @return 删除的数量
*/
@Transactional
public int deleteQadAccessByIds(Long[] ids, Long userId) {
int result = 0;
for(Long id : ids) {
QadAccess qadAccess = baseMapper.selectById(id);
qadAccess.setDeleteBy(userId);
qadAccess.setDeleteTime(LocalDateTime.now());
result += baseMapper.updateById(qadAccess);
}
return result;
}
}

29
win-system/src/main/resources/mapper/system/QadAccessMapper.xml

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.win.system.mapper.QadAccessMapper">
<resultMap type="QadAccess" id="QadAccessResult">
<result property="id" column="id" />
<result property="companyCode" column="company_code" />
<result property="companyName" column="company_name" />
<result property="userName" column="user_name" />
<result property="password" column="password" />
<result property="domain" column="domain" />
<result property="deptId" column="dept_id" />
<result property="userId" column="user_id" />
<result property="version" column="version" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="deleteBy" column="delete_by" />
<result property="deleteTime" column="delete_time" />
</resultMap>
<sql id="selectQadAccessVo">
select id, company_code, company_name, user_name, password, domain, dept_id, user_id, version, create_by, create_time, update_by, update_time, delete_by, delete_time from qad_access
</sql>
</mapper>
Loading…
Cancel
Save