Merge remote-tracking branch '惠信/develop' into develop
# Conflicts: # nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/mapper/TBaseDepartmentMapper.java # nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/ITBaseDepartmentService.java # nflg-mobilebroken-repository/src/main/java/com/nflg/mobilebroken/repository/service/impl/TBaseDepartmentServiceImpl.java # nflg-mobilebroken-repository/src/main/resources/mapper/TBaseDepartmentMapper.xml
This commit is contained in:
commit
e0e4150e23
|
|
@ -71,6 +71,10 @@
|
||||||
<groupId>jakarta.validation</groupId>
|
<groupId>jakarta.validation</groupId>
|
||||||
<artifactId>jakarta.validation-api</artifactId>
|
<artifactId>jakarta.validation-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.nflg</groupId>
|
||||||
|
<artifactId>nflg-mobilebroken-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
package com.nflg.mobilebroken.admin.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.nflg.mobilebroken.admin.pojo.dto.DepartmentDTO;
|
||||||
|
import com.nflg.mobilebroken.admin.pojo.query.DepartmentQuery;
|
||||||
|
import com.nflg.mobilebroken.admin.pojo.query.DeviceComponentQuery;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.PageData;
|
||||||
|
import com.nflg.mobilebroken.common.util.VUtils;
|
||||||
|
import com.nflg.mobilebroken.repository.entity.DeviceComponent;
|
||||||
|
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
|
||||||
|
import com.nflg.mobilebroken.repository.service.IDeviceComponentService;
|
||||||
|
import com.nflg.mobilebroken.repository.service.ITBaseDepartmentService;
|
||||||
|
import com.nflg.mobilebroken.starter.annotation.MethodInfoMark;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/department")
|
||||||
|
public class DepartmentController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
ITBaseDepartmentService departmentService;
|
||||||
|
|
||||||
|
@PostMapping("getList")
|
||||||
|
@MethodInfoMark("获取部件列表")
|
||||||
|
public ApiResult<PageData<TBaseDepartment>> getSimpleAreas(@RequestBody DepartmentQuery query){
|
||||||
|
Page<TBaseDepartment> result = departmentService.selectListByPage(query);
|
||||||
|
return ApiResult.success(result.getRecords(),result.getCurrent(),result.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("getChild")
|
||||||
|
@MethodInfoMark("获取子级")
|
||||||
|
public ApiResult<List<TBaseDepartment>> getChild(@RequestParam("parentId") Integer parentId ){
|
||||||
|
|
||||||
|
return ApiResult.success(departmentService.getChildByParentId(parentId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("add")
|
||||||
|
@MethodInfoMark("新增")
|
||||||
|
public ApiResult<Boolean> add(@Valid @RequestBody DepartmentDTO departmentDTO){
|
||||||
|
|
||||||
|
List<TBaseDepartment> checkCode = departmentService.lambdaQuery().eq(TBaseDepartment::getDeptCode, departmentDTO.getDeptCode()).list();
|
||||||
|
VUtils.trueThrowBusinessError(CollUtil.isNotEmpty(checkCode)).throwMessage("编码已存在");
|
||||||
|
|
||||||
|
departmentService.saveDepartment(Convert.convert(TBaseDepartment.class,departmentDTO));
|
||||||
|
return ApiResult.success(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("del")
|
||||||
|
@MethodInfoMark("删除")
|
||||||
|
public ApiResult<Boolean> add(@RequestBody List<Integer> ids ){
|
||||||
|
VUtils.trueThrowBusinessError(CollUtil.isEmpty(ids)).throwMessage("请选择要删除的数据");
|
||||||
|
departmentService.del(ids);
|
||||||
|
return ApiResult.success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,100 @@
|
||||||
|
package com.nflg.mobilebroken.admin.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.nflg.mobilebroken.admin.pojo.query.DeviceComponentQuery;
|
||||||
|
import com.nflg.mobilebroken.common.constant.STATE;
|
||||||
|
import com.nflg.mobilebroken.common.exception.NflgException;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.ApiResult;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.PageData;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.dto.DevComponentExcel;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.vo.AreaSimpleVO;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.vo.AreaVO;
|
||||||
|
import com.nflg.mobilebroken.common.util.EecExcelUtil;
|
||||||
|
import com.nflg.mobilebroken.common.util.VUtils;
|
||||||
|
import com.nflg.mobilebroken.repository.entity.DeviceComponent;
|
||||||
|
import com.nflg.mobilebroken.repository.service.IDeviceComponentService;
|
||||||
|
import com.nflg.mobilebroken.starter.annotation.MethodInfoMark;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.ttzero.excel.entity.ListSheet;
|
||||||
|
import org.ttzero.excel.entity.Workbook;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.Struct;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/deviceComponent")
|
||||||
|
public class DeviceComponentController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
IDeviceComponentService deviceComponentService;
|
||||||
|
|
||||||
|
@PostMapping("getList")
|
||||||
|
@MethodInfoMark("获取部件列表")
|
||||||
|
public ApiResult<PageData<DeviceComponent>> getSimpleAreas(@RequestBody DeviceComponentQuery query){
|
||||||
|
Page<DeviceComponent> result = deviceComponentService.selectListByPage(query);
|
||||||
|
return ApiResult.success(result.getRecords(),result.getCurrent(),result.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("add")
|
||||||
|
@MethodInfoMark("新增部件")
|
||||||
|
public ApiResult<Boolean> add(@RequestBody DeviceComponentQuery component){
|
||||||
|
if(StrUtil.isBlank(component.getModelNo())){
|
||||||
|
throw new NflgException(STATE.ParamErr,"设备机型不能为空");
|
||||||
|
}
|
||||||
|
if(StrUtil.isBlank(component.getComponent())){
|
||||||
|
throw new NflgException(STATE.ParamErr,"机型部件不能为空");
|
||||||
|
}
|
||||||
|
DeviceComponent ent = Convert.convert(DeviceComponent.class, component);
|
||||||
|
deviceComponentService.saveComponent(ent);
|
||||||
|
return ApiResult.success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("del")
|
||||||
|
@MethodInfoMark("删除部件")
|
||||||
|
public ApiResult<Boolean> del(@RequestBody List<Integer> ids){
|
||||||
|
if(CollUtil.isNotEmpty(ids)){
|
||||||
|
throw new NflgException(STATE.ParamErr,"请选择要删除的部件");
|
||||||
|
}
|
||||||
|
deviceComponentService.batchDelComponent(ids);
|
||||||
|
return ApiResult.success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("importData")
|
||||||
|
@MethodInfoMark("导入部件")
|
||||||
|
public ApiResult<Boolean> importData( @RequestParam(value = "file") MultipartFile file){
|
||||||
|
|
||||||
|
try {
|
||||||
|
List<DevComponentExcel> data = EecExcelUtil.getExcelContext(file.getInputStream(), DevComponentExcel.class);
|
||||||
|
VUtils.trueThrowBusinessError(CollUtil.isEmpty(data)).throwMessage("导入文件内容为空");
|
||||||
|
deviceComponentService.saveOrUpdateBatchComponent(Convert.toList(DeviceComponent.class, data));
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new NflgException(STATE.BusinessError, "导出失败:"+e.getMessage());
|
||||||
|
}
|
||||||
|
return ApiResult.success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("exportData")
|
||||||
|
@MethodInfoMark("导出部件")
|
||||||
|
public void exportData(HttpServletResponse response) throws IOException {
|
||||||
|
List<DeviceComponent> list = deviceComponentService.list();
|
||||||
|
List<DevComponentExcel> excelList = Convert.toList(DevComponentExcel.class, list);
|
||||||
|
new Workbook("部件列表", "").addSheet(new ListSheet<>("sheet1", excelList)).writeTo(response.getOutputStream());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.nflg.mobilebroken.admin.pojo.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DepartmentDTO {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
@NotBlank(message = "编码不能为空")
|
||||||
|
private String deptCode;
|
||||||
|
|
||||||
|
@NotBlank(message = "名称不能为空")
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
|
|
||||||
|
private Integer deptParentId=0;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.nflg.mobilebroken.admin.pojo.query;
|
||||||
|
|
||||||
|
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DepartmentQuery extends PageBaseQuery {
|
||||||
|
|
||||||
|
//编码OR 名称
|
||||||
|
private String deptCodeOrName;
|
||||||
|
|
||||||
|
//是否有效 0-否 1-是
|
||||||
|
private Integer dataValidStatus;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.nflg.mobilebroken.admin.pojo.query;
|
||||||
|
|
||||||
|
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DeviceComponentQuery extends PageBaseQuery {
|
||||||
|
private String modelNo;
|
||||||
|
|
||||||
|
private String component;
|
||||||
|
}
|
||||||
|
|
@ -33,6 +33,15 @@
|
||||||
<groupId>cn.dev33</groupId>
|
<groupId>cn.dev33</groupId>
|
||||||
<artifactId>sa-token-core</artifactId>
|
<artifactId>sa-token-core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.tomcat.embed</groupId>
|
||||||
|
<artifactId>tomcat-embed-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.ttzero</groupId>
|
||||||
|
<artifactId>eec</artifactId>
|
||||||
|
<version>0.4.14</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,13 @@
|
||||||
package com.nflg.mobilebroken.common.pojo;
|
package com.nflg.mobilebroken.common.pojo;
|
||||||
|
|
||||||
|
import cn.hutool.db.Page;
|
||||||
import com.nflg.mobilebroken.common.constant.STATE;
|
import com.nflg.mobilebroken.common.constant.STATE;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class ApiResult<T> implements Serializable {
|
public class ApiResult<T> implements Serializable {
|
||||||
|
|
@ -24,6 +27,19 @@ public class ApiResult<T> implements Serializable {
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> ApiResult<PageData<T>> success(List<T> value, long page,long total) {
|
||||||
|
ApiResult<PageData<T>> vo = new ApiResult<>();
|
||||||
|
PageData<T> data=new PageData<>();
|
||||||
|
data.setItems(value);;
|
||||||
|
data.setPage(page);
|
||||||
|
data.setTotal(total);
|
||||||
|
vo.code = STATE.Success.getState();
|
||||||
|
vo.type=STATE.Success.getType();
|
||||||
|
vo.setResult(data);
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static <T> ApiResult<T> error(int state,String msg,T value) {
|
public static <T> ApiResult<T> error(int state,String msg,T value) {
|
||||||
ApiResult<T> vo = new ApiResult<>();
|
ApiResult<T> vo = new ApiResult<>();
|
||||||
vo.result = value;
|
vo.result = value;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.nflg.mobilebroken.common.pojo.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import org.ttzero.excel.annotation.ExcelColumn;
|
||||||
|
@Data
|
||||||
|
public class DevComponentExcel {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备机型
|
||||||
|
*/
|
||||||
|
@ExcelColumn("设备机型")
|
||||||
|
private String modelNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机型部件
|
||||||
|
*/
|
||||||
|
@ExcelColumn("机型部件")
|
||||||
|
private String component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用
|
||||||
|
*/
|
||||||
|
@ExcelColumn("是否启用")
|
||||||
|
private Boolean enable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
@ExcelColumn("创建人")
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@ExcelColumn("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最后更新人
|
||||||
|
*/
|
||||||
|
@ExcelColumn("最后更新人")
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最后更新时间
|
||||||
|
*/
|
||||||
|
@ExcelColumn("最后更新时间")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.nflg.mobilebroken.common.pojo.query;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class PageBaseQuery {
|
||||||
|
|
||||||
|
private Integer page=1;
|
||||||
|
|
||||||
|
private Integer pageSize=20;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,117 @@
|
||||||
|
package com.nflg.mobilebroken.common.util;
|
||||||
|
|
||||||
|
|
||||||
|
import com.nflg.mobilebroken.common.constant.STATE;
|
||||||
|
import com.nflg.mobilebroken.common.exception.NflgException;
|
||||||
|
import org.ttzero.excel.entity.ListSheet;
|
||||||
|
|
||||||
|
import org.ttzero.excel.entity.Workbook;
|
||||||
|
import org.ttzero.excel.reader.ExcelReader;
|
||||||
|
import org.ttzero.excel.reader.Row;
|
||||||
|
import org.ttzero.excel.reader.Sheet;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* eecExcel
|
||||||
|
*
|
||||||
|
* @Author 大米
|
||||||
|
*/
|
||||||
|
public class EecExcelUtil {
|
||||||
|
|
||||||
|
public static void setResponseExcelHeader(HttpServletResponse response, String fileName) throws UnsupportedEncodingException {
|
||||||
|
response.setHeader("content-Type", "application/octet-stream");
|
||||||
|
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName + ".xlsx", "utf-8"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void eecExcel(String fileName, List<ListSheet> sheets, HttpServletResponse response) throws IOException {
|
||||||
|
setResponseExcelHeader(response, fileName);
|
||||||
|
Workbook workbook = new Workbook();
|
||||||
|
for (ListSheet sheet : sheets) {
|
||||||
|
workbook.addSheet(sheet);
|
||||||
|
}
|
||||||
|
workbook.writeTo(response.getOutputStream());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 行读取excel sheet 0
|
||||||
|
*
|
||||||
|
* @param hanlder
|
||||||
|
* @param inputStream
|
||||||
|
*/
|
||||||
|
public static <T, U> void iteratorRead(BiConsumer<T, U> hanlder, InputStream inputStream, Class<T> cls, U u) {
|
||||||
|
try (ExcelReader reader = ExcelReader.read(inputStream)) {
|
||||||
|
Sheet sheet = reader.sheet(0);
|
||||||
|
Iterator<Row> ite = sheet.iterator();
|
||||||
|
while (ite.hasNext()) {
|
||||||
|
hanlder.accept(ite.next().to(cls), u);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new IllegalArgumentException("读取EXCEL 失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T, U> List<T> iteratorReadAndInitRowNum(BiConsumer<T, Integer> hanlder, InputStream inputStream, Class<T> cls, Integer rowNum) {
|
||||||
|
List<T> result = new ArrayList<>();
|
||||||
|
try (ExcelReader reader = ExcelReader.read(inputStream)) {
|
||||||
|
|
||||||
|
Sheet sheet = reader.sheet(0);
|
||||||
|
Iterator<Row> ite = sheet.iterator();
|
||||||
|
while (ite.hasNext()) {
|
||||||
|
T t = ite.next().to(cls);
|
||||||
|
hanlder.accept(t, rowNum++);
|
||||||
|
result.add(t);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new IllegalArgumentException("读取EXCEL 失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> List<T> getExcelContext(InputStream inputStream, Class<T> clc) throws IOException {
|
||||||
|
try {
|
||||||
|
return ExcelReader.read(inputStream)
|
||||||
|
.sheet(0)
|
||||||
|
.dataRows() // 所有数据列,会过滤掉表头
|
||||||
|
.map(row -> row.to(clc))// 列数据转Stock对象
|
||||||
|
.collect(Collectors.toList());// 转为对象数组
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new NflgException(STATE.BusinessError, "读取EXCEL 失败,请检查模板是否正确:" + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> List<T> handlerExcel(InputStream inputStream, Class<T> clc, Consumer<T> handler) {
|
||||||
|
List<T> result = new ArrayList<>();
|
||||||
|
try (ExcelReader reader = ExcelReader.read(inputStream)) {
|
||||||
|
|
||||||
|
reader.sheet(0).dataRows().map(row -> row.to(clc)
|
||||||
|
// T t= row.too(clc);
|
||||||
|
// t.setRowNum(row.getRowNum());
|
||||||
|
// return t ;
|
||||||
|
).forEach(u -> {
|
||||||
|
if (handler != null) {
|
||||||
|
handler.accept(u);
|
||||||
|
result.add(u);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new NflgException(STATE.ParamErr, "excel 解析失败,请检查模板是否正确");
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.nflg.mobilebroken.common.util;
|
package com.nflg.mobilebroken.common.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.ListUtil;
|
||||||
import com.nflg.mobilebroken.common.constant.STATE;
|
import com.nflg.mobilebroken.common.constant.STATE;
|
||||||
import com.nflg.mobilebroken.common.exception.NflgException;
|
import com.nflg.mobilebroken.common.exception.NflgException;
|
||||||
|
|
||||||
|
|
@ -20,7 +21,7 @@ public class TokenUtil {
|
||||||
public static List<Integer> getCompanyId(){
|
public static List<Integer> getCompanyId(){
|
||||||
try {
|
try {
|
||||||
//TODO 待实现
|
//TODO 待实现
|
||||||
return List.of(111);
|
return ListUtil.of(111);
|
||||||
//return (List<Integer>)StpUtil.getExtra("companyId");
|
//return (List<Integer>)StpUtil.getExtra("companyId");
|
||||||
}catch (Exception ex){
|
}catch (Exception ex){
|
||||||
throw new NflgException(STATE.LoginError,"请登录");
|
throw new NflgException(STATE.LoginError,"请登录");
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,11 @@ public class DictionaryItem implements Serializable {
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字典id
|
||||||
|
*/
|
||||||
|
private Integer dictionaryId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典值编码
|
* 字典值编码
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
package com.nflg.mobilebroken.repository.mapper;
|
package com.nflg.mobilebroken.repository.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
||||||
import com.nflg.mobilebroken.repository.entity.DeviceComponent;
|
import com.nflg.mobilebroken.repository.entity.DeviceComponent;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|
@ -13,4 +16,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
*/
|
*/
|
||||||
public interface DeviceComponentMapper extends BaseMapper<DeviceComponent> {
|
public interface DeviceComponentMapper extends BaseMapper<DeviceComponent> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
* @param page
|
||||||
|
* @param query
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Page<DeviceComponent> selectListByPage(@Param("page") Page<PageBaseQuery> page, @Param("query") PageBaseQuery query);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,12 @@
|
||||||
package com.nflg.mobilebroken.repository.mapper;
|
package com.nflg.mobilebroken.repository.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
||||||
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
|
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|
@ -13,4 +18,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
*/
|
*/
|
||||||
public interface TBaseDepartmentMapper extends BaseMapper<TBaseDepartment> {
|
public interface TBaseDepartmentMapper extends BaseMapper<TBaseDepartment> {
|
||||||
|
|
||||||
|
Page<TBaseDepartment> selectListByPage(@Param("page") Page<PageBaseQuery> page,@Param("query") PageBaseQuery query );
|
||||||
|
|
||||||
|
void del(@Param("ids") List<Integer> ids);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,13 @@
|
||||||
package com.nflg.mobilebroken.repository.service;
|
package com.nflg.mobilebroken.repository.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
||||||
import com.nflg.mobilebroken.repository.entity.DeviceComponent;
|
import com.nflg.mobilebroken.repository.entity.DeviceComponent;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|
@ -13,4 +19,20 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
*/
|
*/
|
||||||
public interface IDeviceComponentService extends IService<DeviceComponent> {
|
public interface IDeviceComponentService extends IService<DeviceComponent> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
* @param
|
||||||
|
* @param query
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Page<DeviceComponent> selectListByPage( @Param("query") PageBaseQuery query);
|
||||||
|
|
||||||
|
DeviceComponent saveComponent(DeviceComponent component);
|
||||||
|
|
||||||
|
|
||||||
|
void delComponent(Integer id);
|
||||||
|
|
||||||
|
void batchDelComponent(List<Integer> ids);
|
||||||
|
|
||||||
|
Boolean saveOrUpdateBatchComponent(List<DeviceComponent> data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,13 @@
|
||||||
package com.nflg.mobilebroken.repository.service;
|
package com.nflg.mobilebroken.repository.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
||||||
|
import com.nflg.mobilebroken.repository.entity.DeviceComponent;
|
||||||
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
|
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|
@ -13,4 +19,14 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
*/
|
*/
|
||||||
public interface ITBaseDepartmentService extends IService<TBaseDepartment> {
|
public interface ITBaseDepartmentService extends IService<TBaseDepartment> {
|
||||||
|
|
||||||
|
Page<TBaseDepartment> selectListByPage(@Param("query") PageBaseQuery query);
|
||||||
|
|
||||||
|
|
||||||
|
Boolean saveDepartment(TBaseDepartment department);
|
||||||
|
|
||||||
|
|
||||||
|
void del(List<Integer> ids);
|
||||||
|
|
||||||
|
List<TBaseDepartment> getChildByParentId(Integer id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,16 @@
|
||||||
package com.nflg.mobilebroken.repository.service.impl;
|
package com.nflg.mobilebroken.repository.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
||||||
import com.nflg.mobilebroken.repository.entity.DeviceComponent;
|
import com.nflg.mobilebroken.repository.entity.DeviceComponent;
|
||||||
import com.nflg.mobilebroken.repository.mapper.DeviceComponentMapper;
|
import com.nflg.mobilebroken.repository.mapper.DeviceComponentMapper;
|
||||||
import com.nflg.mobilebroken.repository.service.IDeviceComponentService;
|
import com.nflg.mobilebroken.repository.service.IDeviceComponentService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 机型部件 服务实现类
|
* 机型部件 服务实现类
|
||||||
|
|
@ -17,4 +22,42 @@ import org.springframework.stereotype.Service;
|
||||||
@Service
|
@Service
|
||||||
public class DeviceComponentServiceImpl extends ServiceImpl<DeviceComponentMapper, DeviceComponent> implements IDeviceComponentService {
|
public class DeviceComponentServiceImpl extends ServiceImpl<DeviceComponentMapper, DeviceComponent> implements IDeviceComponentService {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
* @param page
|
||||||
|
* @param query
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Page<DeviceComponent> selectListByPage( @Param("query") PageBaseQuery query){
|
||||||
|
return this.getBaseMapper().selectListByPage(new Page<>(query.getPage(),query.getPageSize()) ,query);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存
|
||||||
|
* @param component
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public DeviceComponent saveComponent(DeviceComponent component){
|
||||||
|
this.saveOrUpdate(component);
|
||||||
|
return component;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delComponent(Integer id){
|
||||||
|
this.getBaseMapper().deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Boolean saveOrUpdateBatchComponent(List<DeviceComponent> data){
|
||||||
|
return this.saveOrUpdateBatch(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void batchDelComponent(List<Integer> ids){
|
||||||
|
this.getBaseMapper().deleteByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,17 @@
|
||||||
package com.nflg.mobilebroken.repository.service.impl;
|
package com.nflg.mobilebroken.repository.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.nflg.mobilebroken.common.pojo.query.PageBaseQuery;
|
||||||
|
import com.nflg.mobilebroken.repository.entity.DeviceComponent;
|
||||||
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
|
import com.nflg.mobilebroken.repository.entity.TBaseDepartment;
|
||||||
import com.nflg.mobilebroken.repository.mapper.TBaseDepartmentMapper;
|
import com.nflg.mobilebroken.repository.mapper.TBaseDepartmentMapper;
|
||||||
import com.nflg.mobilebroken.repository.service.ITBaseDepartmentService;
|
import com.nflg.mobilebroken.repository.service.ITBaseDepartmentService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* 部门表 服务实现类
|
* 部门表 服务实现类
|
||||||
|
|
@ -17,4 +23,22 @@ import org.springframework.stereotype.Service;
|
||||||
@Service
|
@Service
|
||||||
public class TBaseDepartmentServiceImpl extends ServiceImpl<TBaseDepartmentMapper, TBaseDepartment> implements ITBaseDepartmentService {
|
public class TBaseDepartmentServiceImpl extends ServiceImpl<TBaseDepartmentMapper, TBaseDepartment> implements ITBaseDepartmentService {
|
||||||
|
|
||||||
|
|
||||||
|
public Page<TBaseDepartment> selectListByPage(@Param("query") PageBaseQuery query) {
|
||||||
|
return this.getBaseMapper().selectListByPage(new Page<>(query.getPage(), query.getPageSize()), query);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Boolean saveDepartment(TBaseDepartment department) {
|
||||||
|
return this.saveOrUpdate(department);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void del(List<Integer> ids) {
|
||||||
|
this.getBaseMapper().del(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TBaseDepartment> getChildByParentId(Integer id) {
|
||||||
|
return this.lambdaQuery().eq(TBaseDepartment::getDeptParentId, id).list();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,16 @@
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.nflg.mobilebroken.repository.mapper.DeviceComponentMapper">
|
<mapper namespace="com.nflg.mobilebroken.repository.mapper.DeviceComponentMapper">
|
||||||
|
|
||||||
|
<sql id="whr">
|
||||||
|
<if test="query.modelNo!=null and query.modelNo!=''">
|
||||||
|
and model_no=#{query.modelNo}
|
||||||
|
</if>
|
||||||
|
<if test="query.component!=null and query.component!=''">
|
||||||
|
and component like concat('%',#{query.component} ,"%")
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
|
<select id="selectListByPage" resultType="com.nflg.mobilebroken.repository.entity.DeviceComponent">
|
||||||
|
select * from device_component where 1=1
|
||||||
|
<include refid="whr" />
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,25 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.nflg.mobilebroken.repository.mapper.TBaseDepartmentMapper">
|
<mapper namespace="com.nflg.mobilebroken.repository.mapper.TBaseDepartmentMapper">
|
||||||
|
<sql id="whr">
|
||||||
|
<if test="query.deptCodeOrName!=null and query.deptCodeOrName!=''">
|
||||||
|
and (dept_code=#{query.deptCodeOrName} or dept_name=#{query.deptCodeOrName})
|
||||||
|
</if>
|
||||||
|
<if test="query.dataValidStatus!=null">
|
||||||
|
and data_valid_status=#{query.dataValidStatus}
|
||||||
|
</if>
|
||||||
|
</sql>
|
||||||
|
<select id="selectListByPage" resultType="com.nflg.mobilebroken.repository.entity.TBaseDepartment">
|
||||||
|
select *
|
||||||
|
from t_base_department
|
||||||
|
where 1 = 1 and dept_parent_id=0
|
||||||
|
<include refid="whr"/>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<update id="del">
|
||||||
|
update t_base_department set data_valid_status=0 where id in
|
||||||
|
<foreach collection="ids" item="item" open="(" close=")" separator=",">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,17 @@
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-aop</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>1.2.83</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
package com.nflg.mobilebroken.starter.advice;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||||
|
import com.nflg.mobilebroken.starter.annotation.MethodInfoMark;
|
||||||
|
import org.aspectj.lang.JoinPoint;
|
||||||
|
import org.aspectj.lang.annotation.AfterReturning;
|
||||||
|
import org.aspectj.lang.annotation.AfterThrowing;
|
||||||
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
import org.aspectj.lang.annotation.Before;
|
||||||
|
import org.aspectj.lang.reflect.MethodSignature;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
@Aspect
|
||||||
|
@Component
|
||||||
|
public class LoggingAspect {
|
||||||
|
|
||||||
|
private static final ThreadLocal<String> requestIdHolder = new ThreadLocal<>();
|
||||||
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||||
|
|
||||||
|
@Before("execution(* com.nflg.mobilebroken.admin.controller..*(..))")
|
||||||
|
public void logMethodCall(JoinPoint joinPoint) {
|
||||||
|
try {
|
||||||
|
// 获取HttpServletRequest对象
|
||||||
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||||
|
HttpServletRequest request = attributes.getRequest();
|
||||||
|
|
||||||
|
Long requestId = IdWorker.getId();
|
||||||
|
requestIdHolder.set(requestId.toString());
|
||||||
|
|
||||||
|
// 获取ApiOperation注解
|
||||||
|
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||||
|
Method method = signature.getMethod();
|
||||||
|
MethodInfoMark apiOperation = method.getAnnotation(MethodInfoMark.class);
|
||||||
|
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Error logging request", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterReturning(pointcut = "execution(* com.nflg.mobilebroken.admin.controller..*(..))", returning = "result")
|
||||||
|
public void logMethodResponse(Object result) {
|
||||||
|
try {
|
||||||
|
String requestId = requestIdHolder.get();
|
||||||
|
// 批量保存响应日志
|
||||||
|
// saveLogBatch(logRecord);
|
||||||
|
|
||||||
|
logger.info("Response for request {}: {}", requestId, JSON.toJSONString(result));
|
||||||
|
} finally {
|
||||||
|
requestIdHolder.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterThrowing(pointcut = "execution(* com.nflg.mobilebroken.admin.controller..*(..))", throwing = "ex")
|
||||||
|
public void logAfterThrowing(JoinPoint joinPoint, Throwable ex) {
|
||||||
|
try {
|
||||||
|
String requestId = requestIdHolder.get();
|
||||||
|
StackTraceElement[] stackTraceElements = ex.getStackTrace();
|
||||||
|
logger.error("Exception in {} for request {}: {} at {}",
|
||||||
|
joinPoint.getSignature().getName(),
|
||||||
|
requestId,
|
||||||
|
ex.getMessage(),
|
||||||
|
stackTraceElements.length > 0 ? stackTraceElements[0].toString() : "");
|
||||||
|
} finally {
|
||||||
|
requestIdHolder.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.nflg.mobilebroken.starter.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
public @interface MethodInfoMark {
|
||||||
|
String value() default "";
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue