package com.product.admin.service;
|
|
import com.product.core.entity.FieldSetEntity;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
|
import com.product.core.dao.BaseDao;
|
import com.product.core.exception.BaseException;
|
import com.product.core.service.support.AbstractBaseService;
|
import com.product.core.util.CodeUtil;
|
|
@Component
|
public class CodeService extends AbstractBaseService {
|
/**
|
* 数据查询 ,spring 注入
|
*/
|
@Autowired
|
public BaseDao baseDao;
|
|
public String createCode(FieldSetEntity fse, String table, String field, String parentCode) throws BaseException {
|
fse.setValue(field, CodeUtil.getNewCodeByTemp(table, field, parentCode == null ? "" : parentCode));
|
fse.setCodeFieldUpdateFlat(field, true);
|
return fse.getString(field);
|
}
|
|
/**
|
* 获取临时编码
|
*
|
* @param table 表名
|
* @param field 字段名
|
* @param parentCode 上级编码,如果没有上级编码,则为"",不能为null
|
* @return
|
* @throws BaseException
|
*/
|
public String createCode(String table, String field, String parentCode) throws BaseException {
|
return CodeUtil.getNewCodeByTemp(table, field, parentCode == null ? "" : parentCode);
|
}
|
|
/**
|
* 获取固定编码,除导入数据时要求自动生成外,不要调些方法
|
*
|
* @param table 表名
|
* @param field 字段名
|
* @param parentCode 上级编码,如果没有上级编码,则为"",不能为null
|
* @return
|
* @throws BaseException
|
*/
|
public String createFixCode(String table, String field, String parentCode) throws BaseException {
|
return CodeUtil.getNewCode(table, field, CodeUtil.getNewCodeByTemp(table, field, parentCode));
|
}
|
}
|