Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
JSH ERP
Commits
85d96bb2
Commit
85d96bb2
authored
Jan 11, 2019
by
cjl
Browse files
添加事务控制
parent
5df1748c
Changes
25
Show whitespace changes
Inline
Side-by-side
src/main/java/com/jsh/erp/service/supplier/SupplierService.java
View file @
85d96bb2
...
...
@@ -8,6 +8,7 @@ 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
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -37,21 +38,25 @@ public class SupplierService {
return
supplierMapper
.
countsBySupplier
(
supplier
,
type
,
phonenum
,
telephone
,
description
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
insertSupplier
(
String
beanJson
,
HttpServletRequest
request
)
{
Supplier
supplier
=
JSONObject
.
parseObject
(
beanJson
,
Supplier
.
class
);
return
supplierMapper
.
insertSelective
(
supplier
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
updateSupplier
(
String
beanJson
,
Long
id
)
{
Supplier
supplier
=
JSONObject
.
parseObject
(
beanJson
,
Supplier
.
class
);
supplier
.
setId
(
id
);
return
supplierMapper
.
updateByPrimaryKeySelective
(
supplier
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
deleteSupplier
(
Long
id
)
{
return
supplierMapper
.
deleteByPrimaryKey
(
id
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteSupplier
(
String
ids
)
{
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
SupplierExample
example
=
new
SupplierExample
();
...
...
@@ -66,6 +71,7 @@ public class SupplierService {
return
list
.
size
();
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
updateAdvanceIn
(
Long
supplierId
,
Double
advanceIn
){
Supplier
supplier
=
supplierMapper
.
selectByPrimaryKey
(
supplierId
);
supplier
.
setAdvancein
(
supplier
.
getAdvancein
()
+
advanceIn
);
//增加预收款的金额,可能增加的是负值
...
...
@@ -100,6 +106,7 @@ public class SupplierService {
return
supplierMapper
.
selectByExample
(
example
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchSetEnable
(
Boolean
enabled
,
String
supplierIDs
)
{
List
<
Long
>
ids
=
StringUtil
.
strToLongList
(
supplierIDs
);
Supplier
supplier
=
new
Supplier
();
...
...
src/main/java/com/jsh/erp/service/systemConfig/SystemConfigService.java
View file @
85d96bb2
...
...
@@ -8,6 +8,7 @@ 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
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -36,21 +37,25 @@ public class SystemConfigService {
return
systemConfigMapper
.
countsBySystemConfig
();
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
insertSystemConfig
(
String
beanJson
,
HttpServletRequest
request
)
{
SystemConfig
systemConfig
=
JSONObject
.
parseObject
(
beanJson
,
SystemConfig
.
class
);
return
systemConfigMapper
.
insertSelective
(
systemConfig
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
updateSystemConfig
(
String
beanJson
,
Long
id
)
{
SystemConfig
systemConfig
=
JSONObject
.
parseObject
(
beanJson
,
SystemConfig
.
class
);
systemConfig
.
setId
(
id
);
return
systemConfigMapper
.
updateByPrimaryKeySelective
(
systemConfig
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
deleteSystemConfig
(
Long
id
)
{
return
systemConfigMapper
.
deleteByPrimaryKey
(
id
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteSystemConfig
(
String
ids
)
{
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
SystemConfigExample
example
=
new
SystemConfigExample
();
...
...
src/main/java/com/jsh/erp/service/unit/UnitService.java
View file @
85d96bb2
...
...
@@ -8,6 +8,7 @@ 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
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -37,21 +38,25 @@ public class UnitService {
return
unitMapper
.
countsByUnit
(
name
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
insertUnit
(
String
beanJson
,
HttpServletRequest
request
)
{
Unit
unit
=
JSONObject
.
parseObject
(
beanJson
,
Unit
.
class
);
return
unitMapper
.
insertSelective
(
unit
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
updateUnit
(
String
beanJson
,
Long
id
)
{
Unit
unit
=
JSONObject
.
parseObject
(
beanJson
,
Unit
.
class
);
unit
.
setId
(
id
);
return
unitMapper
.
updateByPrimaryKeySelective
(
unit
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
deleteUnit
(
Long
id
)
{
return
unitMapper
.
deleteByPrimaryKey
(
id
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteUnit
(
String
ids
)
{
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
UnitExample
example
=
new
UnitExample
();
...
...
src/main/java/com/jsh/erp/service/user/UserService.java
View file @
85d96bb2
...
...
@@ -9,6 +9,7 @@ import com.jsh.erp.utils.*;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -38,7 +39,16 @@ public class UserService {
public
int
countUser
(
String
userName
,
String
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
)
{
User
user
=
JSONObject
.
parseObject
(
beanJson
,
User
.
class
);
String
password
=
"123456"
;
...
...
@@ -52,17 +62,43 @@ public class UserService {
}
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
)
{
User
user
=
JSONObject
.
parseObject
(
beanJson
,
User
.
class
);
user
.
setId
(
id
);
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
)
{
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
)
{
User
user
=
new
User
();
user
.
setId
(
id
);
...
...
@@ -70,10 +106,12 @@ public class UserService {
return
userMapper
.
updateByPrimaryKeySelective
(
user
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
deleteUser
(
Long
id
)
{
return
userMapper
.
deleteByPrimaryKey
(
id
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteUser
(
String
ids
)
{
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
UserExample
example
=
new
UserExample
();
...
...
src/main/java/com/jsh/erp/service/userBusiness/UserBusinessService.java
View file @
85d96bb2
...
...
@@ -8,6 +8,7 @@ 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
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -29,21 +30,25 @@ public class UserBusinessService {
return
userBusinessMapper
.
selectByExample
(
example
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
insertUserBusiness
(
String
beanJson
,
HttpServletRequest
request
)
{
UserBusiness
userBusiness
=
JSONObject
.
parseObject
(
beanJson
,
UserBusiness
.
class
);
return
userBusinessMapper
.
insertSelective
(
userBusiness
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
updateUserBusiness
(
String
beanJson
,
Long
id
)
{
UserBusiness
userBusiness
=
JSONObject
.
parseObject
(
beanJson
,
UserBusiness
.
class
);
userBusiness
.
setId
(
id
);
return
userBusinessMapper
.
updateByPrimaryKeySelective
(
userBusiness
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
deleteUserBusiness
(
Long
id
)
{
return
userBusinessMapper
.
deleteByPrimaryKey
(
id
);
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteUserBusiness
(
String
ids
)
{
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
UserBusinessExample
example
=
new
UserBusinessExample
();
...
...
@@ -89,6 +94,7 @@ public class UserBusinessService {
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
updateBtnStr
(
Long
userBusinessId
,
String
btnStr
)
{
UserBusiness
userBusiness
=
new
UserBusiness
();
userBusiness
.
setBtnstr
(
btnStr
);
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment