Commit 85d96bb2 authored by cjl's avatar cjl
Browse files

添加事务控制

parent 5df1748c
...@@ -8,6 +8,7 @@ import com.jsh.erp.utils.StringUtil; ...@@ -8,6 +8,7 @@ import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -37,21 +38,25 @@ public class SupplierService { ...@@ -37,21 +38,25 @@ public class SupplierService {
return supplierMapper.countsBySupplier(supplier, type, phonenum, telephone, description); return supplierMapper.countsBySupplier(supplier, type, phonenum, telephone, description);
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertSupplier(String beanJson, HttpServletRequest request) { public int insertSupplier(String beanJson, HttpServletRequest request) {
Supplier supplier = JSONObject.parseObject(beanJson, Supplier.class); Supplier supplier = JSONObject.parseObject(beanJson, Supplier.class);
return supplierMapper.insertSelective(supplier); return supplierMapper.insertSelective(supplier);
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateSupplier(String beanJson, Long id) { public int updateSupplier(String beanJson, Long id) {
Supplier supplier = JSONObject.parseObject(beanJson, Supplier.class); Supplier supplier = JSONObject.parseObject(beanJson, Supplier.class);
supplier.setId(id); supplier.setId(id);
return supplierMapper.updateByPrimaryKeySelective(supplier); return supplierMapper.updateByPrimaryKeySelective(supplier);
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteSupplier(Long id) { public int deleteSupplier(Long id) {
return supplierMapper.deleteByPrimaryKey(id); return supplierMapper.deleteByPrimaryKey(id);
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteSupplier(String ids) { public int batchDeleteSupplier(String ids) {
List<Long> idList = StringUtil.strToLongList(ids); List<Long> idList = StringUtil.strToLongList(ids);
SupplierExample example = new SupplierExample(); SupplierExample example = new SupplierExample();
...@@ -66,6 +71,7 @@ public class SupplierService { ...@@ -66,6 +71,7 @@ public class SupplierService {
return list.size(); return list.size();
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateAdvanceIn(Long supplierId, Double advanceIn){ public int updateAdvanceIn(Long supplierId, Double advanceIn){
Supplier supplier = supplierMapper.selectByPrimaryKey(supplierId); Supplier supplier = supplierMapper.selectByPrimaryKey(supplierId);
supplier.setAdvancein(supplier.getAdvancein() + advanceIn); //增加预收款的金额,可能增加的是负值 supplier.setAdvancein(supplier.getAdvancein() + advanceIn); //增加预收款的金额,可能增加的是负值
...@@ -100,6 +106,7 @@ public class SupplierService { ...@@ -100,6 +106,7 @@ public class SupplierService {
return supplierMapper.selectByExample(example); return supplierMapper.selectByExample(example);
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchSetEnable(Boolean enabled, String supplierIDs) { public int batchSetEnable(Boolean enabled, String supplierIDs) {
List<Long> ids = StringUtil.strToLongList(supplierIDs); List<Long> ids = StringUtil.strToLongList(supplierIDs);
Supplier supplier = new Supplier(); Supplier supplier = new Supplier();
......
...@@ -8,6 +8,7 @@ import com.jsh.erp.utils.StringUtil; ...@@ -8,6 +8,7 @@ import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -36,21 +37,25 @@ public class SystemConfigService { ...@@ -36,21 +37,25 @@ public class SystemConfigService {
return systemConfigMapper.countsBySystemConfig(); return systemConfigMapper.countsBySystemConfig();
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertSystemConfig(String beanJson, HttpServletRequest request) { public int insertSystemConfig(String beanJson, HttpServletRequest request) {
SystemConfig systemConfig = JSONObject.parseObject(beanJson, SystemConfig.class); SystemConfig systemConfig = JSONObject.parseObject(beanJson, SystemConfig.class);
return systemConfigMapper.insertSelective(systemConfig); return systemConfigMapper.insertSelective(systemConfig);
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateSystemConfig(String beanJson, Long id) { public int updateSystemConfig(String beanJson, Long id) {
SystemConfig systemConfig = JSONObject.parseObject(beanJson, SystemConfig.class); SystemConfig systemConfig = JSONObject.parseObject(beanJson, SystemConfig.class);
systemConfig.setId(id); systemConfig.setId(id);
return systemConfigMapper.updateByPrimaryKeySelective(systemConfig); return systemConfigMapper.updateByPrimaryKeySelective(systemConfig);
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteSystemConfig(Long id) { public int deleteSystemConfig(Long id) {
return systemConfigMapper.deleteByPrimaryKey(id); return systemConfigMapper.deleteByPrimaryKey(id);
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteSystemConfig(String ids) { public int batchDeleteSystemConfig(String ids) {
List<Long> idList = StringUtil.strToLongList(ids); List<Long> idList = StringUtil.strToLongList(ids);
SystemConfigExample example = new SystemConfigExample(); SystemConfigExample example = new SystemConfigExample();
......
...@@ -8,6 +8,7 @@ import com.jsh.erp.utils.StringUtil; ...@@ -8,6 +8,7 @@ import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -37,21 +38,25 @@ public class UnitService { ...@@ -37,21 +38,25 @@ public class UnitService {
return unitMapper.countsByUnit(name); return unitMapper.countsByUnit(name);
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertUnit(String beanJson, HttpServletRequest request) { public int insertUnit(String beanJson, HttpServletRequest request) {
Unit unit = JSONObject.parseObject(beanJson, Unit.class); Unit unit = JSONObject.parseObject(beanJson, Unit.class);
return unitMapper.insertSelective(unit); return unitMapper.insertSelective(unit);
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateUnit(String beanJson, Long id) { public int updateUnit(String beanJson, Long id) {
Unit unit = JSONObject.parseObject(beanJson, Unit.class); Unit unit = JSONObject.parseObject(beanJson, Unit.class);
unit.setId(id); unit.setId(id);
return unitMapper.updateByPrimaryKeySelective(unit); return unitMapper.updateByPrimaryKeySelective(unit);
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteUnit(Long id) { public int deleteUnit(Long id) {
return unitMapper.deleteByPrimaryKey(id); return unitMapper.deleteByPrimaryKey(id);
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteUnit(String ids) { public int batchDeleteUnit(String ids) {
List<Long> idList = StringUtil.strToLongList(ids); List<Long> idList = StringUtil.strToLongList(ids);
UnitExample example = new UnitExample(); UnitExample example = new UnitExample();
......
...@@ -9,6 +9,7 @@ import com.jsh.erp.utils.*; ...@@ -9,6 +9,7 @@ import com.jsh.erp.utils.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -38,7 +39,16 @@ public class UserService { ...@@ -38,7 +39,16 @@ public class UserService {
public int countUser(String userName, String loginName) { public int countUser(String userName, String loginName) {
return userMapper.countsByUser(userName, loginName); return userMapper.countsByUser(userName, loginName);
} }
/**
* create by: cjl
* description:
* 添加事务控制
* create time: 2019/1/11 14:30
* @Param: beanJson
 * @Param: request
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertUser(String beanJson, HttpServletRequest request) { public int insertUser(String beanJson, HttpServletRequest request) {
User user = JSONObject.parseObject(beanJson, User.class); User user = JSONObject.parseObject(beanJson, User.class);
String password = "123456"; String password = "123456";
...@@ -52,17 +62,43 @@ public class UserService { ...@@ -52,17 +62,43 @@ public class UserService {
} }
return userMapper.insertSelective(user); return userMapper.insertSelective(user);
} }
/**
* create by: cjl
* description:
* 添加事务控制
* create time: 2019/1/11 14:31
* @Param: beanJson
 * @Param: id
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateUser(String beanJson, Long id) { public int updateUser(String beanJson, Long id) {
User user = JSONObject.parseObject(beanJson, User.class); User user = JSONObject.parseObject(beanJson, User.class);
user.setId(id); user.setId(id);
return userMapper.updateByPrimaryKeySelective(user); return userMapper.updateByPrimaryKeySelective(user);
} }
/**
* create by: cjl
* description:
* 添加事务控制
* create time: 2019/1/11 14:32
* @Param: user
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateUserByObj(User user) { public int updateUserByObj(User user) {
return userMapper.updateByPrimaryKeySelective(user); return userMapper.updateByPrimaryKeySelective(user);
} }
/**
* create by: cjl
* description:
* 添加事务控制
* create time: 2019/1/11 14:33
* @Param: md5Pwd
 * @Param: id
* @return int
*/
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int resetPwd(String md5Pwd, Long id) { public int resetPwd(String md5Pwd, Long id) {
User user = new User(); User user = new User();
user.setId(id); user.setId(id);
...@@ -70,10 +106,12 @@ public class UserService { ...@@ -70,10 +106,12 @@ public class UserService {
return userMapper.updateByPrimaryKeySelective(user); return userMapper.updateByPrimaryKeySelective(user);
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteUser(Long id) { public int deleteUser(Long id) {
return userMapper.deleteByPrimaryKey(id); return userMapper.deleteByPrimaryKey(id);
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteUser(String ids) { public int batchDeleteUser(String ids) {
List<Long> idList = StringUtil.strToLongList(ids); List<Long> idList = StringUtil.strToLongList(ids);
UserExample example = new UserExample(); UserExample example = new UserExample();
......
...@@ -8,6 +8,7 @@ import com.jsh.erp.utils.StringUtil; ...@@ -8,6 +8,7 @@ import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -29,21 +30,25 @@ public class UserBusinessService { ...@@ -29,21 +30,25 @@ public class UserBusinessService {
return userBusinessMapper.selectByExample(example); return userBusinessMapper.selectByExample(example);
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertUserBusiness(String beanJson, HttpServletRequest request) { public int insertUserBusiness(String beanJson, HttpServletRequest request) {
UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class); UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class);
return userBusinessMapper.insertSelective(userBusiness); return userBusinessMapper.insertSelective(userBusiness);
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateUserBusiness(String beanJson, Long id) { public int updateUserBusiness(String beanJson, Long id) {
UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class); UserBusiness userBusiness = JSONObject.parseObject(beanJson, UserBusiness.class);
userBusiness.setId(id); userBusiness.setId(id);
return userBusinessMapper.updateByPrimaryKeySelective(userBusiness); return userBusinessMapper.updateByPrimaryKeySelective(userBusiness);
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int deleteUserBusiness(Long id) { public int deleteUserBusiness(Long id) {
return userBusinessMapper.deleteByPrimaryKey(id); return userBusinessMapper.deleteByPrimaryKey(id);
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteUserBusiness(String ids) { public int batchDeleteUserBusiness(String ids) {
List<Long> idList = StringUtil.strToLongList(ids); List<Long> idList = StringUtil.strToLongList(ids);
UserBusinessExample example = new UserBusinessExample(); UserBusinessExample example = new UserBusinessExample();
...@@ -89,6 +94,7 @@ public class UserBusinessService { ...@@ -89,6 +94,7 @@ public class UserBusinessService {
} }
} }
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int updateBtnStr(Long userBusinessId, String btnStr) { public int updateBtnStr(Long userBusinessId, String btnStr) {
UserBusiness userBusiness = new UserBusiness(); UserBusiness userBusiness = new UserBusiness();
userBusiness.setBtnstr(btnStr); userBusiness.setBtnstr(btnStr);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment