diff --git a/win-admin/src/main/java/com/win/web/controller/base/CommandController.java b/win-admin/src/main/java/com/win/web/controller/base/CommandController.java index b544dc2..ab68f27 100644 --- a/win-admin/src/main/java/com/win/web/controller/base/CommandController.java +++ b/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"); diff --git a/win-admin/src/main/java/com/win/web/controller/base/QadAccessController.java b/win-admin/src/main/java/com/win/web/controller/base/QadAccessController.java new file mode 100644 index 0000000..eafd005 --- /dev/null +++ b/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 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 list = qadAccessService.list(queryWrapper); + return getDataTable(list); + } + + /** + * 导出qad访问控制列表 + */ + @ApiOperation("导出qad访问控制列表") + @PostMapping("/export") + public void export(HttpServletResponse response, QadAccess qadAccess) { + QueryWrapper 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 list = qadAccessService.list(queryWrapper); + ExcelUtil util = new ExcelUtil<>(QadAccess.class); + util.exportExcel(response, list, "qad访问控制数据"); + } + + /** + * 导入qad访问控制 + */ + @ApiOperation("导入qad访问控制模板") + @PostMapping("/importTemplate") + public void importTemplate(HttpServletResponse response) { + ExcelUtil 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())); + } + +} diff --git a/win-admin/src/main/java/com/win/web/controller/base/ShellController.java b/win-admin/src/main/java/com/win/web/controller/base/ShellController.java index d1e761c..1086ca2 100644 --- a/win-admin/src/main/java/com/win/web/controller/base/ShellController.java +++ b/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"); diff --git a/win-framework/src/main/java/com/win/framework/config/SecurityConfig.java b/win-framework/src/main/java/com/win/framework/config/SecurityConfig.java index 6a882a2..903bafa 100644 --- a/win-framework/src/main/java/com/win/framework/config/SecurityConfig.java +++ b/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() diff --git a/win-system/src/main/java/com/win/system/domain/QadAccess.java b/win-system/src/main/java/com/win/system/domain/QadAccess.java new file mode 100644 index 0000000..95e1a5b --- /dev/null +++ b/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 { + + 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; + +} diff --git a/win-system/src/main/java/com/win/system/mapper/QadAccessMapper.java b/win-system/src/main/java/com/win/system/mapper/QadAccessMapper.java new file mode 100644 index 0000000..e499418 --- /dev/null +++ b/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 { + +} diff --git a/win-system/src/main/java/com/win/system/service/LinuxAccessService.java b/win-system/src/main/java/com/win/system/service/LinuxAccessService.java index 33c4211..63e2725 100644 --- a/win-system/src/main/java/com/win/system/service/LinuxAccessService.java +++ b/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 implements IService { + @Autowired + private ShellUtil shellUtil; + /** * 批量删除【请填写功能名称】 * diff --git a/win-system/src/main/java/com/win/system/service/QadAccessService.java b/win-system/src/main/java/com/win/system/service/QadAccessService.java new file mode 100644 index 0000000..63558c5 --- /dev/null +++ b/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 implements IService { + + /** + * 批量删除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; + } + +} \ No newline at end of file diff --git a/win-system/src/main/resources/mapper/system/QadAccessMapper.xml b/win-system/src/main/resources/mapper/system/QadAccessMapper.xml new file mode 100644 index 0000000..01d9fc8 --- /dev/null +++ b/win-system/src/main/resources/mapper/system/QadAccessMapper.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + \ No newline at end of file