vue版本上线
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
package com.jsh.erp.service.materialProperty;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.service.ICommonQuery;
|
||||
import com.jsh.erp.utils.Constants;
|
||||
import com.jsh.erp.utils.QueryUtils;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service(value = "materialProperty_component")
|
||||
@MaterialPropertyResource
|
||||
public class MaterialPropertyComponent implements ICommonQuery {
|
||||
|
||||
@Resource
|
||||
private MaterialPropertyService materialPropertyService;
|
||||
|
||||
@Override
|
||||
public Object selectOne(Long id) throws Exception {
|
||||
return materialPropertyService.getMaterialProperty(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<?> select(Map<String, String> map)throws Exception {
|
||||
return getMaterialPropertyList(map);
|
||||
}
|
||||
|
||||
private List<?> getMaterialPropertyList(Map<String, String> map)throws Exception {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
String order = QueryUtils.order(map);
|
||||
return materialPropertyService.select(name, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long counts(Map<String, String> map)throws Exception {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
return materialPropertyService.countMaterialProperty(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(JSONObject obj, HttpServletRequest request)throws Exception {
|
||||
return materialPropertyService.insertMaterialProperty(obj, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(JSONObject obj, HttpServletRequest request)throws Exception {
|
||||
return materialPropertyService.updateMaterialProperty(obj, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id, HttpServletRequest request)throws Exception {
|
||||
return materialPropertyService.deleteMaterialProperty(id, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteBatch(String ids, HttpServletRequest request)throws Exception {
|
||||
return materialPropertyService.batchDeleteMaterialProperty(ids, request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkIsNameExist(Long id, String name)throws Exception {
|
||||
return materialPropertyService.checkIsNameExist(id, name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.jsh.erp.service.materialProperty;
|
||||
|
||||
import com.jsh.erp.service.ResourceInfo;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author jishenghua qq752718920 2018-10-7 15:26:27
|
||||
*/
|
||||
@ResourceInfo(value = "materialProperty")
|
||||
@Inherited
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface MaterialPropertyResource {
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
package com.jsh.erp.service.materialProperty;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.MaterialPropertyExample;
|
||||
import com.jsh.erp.datasource.entities.User;
|
||||
import com.jsh.erp.datasource.mappers.MaterialPropertyMapper;
|
||||
import com.jsh.erp.datasource.mappers.MaterialPropertyMapperEx;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.exception.JshException;
|
||||
import com.jsh.erp.service.log.LogService;
|
||||
import com.jsh.erp.service.user.UserService;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class MaterialPropertyService {
|
||||
private Logger logger = LoggerFactory.getLogger(MaterialPropertyService.class);
|
||||
|
||||
@Resource
|
||||
private MaterialPropertyMapper materialPropertyMapper;
|
||||
|
||||
@Resource
|
||||
private MaterialPropertyMapperEx materialPropertyMapperEx;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private LogService logService;
|
||||
|
||||
public MaterialProperty getMaterialProperty(long id)throws Exception {
|
||||
MaterialProperty result=null;
|
||||
try{
|
||||
result=materialPropertyMapper.selectByPrimaryKey(id);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<MaterialProperty> getMaterialProperty()throws Exception {
|
||||
MaterialPropertyExample example = new MaterialPropertyExample();
|
||||
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||
List<MaterialProperty> list=null;
|
||||
try{
|
||||
list=materialPropertyMapper.selectByExample(example);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<MaterialProperty> select(String name, int offset, int rows)throws Exception {
|
||||
List<MaterialProperty> list=null;
|
||||
try{
|
||||
list=materialPropertyMapperEx.selectByConditionMaterialProperty(name, offset, rows);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public Long countMaterialProperty(String name)throws Exception {
|
||||
Long result=null;
|
||||
try{
|
||||
result=materialPropertyMapperEx.countsByMaterialProperty(name);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int insertMaterialProperty(JSONObject obj, HttpServletRequest request)throws Exception {
|
||||
MaterialProperty materialProperty = JSONObject.parseObject(obj.toJSONString(), MaterialProperty.class);
|
||||
int result=0;
|
||||
try{
|
||||
result=materialPropertyMapper.insertSelective(materialProperty);
|
||||
logService.insertLog("商品属性",
|
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(materialProperty.getNativeName()).toString(), request);
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int updateMaterialProperty(JSONObject obj, HttpServletRequest request)throws Exception {
|
||||
MaterialProperty materialProperty = JSONObject.parseObject(obj.toJSONString(), MaterialProperty.class);
|
||||
int result=0;
|
||||
try{
|
||||
result=materialPropertyMapper.updateByPrimaryKeySelective(materialProperty);
|
||||
logService.insertLog("商品属性",
|
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(materialProperty.getNativeName()).toString(), request);
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int deleteMaterialProperty(Long id, HttpServletRequest request)throws Exception {
|
||||
return batchDeleteMaterialPropertyByIds(id.toString());
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int batchDeleteMaterialProperty(String ids, HttpServletRequest request)throws Exception {
|
||||
return batchDeleteMaterialPropertyByIds(ids);
|
||||
}
|
||||
|
||||
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||
public int batchDeleteMaterialPropertyByIds(String ids) throws Exception{
|
||||
logService.insertLog("商品属性",
|
||||
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_DELETE).append(ids).toString(),
|
||||
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
|
||||
User userInfo=userService.getCurrentUser();
|
||||
String [] idArray=ids.split(",");
|
||||
int result=0;
|
||||
try{
|
||||
result=materialPropertyMapperEx.batchDeleteMaterialPropertyByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
|
||||
}catch(Exception e){
|
||||
JshException.writeFail(logger, e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int checkIsNameExist(Long id, String name)throws Exception {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user