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
Hide whitespace changes
Inline
Side-by-side
src/main/java/com/jsh/erp/service/supplier/SupplierService.java
View file @
85d96bb2
package
com.jsh.erp.service.supplier
;
package
com.jsh.erp.service.supplier
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.datasource.entities.Supplier
;
import
com.jsh.erp.datasource.entities.Supplier
;
import
com.jsh.erp.datasource.entities.SupplierExample
;
import
com.jsh.erp.datasource.entities.SupplierExample
;
import
com.jsh.erp.datasource.mappers.SupplierMapper
;
import
com.jsh.erp.datasource.mappers.SupplierMapper
;
import
com.jsh.erp.utils.StringUtil
;
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.servlet.http.HttpServletRequest
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
@Service
public
class
SupplierService
{
@Service
private
Logger
logger
=
LoggerFactory
.
getLogger
(
SupplierService
.
class
);
public
class
SupplierService
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
SupplierService
.
class
);
@Resource
private
SupplierMapper
supplierMapper
;
@Resource
private
SupplierMapper
supplierMapper
;
public
Supplier
getSupplier
(
long
id
)
{
return
supplierMapper
.
selectByPrimaryKey
(
id
);
public
Supplier
getSupplier
(
long
id
)
{
}
return
supplierMapper
.
selectByPrimaryKey
(
id
);
}
public
List
<
Supplier
>
getSupplier
()
{
SupplierExample
example
=
new
SupplierExample
();
public
List
<
Supplier
>
getSupplier
()
{
return
supplierMapper
.
selectByExample
(
example
);
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
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
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
);
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
return
supplierMapper
.
insertSelective
(
supplier
);
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
);
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
return
supplierMapper
.
updateByPrimaryKeySelective
(
supplier
);
public
int
updateSupplier
(
String
beanJson
,
Long
id
)
{
}
Supplier
supplier
=
JSONObject
.
parseObject
(
beanJson
,
Supplier
.
class
);
supplier
.
setId
(
id
);
public
int
deleteSupplier
(
Long
id
)
{
return
supplierMapper
.
updateByPrimaryKeySelective
(
supplier
);
return
supplierMapper
.
deleteByPrimaryKey
(
id
);
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteSupplier
(
String
ids
)
{
public
int
deleteSupplier
(
Long
id
)
{
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
return
supplierMapper
.
deleteByPrimaryKey
(
id
);
SupplierExample
example
=
new
SupplierExample
();
}
example
.
createCriteria
().
andIdIn
(
idList
);
return
supplierMapper
.
deleteByExample
(
example
);
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
}
public
int
batchDeleteSupplier
(
String
ids
)
{
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
public
int
checkIsNameExist
(
Long
id
,
String
name
)
{
SupplierExample
example
=
new
SupplierExample
();
SupplierExample
example
=
new
SupplierExample
();
example
.
createCriteria
().
andIdIn
(
idList
);
example
.
createCriteria
().
andIdNotEqualTo
(
id
).
andSupplierEqualTo
(
name
);
return
supplierMapper
.
deleteByExample
(
example
);
List
<
Supplier
>
list
=
supplierMapper
.
selectByExample
(
example
);
}
return
list
.
size
();
}
public
int
checkIsNameExist
(
Long
id
,
String
name
)
{
SupplierExample
example
=
new
SupplierExample
();
public
int
updateAdvanceIn
(
Long
supplierId
,
Double
advanceIn
){
example
.
createCriteria
().
andIdNotEqualTo
(
id
).
andSupplierEqualTo
(
name
);
Supplier
supplier
=
supplierMapper
.
selectByPrimaryKey
(
supplierId
);
List
<
Supplier
>
list
=
supplierMapper
.
selectByExample
(
example
);
supplier
.
setAdvancein
(
supplier
.
getAdvancein
()
+
advanceIn
);
//增加预收款的金额,可能增加的是负值
return
list
.
size
();
return
supplierMapper
.
updateByPrimaryKeySelective
(
supplier
);
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
List
<
Supplier
>
findBySelectCus
()
{
public
int
updateAdvanceIn
(
Long
supplierId
,
Double
advanceIn
){
SupplierExample
example
=
new
SupplierExample
();
Supplier
supplier
=
supplierMapper
.
selectByPrimaryKey
(
supplierId
);
example
.
createCriteria
().
andTypeLike
(
"客户"
).
andEnabledEqualTo
(
true
);
supplier
.
setAdvancein
(
supplier
.
getAdvancein
()
+
advanceIn
);
//增加预收款的金额,可能增加的是负值
example
.
setOrderByClause
(
"id desc"
);
return
supplierMapper
.
updateByPrimaryKeySelective
(
supplier
);
return
supplierMapper
.
selectByExample
(
example
);
}
}
public
List
<
Supplier
>
findBySelectCus
()
{
public
List
<
Supplier
>
findBySelectSup
()
{
SupplierExample
example
=
new
SupplierExample
();
SupplierExample
example
=
new
SupplierExample
();
example
.
createCriteria
().
andTypeLike
(
"客户"
).
andEnabledEqualTo
(
true
);
example
.
createCriteria
().
andTypeLike
(
"供应商"
).
andEnabledEqualTo
(
true
);
example
.
setOrderByClause
(
"id desc"
);
example
.
setOrderByClause
(
"id desc"
);
return
supplierMapper
.
selectByExample
(
example
);
return
supplierMapper
.
selectByExample
(
example
);
}
}
public
List
<
Supplier
>
findBySelectSup
()
{
public
List
<
Supplier
>
findBySelectRetail
()
{
SupplierExample
example
=
new
SupplierExample
();
SupplierExample
example
=
new
SupplierExample
();
example
.
createCriteria
().
andTypeLike
(
"供应商"
).
andEnabledEqualTo
(
true
);
example
.
createCriteria
().
andTypeLike
(
"会员"
).
andEnabledEqualTo
(
true
);
example
.
setOrderByClause
(
"id desc"
);
example
.
setOrderByClause
(
"id desc"
);
return
supplierMapper
.
selectByExample
(
example
);
return
supplierMapper
.
selectByExample
(
example
);
}
}
public
List
<
Supplier
>
findBySelectRetail
()
{
public
List
<
Supplier
>
findById
(
Long
supplierId
)
{
SupplierExample
example
=
new
SupplierExample
();
SupplierExample
example
=
new
SupplierExample
();
example
.
createCriteria
().
andTypeLike
(
"会员"
).
andEnabledEqualTo
(
true
);
example
.
createCriteria
().
andIdEqualTo
(
supplierId
);
example
.
setOrderByClause
(
"id desc"
);
example
.
setOrderByClause
(
"id desc"
);
return
supplierMapper
.
selectByExample
(
example
);
return
supplierMapper
.
selectByExample
(
example
);
}
}
public
List
<
Supplier
>
findById
(
Long
supplierId
)
{
public
int
batchSetEnable
(
Boolean
enabled
,
String
supplierIDs
)
{
SupplierExample
example
=
new
SupplierExample
();
List
<
Long
>
ids
=
StringUtil
.
strToLongList
(
supplierIDs
);
example
.
createCriteria
().
andIdEqualTo
(
supplierId
);
Supplier
supplier
=
new
Supplier
();
example
.
setOrderByClause
(
"id desc"
);
supplier
.
setEnabled
(
enabled
);
return
supplierMapper
.
selectByExample
(
example
);
SupplierExample
example
=
new
SupplierExample
();
}
example
.
createCriteria
().
andIdIn
(
ids
);
return
supplierMapper
.
updateByExampleSelective
(
supplier
,
example
);
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
}
public
int
batchSetEnable
(
Boolean
enabled
,
String
supplierIDs
)
{
List
<
Long
>
ids
=
StringUtil
.
strToLongList
(
supplierIDs
);
public
List
<
Supplier
>
findUserCustomer
(){
Supplier
supplier
=
new
Supplier
();
SupplierExample
example
=
new
SupplierExample
();
supplier
.
setEnabled
(
enabled
);
example
.
createCriteria
().
andTypeEqualTo
(
"客户"
);
SupplierExample
example
=
new
SupplierExample
();
example
.
setOrderByClause
(
"id desc"
);
example
.
createCriteria
().
andIdIn
(
ids
);
List
<
Supplier
>
list
=
supplierMapper
.
selectByExample
(
example
);
return
supplierMapper
.
updateByExampleSelective
(
supplier
,
example
);
return
list
;
}
}
}
public
List
<
Supplier
>
findUserCustomer
(){
SupplierExample
example
=
new
SupplierExample
();
example
.
createCriteria
().
andTypeEqualTo
(
"客户"
);
example
.
setOrderByClause
(
"id desc"
);
List
<
Supplier
>
list
=
supplierMapper
.
selectByExample
(
example
);
return
list
;
}
}
src/main/java/com/jsh/erp/service/systemConfig/SystemConfigService.java
View file @
85d96bb2
package
com.jsh.erp.service.systemConfig
;
package
com.jsh.erp.service.systemConfig
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.datasource.entities.SystemConfig
;
import
com.jsh.erp.datasource.entities.SystemConfig
;
import
com.jsh.erp.datasource.entities.SystemConfigExample
;
import
com.jsh.erp.datasource.entities.SystemConfigExample
;
import
com.jsh.erp.datasource.mappers.SystemConfigMapper
;
import
com.jsh.erp.datasource.mappers.SystemConfigMapper
;
import
com.jsh.erp.utils.StringUtil
;
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.servlet.http.HttpServletRequest
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
@Service
public
class
SystemConfigService
{
@Service
private
Logger
logger
=
LoggerFactory
.
getLogger
(
SystemConfigService
.
class
);
public
class
SystemConfigService
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
SystemConfigService
.
class
);
@Resource
private
SystemConfigMapper
systemConfigMapper
;
@Resource
private
SystemConfigMapper
systemConfigMapper
;
public
SystemConfig
getSystemConfig
(
long
id
)
{
return
systemConfigMapper
.
selectByPrimaryKey
(
id
);
public
SystemConfig
getSystemConfig
(
long
id
)
{
}
return
systemConfigMapper
.
selectByPrimaryKey
(
id
);
}
public
List
<
SystemConfig
>
getSystemConfig
()
{
SystemConfigExample
example
=
new
SystemConfigExample
();
public
List
<
SystemConfig
>
getSystemConfig
()
{
return
systemConfigMapper
.
selectByExample
(
example
);
SystemConfigExample
example
=
new
SystemConfigExample
();
}
return
systemConfigMapper
.
selectByExample
(
example
);
public
List
<
SystemConfig
>
select
(
int
offset
,
int
rows
)
{
}
return
systemConfigMapper
.
selectByConditionSystemConfig
(
offset
,
rows
);
public
List
<
SystemConfig
>
select
(
int
offset
,
int
rows
)
{
}
return
systemConfigMapper
.
selectByConditionSystemConfig
(
offset
,
rows
);
}
public
int
countSystemConfig
()
{
return
systemConfigMapper
.
countsBySystemConfig
();
public
int
countSystemConfig
()
{
}
return
systemConfigMapper
.
countsBySystemConfig
();
}
public
int
insertSystemConfig
(
String
beanJson
,
HttpServletRequest
request
)
{
SystemConfig
systemConfig
=
JSONObject
.
parseObject
(
beanJson
,
SystemConfig
.
class
);
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
return
systemConfigMapper
.
insertSelective
(
systemConfig
);
public
int
insertSystemConfig
(
String
beanJson
,
HttpServletRequest
request
)
{
}
SystemConfig
systemConfig
=
JSONObject
.
parseObject
(
beanJson
,
SystemConfig
.
class
);
return
systemConfigMapper
.
insertSelective
(
systemConfig
);
public
int
updateSystemConfig
(
String
beanJson
,
Long
id
)
{
}
SystemConfig
systemConfig
=
JSONObject
.
parseObject
(
beanJson
,
SystemConfig
.
class
);
systemConfig
.
setId
(
id
);
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
return
systemConfigMapper
.
updateByPrimaryKeySelective
(
systemConfig
);
public
int
updateSystemConfig
(
String
beanJson
,
Long
id
)
{
}
SystemConfig
systemConfig
=
JSONObject
.
parseObject
(
beanJson
,
SystemConfig
.
class
);
systemConfig
.
setId
(
id
);
public
int
deleteSystemConfig
(
Long
id
)
{
return
systemConfigMapper
.
updateByPrimaryKeySelective
(
systemConfig
);
return
systemConfigMapper
.
deleteByPrimaryKey
(
id
);
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteSystemConfig
(
String
ids
)
{
public
int
deleteSystemConfig
(
Long
id
)
{
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
return
systemConfigMapper
.
deleteByPrimaryKey
(
id
);
SystemConfigExample
example
=
new
SystemConfigExample
();
}
example
.
createCriteria
().
andIdIn
(
idList
);
return
systemConfigMapper
.
deleteByExample
(
example
);
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
}
public
int
batchDeleteSystemConfig
(
String
ids
)
{
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
public
int
checkIsNameExist
(
Long
id
,
String
name
)
{
SystemConfigExample
example
=
new
SystemConfigExample
();
SystemConfigExample
example
=
new
SystemConfigExample
();
example
.
createCriteria
().
andIdIn
(
idList
);
example
.
createCriteria
().
andIdNotEqualTo
(
id
).
andNameEqualTo
(
name
);
return
systemConfigMapper
.
deleteByExample
(
example
);
List
<
SystemConfig
>
list
=
systemConfigMapper
.
selectByExample
(
example
);
}
return
list
.
size
();
}
public
int
checkIsNameExist
(
Long
id
,
String
name
)
{
}
SystemConfigExample
example
=
new
SystemConfigExample
();
example
.
createCriteria
().
andIdNotEqualTo
(
id
).
andNameEqualTo
(
name
);
List
<
SystemConfig
>
list
=
systemConfigMapper
.
selectByExample
(
example
);
return
list
.
size
();
}
}
src/main/java/com/jsh/erp/service/unit/UnitService.java
View file @
85d96bb2
package
com.jsh.erp.service.unit
;
package
com.jsh.erp.service.unit
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.datasource.entities.Unit
;
import
com.jsh.erp.datasource.entities.Unit
;
import
com.jsh.erp.datasource.entities.UnitExample
;
import
com.jsh.erp.datasource.entities.UnitExample
;
import
com.jsh.erp.datasource.mappers.UnitMapper
;
import
com.jsh.erp.datasource.mappers.UnitMapper
;
import
com.jsh.erp.utils.StringUtil
;
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.servlet.http.HttpServletRequest
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
@Service
public
class
UnitService
{
@Service
private
Logger
logger
=
LoggerFactory
.
getLogger
(
UnitService
.
class
);
public
class
UnitService
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
UnitService
.
class
);
@Resource
private
UnitMapper
unitMapper
;
@Resource
private
UnitMapper
unitMapper
;
public
Unit
getUnit
(
long
id
)
{
return
unitMapper
.
selectByPrimaryKey
(
id
);
public
Unit
getUnit
(
long
id
)
{
}
return
unitMapper
.
selectByPrimaryKey
(
id
);
}
public
List
<
Unit
>
getUnit
()
{
UnitExample
example
=
new
UnitExample
();
public
List
<
Unit
>
getUnit
()
{
return
unitMapper
.
selectByExample
(
example
);
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
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
countUnit
(
String
name
)
{
}
return
unitMapper
.
countsByUnit
(
name
);
}
public
int
insertUnit
(
String
beanJson
,
HttpServletRequest
request
)
{
Unit
unit
=
JSONObject
.
parseObject
(
beanJson
,
Unit
.
class
);
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
return
unitMapper
.
insertSelective
(
unit
);
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
);
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
return
unitMapper
.
updateByPrimaryKeySelective
(
unit
);
public
int
updateUnit
(
String
beanJson
,
Long
id
)
{
}
Unit
unit
=
JSONObject
.
parseObject
(
beanJson
,
Unit
.
class
);
unit
.
setId
(
id
);
public
int
deleteUnit
(
Long
id
)
{
return
unitMapper
.
updateByPrimaryKeySelective
(
unit
);
return
unitMapper
.
deleteByPrimaryKey
(
id
);
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteUnit
(
String
ids
)
{
public
int
deleteUnit
(
Long
id
)
{
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
return
unitMapper
.
deleteByPrimaryKey
(
id
);
UnitExample
example
=
new
UnitExample
();
}
example
.
createCriteria
().
andIdIn
(
idList
);
return
unitMapper
.
deleteByExample
(
example
);
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
}
public
int
batchDeleteUnit
(
String
ids
)
{
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
public
int
checkIsNameExist
(
Long
id
,
String
name
)
{
UnitExample
example
=
new
UnitExample
();
UnitExample
example
=
new
UnitExample
();
example
.
createCriteria
().
andIdIn
(
idList
);
example
.
createCriteria
().
andIdNotEqualTo
(
id
).
andUnameEqualTo
(
name
);
return
unitMapper
.
deleteByExample
(
example
);
List
<
Unit
>
list
=
unitMapper
.
selectByExample
(
example
);
}
return
list
.
size
();
}
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
();
}
}
src/main/java/com/jsh/erp/service/user/UserService.java
View file @
85d96bb2
package
com.jsh.erp.service.user
;
package
com.jsh.erp.service.user
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.datasource.entities.User
;
import
com.jsh.erp.datasource.entities.User
;
import
com.jsh.erp.datasource.entities.UserExample
;
import
com.jsh.erp.datasource.entities.UserExample
;
import
com.jsh.erp.datasource.mappers.UserMapper
;
import
com.jsh.erp.datasource.mappers.UserMapper
;
import
com.jsh.erp.utils.*
;
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.servlet.http.HttpServletRequest
;
import
javax.annotation.Resource
;
import
java.security.NoSuchAlgorithmException
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.Map
;
import
java.util.List
;
import
java.util.Map
;
@Service
public
class
UserService
{
@Service
private
Logger
logger
=
LoggerFactory
.
getLogger
(
UserService
.
class
);
public
class
UserService
{
@Resource
private
Logger
logger
=
LoggerFactory
.
getLogger
(
UserService
.
class
);
private
UserMapper
userMapper
;
@Resource
private
UserMapper
userMapper
;
public
User
getUser
(
long
id
)
{
return
userMapper
.
selectByPrimaryKey
(
id
);
public
User
getUser
(
long
id
)
{
}
return
userMapper
.
selectByPrimaryKey
(
id
);
}
public
List
<
User
>
getUser
()
{
UserExample
example
=
new
UserExample
();
public
List
<
User
>
getUser
()
{
return
userMapper
.
selectByExample
(
example
);
UserExample
example
=
new
UserExample
();
}
return
userMapper
.
selectByExample
(
example
);
}
public
List
<
User
>
select
(
String
userName
,
String
loginName
,
int
offset
,
int
rows
)
{
return
userMapper
.
selectByConditionUser
(
userName
,
loginName
,
offset
,
rows
);
public
List
<
User
>
select
(
String
userName
,
String
loginName
,
int
offset
,
int
rows
)
{
}
return
userMapper
.
selectByConditionUser
(
userName
,
loginName
,
offset
,
rows
);
}
public
int
countUser
(
String
userName
,
String
loginName
)
{
return
userMapper
.
countsByUser
(
userName
,
loginName
);
public
int
countUser
(
String
userName
,
String
loginName
)
{
}
return
userMapper
.
countsByUser
(
userName
,
loginName
);
}
public
int
insertUser
(
String
beanJson
,
HttpServletRequest
request
)
{
/**
User
user
=
JSONObject
.
parseObject
(
beanJson
,
User
.
class
);
* create by: cjl
String
password
=
"123456"
;
* description:
//因密码用MD5加密,需要对密码进行转化
* 添加事务控制
try
{
* create time: 2019/1/11 14:30
password
=
Tools
.
md5Encryp
(
password
);
* @Param: beanJson
user
.
setPassword
(
password
);
* @Param: request
}
catch
(
NoSuchAlgorithmException
e
)
{
* @return int
e
.
printStackTrace
();
*/
logger
.
error
(
">>>>>>>>>>>>>>转化MD5字符串错误 :"
+
e
.
getMessage
());
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
}
public
int
insertUser
(
String
beanJson
,
HttpServletRequest
request
)
{
return
userMapper
.
insertSelective
(
user
);
User
user
=
JSONObject
.
parseObject
(
beanJson
,
User
.
class
);
}
String
password
=
"123456"
;
//因密码用MD5加密,需要对密码进行转化
public
int
updateUser
(
String
beanJson
,
Long
id
)
{
try
{
User
user
=
JSONObject
.
parseObject
(
beanJson
,
User
.
class
);
password
=
Tools
.
md5Encryp
(
password
);
user
.
setId
(
id
);
user
.
setPassword
(
password
);
return
userMapper
.
updateByPrimaryKeySelective
(
user
);
}
catch
(
NoSuchAlgorithmException
e
)
{
}
e
.
printStackTrace
();
logger
.
error
(
">>>>>>>>>>>>>>转化MD5字符串错误 :"
+
e
.
getMessage
());
public
int
updateUserByObj
(
User
user
)
{
}
return
userMapper
.
updateByPrimaryKeySelective
(
user
);
return
userMapper
.
insertSelective
(
user
);
}
}
/**
public
int
resetPwd
(
String
md5Pwd
,
Long
id
)
{
* create by: cjl
User
user
=
new
User
();
* description:
user
.
setId
(
id
);
* 添加事务控制
user
.
setPassword
(
md5Pwd
);
* create time: 2019/1/11 14:31
return
userMapper
.
updateByPrimaryKeySelective
(
user
);
* @Param: beanJson
}
* @Param: id
* @return int
public
int
deleteUser
(
Long
id
)
{
*/
return
userMapper
.
deleteByPrimaryKey
(
id
);
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
}
public
int
updateUser
(
String
beanJson
,
Long
id
)
{
User
user
=
JSONObject
.
parseObject
(
beanJson
,
User
.
class
);
public
int
batchDeleteUser
(
String
ids
)
{
user
.
setId
(
id
);
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
return
userMapper
.
updateByPrimaryKeySelective
(
user
);
UserExample
example
=
new
UserExample
();
}
example
.
createCriteria
().
andIdIn
(
idList
);
/**
return
userMapper
.
deleteByExample
(
example
);
* create by: cjl
}
* description:
* 添加事务控制
public
int
validateUser
(
String
username
,
String
password
)
throws
JshException
{
* create time: 2019/1/11 14:32
try
{
* @Param: user
/**默认是可以登录的*/
* @return int
List
<
User
>
list
=
null
;
*/
try
{
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
UserExample
example
=
new
UserExample
();
public
int
updateUserByObj
(
User
user
)
{
example
.
createCriteria
().
andLoginameEqualTo
(
username
);
return
userMapper
.
updateByPrimaryKeySelective
(
user
);
list
=
userMapper
.
selectByExample
(
example
);
}
}
catch
(
Exception
e
)
{
/**
logger
.
error
(
">>>>>>>>访问验证用户姓名是否存在后台信息异常"
,
e
);
* create by: cjl
return
ExceptionCodeConstants
.
UserExceptionCode
.
USER_ACCESS_EXCEPTION
;
* description:
}
* 添加事务控制
* create time: 2019/1/11 14:33
if
(
null
!=
list
&&
list
.
size
()
==
0
)
{
* @Param: md5Pwd
return
ExceptionCodeConstants
.
UserExceptionCode
.
USER_NOT_EXIST
;
* @Param: id
}
* @return int
*/
try
{
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
UserExample
example
=
new
UserExample
();
public
int
resetPwd
(
String
md5Pwd
,
Long
id
)
{
example
.
createCriteria
().
andLoginameEqualTo
(
username
).
andPasswordEqualTo
(
password
);
User
user
=
new
User
();
list
=
userMapper
.
selectByExample
(
example
);
user
.
setId
(
id
);
}
catch
(
Exception
e
)
{
user
.
setPassword
(
md5Pwd
);
logger
.
error
(
">>>>>>>>>>访问验证用户密码后台信息异常"
,
e
);
return
userMapper
.
updateByPrimaryKeySelective
(
user
);
return
ExceptionCodeConstants
.
UserExceptionCode
.
USER_ACCESS_EXCEPTION
;
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
if
(
null
!=
list
&&
list
.
size
()
==
0
)
{
public
int
deleteUser
(
Long
id
)
{
return
ExceptionCodeConstants
.
UserExceptionCode
.
USER_PASSWORD_ERROR
;
return
userMapper
.
deleteByPrimaryKey
(
id
);
}
}
return
ExceptionCodeConstants
.
UserExceptionCode
.
USER_CONDITION_FIT
;
}
catch
(
Exception
e
)
{
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
throw
new
JshException
(
"unknown exception"
,
e
);
public
int
batchDeleteUser
(
String
ids
)
{
}
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
}
UserExample
example
=
new
UserExample
();
example
.
createCriteria
().
andIdIn
(
idList
);
public
User
getUserByUserName
(
String
username
)
{
return
userMapper
.
deleteByExample
(
example
);
UserExample
example
=
new
UserExample
();
}
example
.
createCriteria
().
andLoginameEqualTo
(
username
);
List
<
User
>
list
=
userMapper
.
selectByExample
(
example
);
public
int
validateUser
(
String
username
,
String
password
)
throws
JshException
{
User
user
=
list
.
get
(
0
);
try
{
return
user
;
/**默认是可以登录的*/
}
List
<
User
>
list
=
null
;
try
{
public
int
checkIsNameExist
(
Long
id
,
String
name
)
{
UserExample
example
=
new
UserExample
();
UserExample
example
=
new
UserExample
();
example
.
createCriteria
().
andLoginameEqualTo
(
username
);
example
.
createCriteria
().
andIdNotEqualTo
(
id
).
andLoginameEqualTo
(
name
);
list
=
userMapper
.
selectByExample
(
example
);
List
<
User
>
list
=
userMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
)
{
return
list
.
size
();
logger
.
error
(
">>>>>>>>访问验证用户姓名是否存在后台信息异常"
,
e
);
}
return
ExceptionCodeConstants
.
UserExceptionCode
.
USER_ACCESS_EXCEPTION
;
}
}
if
(
null
!=
list
&&
list
.
size
()
==
0
)
{
return
ExceptionCodeConstants
.
UserExceptionCode
.
USER_NOT_EXIST
;
}
try
{
UserExample
example
=
new
UserExample
();
example
.
createCriteria
().
andLoginameEqualTo
(
username
).
andPasswordEqualTo
(
password
);
list
=
userMapper
.
selectByExample
(
example
);
}
catch
(
Exception
e
)
{
logger
.
error
(
">>>>>>>>>>访问验证用户密码后台信息异常"
,
e
);
return
ExceptionCodeConstants
.
UserExceptionCode
.
USER_ACCESS_EXCEPTION
;
}
if
(
null
!=
list
&&
list
.
size
()
==
0
)
{
return
ExceptionCodeConstants
.
UserExceptionCode
.
USER_PASSWORD_ERROR
;
}
return
ExceptionCodeConstants
.
UserExceptionCode
.
USER_CONDITION_FIT
;
}
catch
(
Exception
e
)
{
throw
new
JshException
(
"unknown exception"
,
e
);
}
}
public
User
getUserByUserName
(
String
username
)
{
UserExample
example
=
new
UserExample
();
example
.
createCriteria
().
andLoginameEqualTo
(
username
);
List
<
User
>
list
=
userMapper
.
selectByExample
(
example
);
User
user
=
list
.
get
(
0
);
return
user
;
}
public
int
checkIsNameExist
(
Long
id
,
String
name
)
{
UserExample
example
=
new
UserExample
();
example
.
createCriteria
().
andIdNotEqualTo
(
id
).
andLoginameEqualTo
(
name
);
List
<
User
>
list
=
userMapper
.
selectByExample
(
example
);
return
list
.
size
();
}
}
src/main/java/com/jsh/erp/service/userBusiness/UserBusinessService.java
View file @
85d96bb2
package
com.jsh.erp.service.userBusiness
;
package
com.jsh.erp.service.userBusiness
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.jsh.erp.datasource.entities.UserBusiness
;
import
com.jsh.erp.datasource.entities.UserBusiness
;
import
com.jsh.erp.datasource.entities.UserBusinessExample
;
import
com.jsh.erp.datasource.entities.UserBusinessExample
;
import
com.jsh.erp.datasource.mappers.UserBusinessMapper
;
import
com.jsh.erp.datasource.mappers.UserBusinessMapper
;
import
com.jsh.erp.utils.StringUtil
;
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.servlet.http.HttpServletRequest
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
@Service
public
class
UserBusinessService
{
@Service
private
Logger
logger
=
LoggerFactory
.
getLogger
(
UserBusinessService
.
class
);
public
class
UserBusinessService
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
UserBusinessService
.
class
);
@Resource
private
UserBusinessMapper
userBusinessMapper
;
@Resource
private
UserBusinessMapper
userBusinessMapper
;
public
UserBusiness
getUserBusiness
(
long
id
)
{
return
userBusinessMapper
.
selectByPrimaryKey
(
id
);
public
UserBusiness
getUserBusiness
(
long
id
)
{
}
return
userBusinessMapper
.
selectByPrimaryKey
(
id
);
}
public
List
<
UserBusiness
>
getUserBusiness
()
{
UserBusinessExample
example
=
new
UserBusinessExample
();
public
List
<
UserBusiness
>
getUserBusiness
()
{
return
userBusinessMapper
.
selectByExample
(
example
);
UserBusinessExample
example
=
new
UserBusinessExample
();
}
return
userBusinessMapper
.
selectByExample
(
example
);
}
public
int
insertUserBusiness
(
String
beanJson
,
HttpServletRequest
request
)
{
UserBusiness
userBusiness
=
JSONObject
.
parseObject
(
beanJson
,
UserBusiness
.
class
);
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
return
userBusinessMapper
.
insertSelective
(
userBusiness
);
public
int
insertUserBusiness
(
String
beanJson
,
HttpServletRequest
request
)
{
}
UserBusiness
userBusiness
=
JSONObject
.
parseObject
(
beanJson
,
UserBusiness
.
class
);
return
userBusinessMapper
.
insertSelective
(
userBusiness
);
public
int
updateUserBusiness
(
String
beanJson
,
Long
id
)
{
}
UserBusiness
userBusiness
=
JSONObject
.
parseObject
(
beanJson
,
UserBusiness
.
class
);
userBusiness
.
setId
(
id
);
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
return
userBusinessMapper
.
updateByPrimaryKeySelective
(
userBusiness
);
public
int
updateUserBusiness
(
String
beanJson
,
Long
id
)
{
}
UserBusiness
userBusiness
=
JSONObject
.
parseObject
(
beanJson
,
UserBusiness
.
class
);
userBusiness
.
setId
(
id
);
public
int
deleteUserBusiness
(
Long
id
)
{
return
userBusinessMapper
.
updateByPrimaryKeySelective
(
userBusiness
);
return
userBusinessMapper
.
deleteByPrimaryKey
(
id
);
}
}
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
public
int
batchDeleteUserBusiness
(
String
ids
)
{
public
int
deleteUserBusiness
(
Long
id
)
{
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
return
userBusinessMapper
.
deleteByPrimaryKey
(
id
);
UserBusinessExample
example
=
new
UserBusinessExample
();
}
example
.
createCriteria
().
andIdIn
(
idList
);
return
userBusinessMapper
.
deleteByExample
(
example
);
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
}
public
int
batchDeleteUserBusiness
(
String
ids
)
{
List
<
Long
>
idList
=
StringUtil
.
strToLongList
(
ids
);
public
int
checkIsNameExist
(
Long
id
,
String
name
)
{
UserBusinessExample
example
=
new
UserBusinessExample
();
return
1
;
example
.
createCriteria
().
andIdIn
(
idList
);
}
return
userBusinessMapper
.
deleteByExample
(
example
);
}
public
List
<
UserBusiness
>
getBasicData
(
String
keyId
,
String
type
){
UserBusinessExample
example
=
new
UserBusinessExample
();
public
int
checkIsNameExist
(
Long
id
,
String
name
)
{
example
.
createCriteria
().
andKeyidEqualTo
(
keyId
).
andTypeEqualTo
(
type
);
return
1
;
List
<
UserBusiness
>
list
=
userBusinessMapper
.
selectByExample
(
example
);
}
return
list
;
}
public
List
<
UserBusiness
>
getBasicData
(
String
keyId
,
String
type
){
UserBusinessExample
example
=
new
UserBusinessExample
();
public
Long
checkIsValueExist
(
String
type
,
String
keyId
)
{
example
.
createCriteria
().
andKeyidEqualTo
(
keyId
).
andTypeEqualTo
(
type
);
UserBusinessExample
example
=
new
UserBusinessExample
();
List
<
UserBusiness
>
list
=
userBusinessMapper
.
selectByExample
(
example
);
example
.
createCriteria
().
andTypeEqualTo
(
type
).
andKeyidEqualTo
(
keyId
);
return
list
;
List
<
UserBusiness
>
list
=
userBusinessMapper
.
selectByExample
(
example
);
}
Long
id
=
null
;
if
(
list
.
size
()
>
0
)
{
public
Long
checkIsValueExist
(
String
type
,
String
keyId
)
{
id
=
list
.
get
(
0
).
getId
();
UserBusinessExample
example
=
new
UserBusinessExample
();
}
example
.
createCriteria
().
andTypeEqualTo
(
type
).
andKeyidEqualTo
(
keyId
);
return
id
;
List
<
UserBusiness
>
list
=
userBusinessMapper
.
selectByExample
(
example
);
}
Long
id
=
null
;
if
(
list
.
size
()
>
0
)
{
public
Boolean
checkIsUserBusinessExist
(
String
TypeVale
,
String
KeyIdValue
,
String
UBValue
)
{
id
=
list
.
get
(
0
).
getId
();
UserBusinessExample
example
=
new
UserBusinessExample
();
}
String
newVaule
=
"%"
+
UBValue
+
"%"
;
return
id
;
if
(
TypeVale
!=
null
&&
KeyIdValue
!=
null
)
{
}
example
.
createCriteria
().
andTypeEqualTo
(
TypeVale
).
andKeyidEqualTo
(
KeyIdValue
).
andValueLike
(
newVaule
);
}
else
{
public
Boolean
checkIsUserBusinessExist
(
String
TypeVale
,
String
KeyIdValue
,
String
UBValue
)
{
example
.
createCriteria
().
andValueLike
(
newVaule
);
UserBusinessExample
example
=
new
UserBusinessExample
();
}
String
newVaule
=
"%"
+
UBValue
+
"%"
;
List
<
UserBusiness
>
list
=
userBusinessMapper
.
selectByExample
(
example
);
if
(
TypeVale
!=
null
&&
KeyIdValue
!=
null
)
{
if
(
list
.
size
()
>
0
)
{
example
.
createCriteria
().
andTypeEqualTo
(
TypeVale
).
andKeyidEqualTo
(
KeyIdValue
).
andValueLike
(
newVaule
);
return
true
;
}
else
{
}
else
{
example
.
createCriteria
().
andValueLike
(
newVaule
);
return
false
;
}
}
List
<
UserBusiness
>
list
=
userBusinessMapper
.
selectByExample
(
example
);
}
if
(
list
.
size
()
>
0
)
{
return
true
;
public
int
updateBtnStr
(
Long
userBusinessId
,
String
btnStr
)
{
}
else
{
UserBusiness
userBusiness
=
new
UserBusiness
();
return
false
;
userBusiness
.
setBtnstr
(
btnStr
);
}
UserBusinessExample
example
=
new
UserBusinessExample
();
}
example
.
createCriteria
().
andIdEqualTo
(
userBusinessId
);
return
userBusinessMapper
.
updateByExampleSelective
(
userBusiness
,
example
);
@Transactional
(
value
=
"transactionManager"
,
rollbackFor
=
Exception
.
class
)
}
public
int
updateBtnStr
(
Long
userBusinessId
,
String
btnStr
)
{
UserBusiness
userBusiness
=
new
UserBusiness
();
}
userBusiness
.
setBtnstr
(
btnStr
);
UserBusinessExample
example
=
new
UserBusinessExample
();
example
.
createCriteria
().
andIdEqualTo
(
userBusinessId
);
return
userBusinessMapper
.
updateByExampleSelective
(
userBusiness
,
example
);
}
}
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