Browse Source

-024-08-03 增加日志的删除时是否同步删除文件

master
zhousq 4 months ago
parent
commit
e7df85b0e0
  1. 5
      win-admin/src/main/resources/application.yml
  2. 32
      win-print/src/main/java/com/win/print/controller/WinPrintTasksLogsController.java
  3. 2
      win-print/src/main/java/com/win/print/mapper/WinPrintTasksLogsMapper.java
  4. 2
      win-print/src/main/java/com/win/print/service/IWinPrintTasksLogsService.java
  5. 5
      win-print/src/main/java/com/win/print/service/impl/WinPrintTasksLogsServiceImpl.java
  6. 7
      win-print/src/main/resources/mapper/print/WinPrintTasksLogsMapper.xml

5
win-admin/src/main/resources/application.yml

@ -17,8 +17,9 @@ win:
path:
template: /models
print: /print
file:
print:
delSync: false #是否同步删除文件
# 开发环境配置
server:
# 服务器的HTTP端口,默认为80

32
win-print/src/main/java/com/win/print/controller/WinPrintTasksLogsController.java

@ -5,6 +5,7 @@ import java.net.http.HttpResponse;
import java.util.List;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpRequest;
@ -51,10 +52,14 @@ import javax.print.attribute.PrintRequestAttributeSet;
@RequestMapping("/print/logmanager")
public class WinPrintTasksLogsController extends BaseController {
private String prefix = "print/logmanager";
// @Resource
// IWinPrintSettingsService iSettingsService;
@Resource
IWinPrintSettingsService iSettingsService;
@Autowired
private IWinPrintTasksLogsService winPrintTasksLogsService;
@Value("${win.path.print}")
private String printFilepath; //生成的打印文件存储路径
@Value("${win.file.print.delSync}")
private Boolean delSync; //删除日志记录时是否删除文件
@RequiresPermissions("print:logmanager:view")
@GetMapping()
@ -116,10 +121,10 @@ public class WinPrintTasksLogsController extends BaseController {
mmap.put("winPrintTasksLogs", winPrintTasksLogs);
return prefix + "/edit";
}
@RequiresPermissions("print:logmanager:edit")
@GetMapping("/detail/{id}")
public String detail(@PathVariable("id") Long id, ModelMap mmap)
{
public String detail(@PathVariable("id") Long id, ModelMap mmap) {
mmap.put("name", "printLog");
mmap.put("printLog", winPrintTasksLogsService.selectWinPrintTasksLogsById(id));
return prefix + "/detail";
@ -127,14 +132,13 @@ public class WinPrintTasksLogsController extends BaseController {
@RequiresPermissions("print:logmanager:edit")
@GetMapping("/printChange/{id}")
public String printChange(@PathVariable("id") Long id, ModelMap mmap)
{
public String printChange(@PathVariable("id") Long id, ModelMap mmap) {
//mmap.put("name", "printer");
mmap.put("winPrintTasksLogs", winPrintTasksLogsService.selectWinPrintTasksLogsById(id));
return prefix + "/printChange";
}
@Value("${win.path.print}")
private String printFilepath; //生成的打印文件存储路径
@RequiresPermissions("print:logmanager:edit")
@GetMapping("/print/{id}")
@ -151,6 +155,7 @@ public class WinPrintTasksLogsController extends BaseController {
}
}
@RequiresPermissions("print:logmanager:edit")
@GetMapping("/doprint/{id}")
@ResponseBody
@ -201,6 +206,15 @@ public class WinPrintTasksLogsController extends BaseController {
@PostMapping("/remove")
@ResponseBody
public AjaxResult remove(String ids) {
return toAjax(winPrintTasksLogsService.deleteWinPrintTasksLogsByIds(ids));
List<WinPrintTasksLogs> winPrintTasksLogs = winPrintTasksLogsService.selectWinPrintTasksLogsByIds(ids);
int i = winPrintTasksLogsService.deleteWinPrintTasksLogsByIds(ids);
if (delSync) {
if (i > 0 && winPrintTasksLogs.size() > 0) {
winPrintTasksLogs.forEach(item -> {
FileUtil.del(DataUnitl.getWorkingDir(printFilepath) + "/" + item.getDataFile());
});
}
}
return toAjax(i);
}
}

2
win-print/src/main/java/com/win/print/mapper/WinPrintTasksLogsMapper.java

@ -18,7 +18,7 @@ public interface WinPrintTasksLogsMapper
* @return 打印任务日志
*/
public WinPrintTasksLogs selectWinPrintTasksLogsById(Long id);
public List<WinPrintTasksLogs> selectWinPrintTasksLogsByIds(String[] ids);
/**
* 查询打印任务日志列表
*

2
win-print/src/main/java/com/win/print/service/IWinPrintTasksLogsService.java

@ -44,7 +44,7 @@ public interface IWinPrintTasksLogsService
* @return 结果
*/
public int updateWinPrintTasksLogs(WinPrintTasksLogs winPrintTasksLogs);
public List<WinPrintTasksLogs> selectWinPrintTasksLogsByIds(String ids);
/**
* 批量删除打印任务日志
*

5
win-print/src/main/java/com/win/print/service/impl/WinPrintTasksLogsServiceImpl.java

@ -98,7 +98,10 @@ public class WinPrintTasksLogsServiceImpl implements IWinPrintTasksLogsService
{
return winPrintTasksLogsMapper.deleteWinPrintTasksLogsByIds(Convert.toStrArray(ids));
}
@Override
public List<WinPrintTasksLogs> selectWinPrintTasksLogsByIds(String ids){
return winPrintTasksLogsMapper.selectWinPrintTasksLogsByIds(Convert.toStrArray(ids));
}
/**
* 删除打印任务日志信息
*

7
win-print/src/main/resources/mapper/print/WinPrintTasksLogsMapper.xml

@ -59,6 +59,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectWinPrintTasksLogsVo"/>
where id = #{id}
</select>
<select id="selectWinPrintTasksLogsByIds" parameterType="String" resultMap="WinPrintTasksLogsResult">
<include refid="selectWinPrintTasksLogsVo"/>
where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<insert id="insertWinPrintTasksLogs" parameterType="WinPrintTasksLogs" useGeneratedKeys="true" keyProperty="id">
insert into win_print_tasks_logs

Loading…
Cancel
Save