FlowMainLogService.java 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. package com.idea.oa.flow2.service;
  2. import com.github.pagehelper.PageHelper;
  3. import com.github.pagehelper.PageInfo;
  4. import com.idea.oa.flow2.mapper.FlowMainLogMapper;
  5. import com.idea.oa.flow2.model.FlowMainLog;
  6. import com.idea.oa.flow2.model.FlowMainLogExample;
  7. import com.rockstar.common.base.BaseService;
  8. import com.rockstar.common.support.Convert;
  9. import com.rockstar.frame.model.extend.DateTrans;
  10. import com.rockstar.frame.model.extend.Tablepar;
  11. import com.rockstar.util.UUIDUtils;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.stereotype.Service;
  14. import java.util.ArrayList;
  15. import java.util.Date;
  16. import java.util.List;
  17. @Service
  18. public class FlowMainLogService implements BaseService<FlowMainLog, FlowMainLogExample> {
  19. //文件mapper
  20. @Autowired
  21. private FlowMainLogMapper modelMapper;
  22. /**
  23. * 分页查询
  24. *
  25. * @return
  26. */
  27. public PageInfo<FlowMainLog> list(Tablepar tablepar, FlowMainLog model, DateTrans dt) {
  28. PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
  29. List<FlowMainLog> list = null;//modelMapper.selectByExample(getCondition(model,dt));
  30. PageInfo<FlowMainLog> pageInfo = new PageInfo<>(list);
  31. return pageInfo;
  32. }
  33. public Object listAll(FlowMainLog model, DateTrans dt) {
  34. List<FlowMainLog> list = null;//modelMapper.selectByExample(getCondition(model,dt));
  35. return list;
  36. }
  37. @Override
  38. public int deleteByPrimaryKey(String ids) {
  39. List<String> lista = Convert.toListStrArray(ids);
  40. FlowMainLogExample example = new FlowMainLogExample();
  41. example.createCriteria().andIdIn(lista);
  42. return modelMapper.deleteByExample(example);
  43. }
  44. @Override
  45. public FlowMainLog selectByPrimaryKey(String id) {
  46. return modelMapper.selectByPrimaryKey(id);
  47. }
  48. @Override
  49. public int updateByPrimaryKeySelective(FlowMainLog record) {
  50. return modelMapper.updateByPrimaryKeySelective(record);
  51. }
  52. @Override
  53. public int updateByExampleSelective(FlowMainLog record, FlowMainLogExample example) {
  54. return modelMapper.updateByExampleSelective(record, example);
  55. }
  56. @Override
  57. public int updateByExample(FlowMainLog record, FlowMainLogExample example) {
  58. return modelMapper.updateByExample(record, example);
  59. }
  60. @Override
  61. public List<FlowMainLog> selectByExample(FlowMainLogExample example) {
  62. return modelMapper.selectByExample(example);
  63. }
  64. @Override
  65. public long countByExample(FlowMainLogExample example) {
  66. return modelMapper.countByExample(example);
  67. }
  68. @Override
  69. public int deleteByExample(FlowMainLogExample example) {
  70. return modelMapper.deleteByExample(example);
  71. }
  72. public int insert(FlowMainLog record){
  73. record.setId(UUIDUtils.middleUUID());
  74. return insertWithoutId(record);
  75. }
  76. public int insertWithoutId(FlowMainLog record){
  77. return modelMapper.insert(record);
  78. }
  79. @Override
  80. public int insertSelective(FlowMainLog record) {
  81. record.setId(UUIDUtils.middleUUID());
  82. record.setCreatedAt(new Date());
  83. return modelMapper.insertSelective(record);
  84. }
  85. public FlowMainLog selectLastOneByFlowMainId(String flowMainId) {
  86. FlowMainLogExample example = new FlowMainLogExample();
  87. example.setOrderByClause("created_at desc limit 1");
  88. example.createCriteria().andFlowMainIdEqualTo(flowMainId);
  89. List<FlowMainLog> flowMainLogs = modelMapper.selectByExample(example);
  90. if (flowMainLogs.isEmpty()){
  91. return null;
  92. }else{
  93. return flowMainLogs.get(0);
  94. }
  95. }
  96. /**
  97. * 查询所有通过的日志信息
  98. * @param flowMainId
  99. * @return
  100. */
  101. public List<FlowMainLog> selectPassListByFlowMainId(String flowMainId) {
  102. FlowMainLogExample example = new FlowMainLogExample();
  103. example.setOrderByClause("created_at desc");
  104. example.createCriteria().andFlowMainIdEqualTo(flowMainId).andStatusEqualTo(0).andAuditResultEqualTo("1");
  105. List<FlowMainLog> flowMainLogs = modelMapper.selectByExample(example);
  106. if (flowMainLogs.isEmpty()){
  107. return new ArrayList<>();
  108. }else{
  109. return flowMainLogs;
  110. }
  111. }
  112. }