Toggle navigation
Toggle navigation
This project
Loading...
Sign in
YOHOBUY
/
yohobuy-union
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
ping
9 years ago
Commit
f10e1382fa0bb46f030df4e6bbb1f858b15697b9
1 parent
162507d8
update
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
0 deletions
common/src/main/java/com/yoho/unions/common/enums/SexEnum.java
server/src/main/java/com/yoho/activity/service/impl/DrawServiceImpl.java
common/src/main/java/com/yoho/unions/common/enums/SexEnum.java
0 → 100644
View file @
f10e138
package
com
.
yoho
.
unions
.
common
.
enums
;
import
org.apache.commons.lang.StringUtils
;
/**
* 性别枚举
* @author ping.huang
*
*/
public
enum
SexEnum
{
FEMALE
(
"2"
,
"f"
,
"女"
),
MALE
(
"1"
,
"m"
,
"男"
);
private
String
code
;
private
String
name
;
private
String
name_ch
;
public
String
getCode
()
{
return
code
;
}
public
String
getName
()
{
return
name
;
}
public
String
getName_ch
()
{
return
name_ch
;
}
private
SexEnum
(
String
code
,
String
name
,
String
name_ch
)
{
this
.
code
=
code
;
this
.
name
=
name
;
this
.
name_ch
=
name_ch
;
}
/**
* 根据code,获取name
* @param code
* @return
*/
public
static
String
getNameByCode
(
String
code
)
{
if
(
StringUtils
.
isEmpty
(
code
))
{
return
null
;
}
for
(
SexEnum
e
:
values
())
{
if
(
code
.
equals
(
e
.
getCode
()))
{
return
e
.
getName
();
}
}
return
null
;
}
/**
* 根据code,获取中文name
* @param code
* @return
*/
public
static
String
getNameCHByCode
(
String
code
)
{
if
(
StringUtils
.
isEmpty
(
code
))
{
return
null
;
}
for
(
SexEnum
e
:
values
())
{
if
(
code
.
equals
(
e
.
getCode
()))
{
return
e
.
getName_ch
();
}
}
return
null
;
}
}
...
...
server/src/main/java/com/yoho/activity/service/impl/DrawServiceImpl.java
View file @
f10e138
...
...
@@ -20,6 +20,7 @@ import com.yoho.error.exception.ServiceException;
import
com.yoho.service.model.union.request.DrawRequestBO
;
import
com.yoho.service.model.union.response.DrawInfoResponseBO
;
import
com.yoho.service.model.user.other.response.DrawResponseBO
;
import
com.yoho.unions.common.enums.SexEnum
;
import
com.yoho.unions.common.utils.DateUtil
;
import
com.yoho.unions.common.utils.RandomUtil
;
import
com.yoho.unions.dal.IUserBaseDAO
;
...
...
@@ -78,6 +79,12 @@ public class DrawServiceImpl implements DrawService {
throw
new
ServiceException
(
ServiceError
.
USER_NOT_EXISTS
);
}
//性别的值,只能是1或2
if
(
SexEnum
.
getNameByCode
(
request
.
getGender
())
==
null
)
{
log
.
warn
(
"draw error gender is error with param is {}"
,
request
);
throw
new
ServiceException
(
ServiceError
.
PARAM_ERROR
);
}
//通用的部分,男女都有
list
.
addAll
(
pDraw
);
...
...
Please
register
or
login
to post a comment