AutoStructWrapper.java 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * Redistributions of source code must retain the above copyright notice,
  8. * this list of conditions and the following disclaimer.
  9. * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * Neither the name of the dreamlu.net developer nor the names of its
  13. * contributors may be used to endorse or promote products derived from
  14. * this software without specific prior written permission.
  15. * Author: Chill 庄骞 (smallchill@163.com)
  16. */
  17. package org.springblade.bank.autostruct.wrapper;
  18. import org.springblade.common.cache.SysCache;
  19. import org.springblade.core.mp.support.BaseEntityWrapper;
  20. import org.springblade.core.tool.utils.BeanUtil;
  21. import org.springblade.bank.autostruct.entity.AutoStruct;
  22. import org.springblade.bank.autostruct.vo.AutoStructVO;
  23. import org.springblade.core.tool.utils.StringUtil;
  24. import java.util.List;
  25. import java.util.Objects;
  26. /**
  27. * 包装类,返回视图层所需的字段
  28. *
  29. * @author BladeX
  30. * @since 2021-09-23
  31. */
  32. public class AutoStructWrapper extends BaseEntityWrapper<AutoStruct, AutoStructVO> {
  33. public static AutoStructWrapper build() {
  34. return new AutoStructWrapper();
  35. }
  36. @Override
  37. public AutoStructVO entityVO(AutoStruct autoStruct) {
  38. AutoStructVO autoStructVO = Objects.requireNonNull(BeanUtil.copy(autoStruct, AutoStructVO.class));
  39. //User createUser = UserCache.getUser(autoStruct.getCreateUser());
  40. //User updateUser = UserCache.getUser(autoStruct.getUpdateUser());
  41. //autoStructVO.setCreateUserName(createUser.getName());
  42. //autoStructVO.setUpdateUserName(updateUser.getName());
  43. List<String> deptNames = SysCache.getDeptNames(autoStruct.getDeptId());
  44. List<String> roleNames = SysCache.getDeptNames(autoStruct.getRoleId());
  45. autoStructVO.setDeptName(StringUtil.join(deptNames, "|"));
  46. autoStructVO.setRoleName(StringUtil.join(roleNames, "|"));
  47. return autoStructVO;
  48. }
  49. }