liuchen864
9 months ago
9 changed files with 286 additions and 3 deletions
@ -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())); |
||||
|
} |
||||
|
|
||||
|
} |
@ -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; |
||||
|
|
||||
|
} |
@ -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> { |
||||
|
|
||||
|
} |
@ -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; |
||||
|
} |
||||
|
|
||||
|
} |
@ -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…
Reference in new issue