| | |
| | | import com.moral.api.service.OrganizationService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.moral.api.service.UserService; |
| | | import com.moral.api.util.CompareFieldUtils; |
| | | import com.moral.api.util.LogUtils; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.pojo.CompareFieldResult; |
| | | import com.moral.util.ConvertUtils; |
| | | import com.moral.util.DateUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.web.context.request.ServletRequestAttributes; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.function.Predicate; |
| | | |
| | |
| | | organizationDTO.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); |
| | | |
| | | //操作插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("添加了组织:").append(organization.getName() + ";"); |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | insertLog(organization); |
| | | return organizationDTO; |
| | | } |
| | | |
| | |
| | | organizationDTO.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); |
| | | |
| | | //操作插入日志 |
| | | insertUpdateLog(organizationUpdateForm, organization, oldOrganization); |
| | | updateLog(oldOrganization,organization); |
| | | |
| | | return organizationDTO; |
| | | } |
| | |
| | | dto.setCode(ResponseCodeEnum.SUCCESS.getCode()); |
| | | dto.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); |
| | | //操作插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("删除了组织:").append(existOrganization.getName()); |
| | | if (form.getDeleteChildren().equals(Constants.DELETE_CHILDREN_ORG)) |
| | | content.append("以及所有子组织;"); |
| | | else |
| | | content.append(";"); |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.DELETE_OPERATE_TYPE); |
| | | logUtils.saveOperationForManage(content.toString(), Constants.DELETE_OPERATE_TYPE); |
| | | |
| | | return dto; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @Description: 插入操作插入日志 |
| | | * @Param: [organization] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/8/25 |
| | | */ |
| | | private void insertLog(Organization organization){ |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("添加了组织:").append(organization.getName() + ";"); |
| | | logUtils.saveOperationForManage(content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | } |
| | | |
| | | public void updateLog(Organization oldOrganization,Organization newOrganization){ |
| | | List<CompareFieldResult> results = CompareFieldUtils.compare(Organization.class, oldOrganization, newOrganization); |
| | | for (CompareFieldResult result : results) { |
| | | //改变父组织特殊处理 |
| | | if(result.getFieldName().equals("parentId")){ |
| | | //父组织id转换为名称 |
| | | String oldData = result.getOldData(); |
| | | String newData = result.getNewData(); |
| | | |
| | | if (!oldData.equals("0")) |
| | | oldData = organizationMapper.selectById(Integer.parseInt(oldData)).getName(); |
| | | else |
| | | oldData = "null"; |
| | | |
| | | if (!newData.equals("0")) |
| | | newData = organizationMapper.selectById(Integer.parseInt(newData)).getName(); |
| | | else |
| | | newData = "null"; |
| | | |
| | | result.setNewData(newData); |
| | | result.setOldData(oldData); |
| | | result.setFieldAnnoName("父组织"); |
| | | } |
| | | |
| | | //过期时间格式转换 |
| | | if(result.getFieldName().equals("expireTime")){ |
| | | //DateToString的时间格式改为yyyy-MM-dd |
| | | String oldData = result.getOldData(); |
| | | String newData = result.getNewData(); |
| | | |
| | | if(oldData!=null){ |
| | | Date oldDate = DateUtils.dateStringToDate(oldData); |
| | | oldData = DateUtils.dateToDateString(oldDate, "yyyy-MM-dd"); |
| | | } |
| | | |
| | | if(newData!=null){ |
| | | Date newDate = DateUtils.dateStringToDate(newData); |
| | | newData = DateUtils.dateToDateString(newDate, "yyyy-MM-dd"); |
| | | } |
| | | |
| | | result.setNewData(newData); |
| | | result.setOldData(oldData); |
| | | result.setFieldAnnoName("过期时间"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |