异常封装之商品属性信息后台修改
This commit is contained in:
@@ -19,16 +19,16 @@ public class MaterialPropertyComponent implements ICommonQuery {
|
|||||||
private MaterialPropertyService materialPropertyService;
|
private MaterialPropertyService materialPropertyService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object selectOne(String condition) {
|
public Object selectOne(String condition)throws Exception {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<?> select(Map<String, String> map) {
|
public List<?> select(Map<String, String> map)throws Exception {
|
||||||
return getMaterialPropertyList(map);
|
return getMaterialPropertyList(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<?> getMaterialPropertyList(Map<String, String> map) {
|
private List<?> getMaterialPropertyList(Map<String, String> map)throws Exception {
|
||||||
String search = map.get(Constants.SEARCH);
|
String search = map.get(Constants.SEARCH);
|
||||||
String name = StringUtil.getInfo(search, "name");
|
String name = StringUtil.getInfo(search, "name");
|
||||||
String order = QueryUtils.order(map);
|
String order = QueryUtils.order(map);
|
||||||
@@ -36,34 +36,34 @@ public class MaterialPropertyComponent implements ICommonQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long counts(Map<String, String> map) {
|
public Long counts(Map<String, String> map)throws Exception {
|
||||||
String search = map.get(Constants.SEARCH);
|
String search = map.get(Constants.SEARCH);
|
||||||
String name = StringUtil.getInfo(search, "name");
|
String name = StringUtil.getInfo(search, "name");
|
||||||
return materialPropertyService.countMaterialProperty(name);
|
return materialPropertyService.countMaterialProperty(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int insert(String beanJson, HttpServletRequest request) {
|
public int insert(String beanJson, HttpServletRequest request)throws Exception {
|
||||||
return materialPropertyService.insertMaterialProperty(beanJson, request);
|
return materialPropertyService.insertMaterialProperty(beanJson, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int update(String beanJson, Long id) {
|
public int update(String beanJson, Long id)throws Exception {
|
||||||
return materialPropertyService.updateMaterialProperty(beanJson, id);
|
return materialPropertyService.updateMaterialProperty(beanJson, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int delete(Long id) {
|
public int delete(Long id)throws Exception {
|
||||||
return materialPropertyService.deleteMaterialProperty(id);
|
return materialPropertyService.deleteMaterialProperty(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int batchDelete(String ids) {
|
public int batchDelete(String ids)throws Exception {
|
||||||
return materialPropertyService.batchDeleteMaterialProperty(ids);
|
return materialPropertyService.batchDeleteMaterialProperty(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int checkIsNameExist(Long id, String name) {
|
public int checkIsNameExist(Long id, String name)throws Exception {
|
||||||
return materialPropertyService.checkIsNameExist(id, name);
|
return materialPropertyService.checkIsNameExist(id, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,13 @@ package com.jsh.erp.service.materialProperty;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.jsh.erp.constants.BusinessConstants;
|
import com.jsh.erp.constants.BusinessConstants;
|
||||||
|
import com.jsh.erp.constants.ExceptionConstants;
|
||||||
import com.jsh.erp.datasource.entities.MaterialProperty;
|
import com.jsh.erp.datasource.entities.MaterialProperty;
|
||||||
import com.jsh.erp.datasource.entities.MaterialPropertyExample;
|
import com.jsh.erp.datasource.entities.MaterialPropertyExample;
|
||||||
import com.jsh.erp.datasource.entities.User;
|
import com.jsh.erp.datasource.entities.User;
|
||||||
import com.jsh.erp.datasource.mappers.MaterialPropertyMapper;
|
import com.jsh.erp.datasource.mappers.MaterialPropertyMapper;
|
||||||
import com.jsh.erp.datasource.mappers.MaterialPropertyMapperEx;
|
import com.jsh.erp.datasource.mappers.MaterialPropertyMapperEx;
|
||||||
|
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||||
import com.jsh.erp.service.log.LogService;
|
import com.jsh.erp.service.log.LogService;
|
||||||
import com.jsh.erp.service.user.UserService;
|
import com.jsh.erp.service.user.UserService;
|
||||||
import com.jsh.erp.utils.StringUtil;
|
import com.jsh.erp.utils.StringUtil;
|
||||||
@@ -36,51 +38,123 @@ public class MaterialPropertyService {
|
|||||||
@Resource
|
@Resource
|
||||||
private LogService logService;
|
private LogService logService;
|
||||||
|
|
||||||
public MaterialProperty getMaterialProperty(long id) {
|
public MaterialProperty getMaterialProperty(long id)throws Exception {
|
||||||
return materialPropertyMapper.selectByPrimaryKey(id);
|
MaterialProperty result=null;
|
||||||
|
try{
|
||||||
|
result=materialPropertyMapper.selectByPrimaryKey(id);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MaterialProperty> getMaterialProperty() {
|
public List<MaterialProperty> getMaterialProperty()throws Exception {
|
||||||
MaterialPropertyExample example = new MaterialPropertyExample();
|
MaterialPropertyExample example = new MaterialPropertyExample();
|
||||||
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||||
return materialPropertyMapper.selectByExample(example);
|
List<MaterialProperty> list=null;
|
||||||
|
try{
|
||||||
|
list=materialPropertyMapper.selectByExample(example);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MaterialProperty> select(String name, int offset, int rows) {
|
public List<MaterialProperty> select(String name, int offset, int rows)throws Exception {
|
||||||
return materialPropertyMapperEx.selectByConditionMaterialProperty(name, offset, rows);
|
List<MaterialProperty> list=null;
|
||||||
|
try{
|
||||||
|
list=materialPropertyMapperEx.selectByConditionMaterialProperty(name, offset, rows);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long countMaterialProperty(String name) {
|
public Long countMaterialProperty(String name)throws Exception {
|
||||||
return materialPropertyMapperEx.countsByMaterialProperty(name);
|
Long result=null;
|
||||||
|
try{
|
||||||
|
result=materialPropertyMapperEx.countsByMaterialProperty(name);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_READ_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_READ_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int insertMaterialProperty(String beanJson, HttpServletRequest request) {
|
public int insertMaterialProperty(String beanJson, HttpServletRequest request)throws Exception {
|
||||||
MaterialProperty materialProperty = JSONObject.parseObject(beanJson, MaterialProperty.class);
|
MaterialProperty materialProperty = JSONObject.parseObject(beanJson, MaterialProperty.class);
|
||||||
return materialPropertyMapper.insertSelective(materialProperty);
|
int result=0;
|
||||||
|
try{
|
||||||
|
result=materialPropertyMapper.insertSelective(materialProperty);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int updateMaterialProperty(String beanJson, Long id) {
|
public int updateMaterialProperty(String beanJson, Long id)throws Exception {
|
||||||
MaterialProperty materialProperty = JSONObject.parseObject(beanJson, MaterialProperty.class);
|
MaterialProperty materialProperty = JSONObject.parseObject(beanJson, MaterialProperty.class);
|
||||||
materialProperty.setId(id);
|
materialProperty.setId(id);
|
||||||
return materialPropertyMapper.updateByPrimaryKeySelective(materialProperty);
|
int result=0;
|
||||||
|
try{
|
||||||
|
result=materialPropertyMapper.updateByPrimaryKeySelective(materialProperty);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int deleteMaterialProperty(Long id) {
|
public int deleteMaterialProperty(Long id)throws Exception {
|
||||||
return materialPropertyMapper.deleteByPrimaryKey(id);
|
int result=0;
|
||||||
|
try{
|
||||||
|
result=materialPropertyMapper.deleteByPrimaryKey(id);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
public int batchDeleteMaterialProperty(String ids) {
|
public int batchDeleteMaterialProperty(String ids)throws Exception {
|
||||||
List<Long> idList = StringUtil.strToLongList(ids);
|
List<Long> idList = StringUtil.strToLongList(ids);
|
||||||
MaterialPropertyExample example = new MaterialPropertyExample();
|
MaterialPropertyExample example = new MaterialPropertyExample();
|
||||||
example.createCriteria().andIdIn(idList);
|
example.createCriteria().andIdIn(idList);
|
||||||
return materialPropertyMapper.deleteByExample(example);
|
int result=0;
|
||||||
|
try{
|
||||||
|
result=materialPropertyMapper.deleteByExample(example);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int checkIsNameExist(Long id, String name) {
|
public int checkIsNameExist(Long id, String name)throws Exception {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
@@ -90,7 +164,16 @@ public class MaterialPropertyService {
|
|||||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||||
User userInfo=userService.getCurrentUser();
|
User userInfo=userService.getCurrentUser();
|
||||||
String [] idArray=ids.split(",");
|
String [] idArray=ids.split(",");
|
||||||
return materialPropertyMapperEx.batchDeleteMaterialPropertyByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
|
int result=0;
|
||||||
|
try{
|
||||||
|
result=materialPropertyMapperEx.batchDeleteMaterialPropertyByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_CODE,ExceptionConstants.DATA_WRITE_FAIL_MSG,e);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.DATA_WRITE_FAIL_CODE,
|
||||||
|
ExceptionConstants.DATA_WRITE_FAIL_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user