| 1234567891011121314151617181920212223242526272829303132 |
- package com.izouma.nineth.converter;
- import com.alibaba.fastjson.JSON;
- import com.izouma.nineth.domain.PreEmptionPrivilege;
- import org.apache.commons.lang3.StringUtils;
- import javax.persistence.AttributeConverter;
- import javax.persistence.Converter;
- @Converter
- public class PreEmptionPrivilegeConverter implements AttributeConverter<PreEmptionPrivilege, String> {
- @Override
- public String convertToDatabaseColumn(PreEmptionPrivilege privileges) {
- if (privileges == null) {
- return null;
- }
- return JSON.toJSONString(privileges);
- }
- @Override
- public PreEmptionPrivilege convertToEntityAttribute(String s) {
- if (StringUtils.isEmpty(s)) {
- return null;
- }
- try {
- return JSON.parseObject(s, PreEmptionPrivilege.class);
- } catch (Exception ignored) {
- }
- return null;
- }
- }
|