更新后端,采用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,68 @@
package com.jsh.erp.service.unit;
import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.Unit;
import com.jsh.erp.datasource.entities.UnitExample;
import com.jsh.erp.datasource.mappers.UnitMapper;
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 UnitService {
private Logger logger = LoggerFactory.getLogger(UnitService.class);
@Resource
private UnitMapper unitMapper;
public Unit getUnit(long id) {
return unitMapper.selectByPrimaryKey(id);
}
public List<Unit> getUnit() {
UnitExample example = new UnitExample();
return unitMapper.selectByExample(example);
}
public List<Unit> select(String name, int offset, int rows) {
return unitMapper.selectByConditionUnit(name, offset, rows);
}
public int countUnit(String name) {
return unitMapper.countsByUnit(name);
}
public int insertUnit(String beanJson, HttpServletRequest request) {
Unit unit = JSONObject.parseObject(beanJson, Unit.class);
return unitMapper.insertSelective(unit);
}
public int updateUnit(String beanJson, Long id) {
Unit unit = JSONObject.parseObject(beanJson, Unit.class);
unit.setId(id);
return unitMapper.updateByPrimaryKeySelective(unit);
}
public int deleteUnit(Long id) {
return unitMapper.deleteByPrimaryKey(id);
}
public int batchDeleteUnit(String ids) {
List<Long> idList = StringUtil.strToLongList(ids);
UnitExample example = new UnitExample();
example.createCriteria().andIdIn(idList);
return unitMapper.deleteByExample(example);
}
public int checkIsNameExist(Long id, String name) {
UnitExample example = new UnitExample();
example.createCriteria().andIdNotEqualTo(id).andUnameEqualTo(name);
List<Unit> list = unitMapper.selectByExample(example);
return list.size();
}
}