更新后端,采用Springboot+mybatis

This commit is contained in:
季圣华
2018-12-19 23:54:53 +08:00
parent bb6f5528a7
commit 5cc26a22f2
1672 changed files with 52804 additions and 156085 deletions

View File

@@ -0,0 +1,80 @@
package com.jsh.erp.service.supplier;
import com.jsh.erp.service.ICommonQuery;
import com.jsh.erp.service.depot.DepotResource;
import com.jsh.erp.service.depot.DepotService;
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 = "supplier_component")
@SupplierResource
public class SupplierComponent implements ICommonQuery {
@Resource
private SupplierService supplierService;
@Override
public Object selectOne(String condition) {
return null;
}
@Override
public List<?> select(Map<String, String> map) {
return getSupplierList(map);
}
private List<?> getSupplierList(Map<String, String> map) {
String search = map.get(Constants.SEARCH);
String supplier = StringUtil.getInfo(search, "supplier");
String type = StringUtil.getInfo(search, "type");
String phonenum = StringUtil.getInfo(search, "phonenum");
String telephone = StringUtil.getInfo(search, "telephone");
String description = StringUtil.getInfo(search, "description");
String order = QueryUtils.order(map);
return supplierService.select(supplier, type, phonenum, telephone, description, QueryUtils.offset(map), QueryUtils.rows(map));
}
@Override
public int counts(Map<String, String> map) {
String search = map.get(Constants.SEARCH);
String supplier = StringUtil.getInfo(search, "supplier");
String type = StringUtil.getInfo(search, "type");
String phonenum = StringUtil.getInfo(search, "phonenum");
String telephone = StringUtil.getInfo(search, "telephone");
String description = StringUtil.getInfo(search, "description");
return supplierService.countSupplier(supplier, type, phonenum, telephone, description);
}
@Override
public int insert(String beanJson, HttpServletRequest request) {
return supplierService.insertSupplier(beanJson, request);
}
@Override
public int update(String beanJson, Long id) {
return supplierService.updateSupplier(beanJson, id);
}
@Override
public int delete(Long id) {
return supplierService.deleteSupplier(id);
}
@Override
public int batchDelete(String ids) {
return supplierService.batchDeleteSupplier(ids);
}
@Override
public int checkIsNameExist(Long id, String name) {
return supplierService.checkIsNameExist(id, name);
}
}

View File

@@ -0,0 +1,15 @@
package com.jsh.erp.service.supplier;
import com.jsh.erp.service.ResourceInfo;
import java.lang.annotation.*;
/**
* @author jishenghua qq752718920 2018-10-7 15:26:27
*/
@ResourceInfo(value = "supplier", type = 70)
@Inherited
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface SupplierResource {
}

View File

@@ -0,0 +1,102 @@
package com.jsh.erp.service.supplier;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Supplier;
import com.jsh.erp.datasource.entities.SupplierExample;
import com.jsh.erp.datasource.mappers.SupplierMapper;
import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@Service
public class SupplierService {
private Logger logger = LoggerFactory.getLogger(SupplierService.class);
@Resource
private SupplierMapper supplierMapper;
public Supplier getSupplier(long id) {
return supplierMapper.selectByPrimaryKey(id);
}
public List<Supplier> getSupplier() {
SupplierExample example = new SupplierExample();
return supplierMapper.selectByExample(example);
}
public List<Supplier> select(String supplier, String type, String phonenum, String telephone, String description, int offset, int rows) {
return supplierMapper.selectByConditionSupplier(supplier, type, phonenum, telephone, description, offset, rows);
}
public int countSupplier(String supplier, String type, String phonenum, String telephone, String description) {
return supplierMapper.countsBySupplier(supplier, type, phonenum, telephone, description);
}
public int insertSupplier(String beanJson, HttpServletRequest request) {
Supplier supplier = JSONObject.parseObject(beanJson, Supplier.class);
return supplierMapper.insertSelective(supplier);
}
public int updateSupplier(String beanJson, Long id) {
Supplier supplier = JSONObject.parseObject(beanJson, Supplier.class);
supplier.setId(id);
return supplierMapper.updateByPrimaryKeySelective(supplier);
}
public int deleteSupplier(Long id) {
return supplierMapper.deleteByPrimaryKey(id);
}
public int batchDeleteSupplier(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
SupplierExample example = new SupplierExample();
example.createCriteria().andIdIn(idList);
return supplierMapper.deleteByExample(example);
}
public int checkIsNameExist(Long id, String name) {
SupplierExample example = new SupplierExample();
example.createCriteria().andIdNotEqualTo(id).andSupplierEqualTo(name);
List<Supplier> list = supplierMapper.selectByExample(example);
return list.size();
}
public int updateAdvanceIn(Long supplierId, Double advanceIn){
Supplier supplier = supplierMapper.selectByPrimaryKey(supplierId);
supplier.setAdvancein(supplier.getAdvancein() + advanceIn); //增加预收款的金额,可能增加的是负值
return supplierMapper.updateByPrimaryKeySelective(supplier);
}
public List<Supplier> findBySelectCus() {
SupplierExample example = new SupplierExample();
example.createCriteria().andTypeLike("客户").andEnabledEqualTo(true);
example.setOrderByClause("id desc");
return supplierMapper.selectByExample(example);
}
public List<Supplier> findBySelectSup() {
SupplierExample example = new SupplierExample();
example.createCriteria().andTypeLike("供应商").andEnabledEqualTo(true);
example.setOrderByClause("id desc");
return supplierMapper.selectByExample(example);
}
public List<Supplier> findBySelectRetail() {
SupplierExample example = new SupplierExample();
example.createCriteria().andTypeLike("会员").andEnabledEqualTo(true);
example.setOrderByClause("id desc");
return supplierMapper.selectByExample(example);
}
public List<Supplier> findById(Long supplierId) {
SupplierExample example = new SupplierExample();
example.createCriteria().andIdEqualTo(supplierId);
example.setOrderByClause("id desc");
return supplierMapper.selectByExample(example);
}
}