Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
6a999e74
Commit
6a999e74
authored
May 11, 2024
by
chenzhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
农户登录注册修改
parent
04f4304f
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
5 deletions
+80
-5
BeanDtoUtils.java
.../yeejoin/amos/boot/module/hygf/api/util/BeanDtoUtils.java
+35
-0
PeasantHouseholdWxController.java
...ule/hygf/biz/controller/PeasantHouseholdWxController.java
+45
-5
PeasantHouseholdServiceImpl.java
...le/hygf/biz/service/impl/PeasantHouseholdServiceImpl.java
+0
-0
No files found.
amos-boot-system-jxiop/amos-boot-module-hygf-api/src/main/java/com/yeejoin/amos/boot/module/hygf/api/util/BeanDtoUtils.java
View file @
6a999e74
...
@@ -2,6 +2,8 @@ package com.yeejoin.amos.boot.module.hygf.api.util;
...
@@ -2,6 +2,8 @@ package com.yeejoin.amos.boot.module.hygf.api.util;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
java.lang.reflect.Field
;
public
class
BeanDtoUtils
{
public
class
BeanDtoUtils
{
...
@@ -34,4 +36,37 @@ public class BeanDtoUtils {
...
@@ -34,4 +36,37 @@ public class BeanDtoUtils {
return
null
;
return
null
;
}
}
}
}
public
static
<
S
,
T
>
void
copyPropertiesNonNull
(
S
source
,
T
target
)
{
if
(
source
==
null
||
target
==
null
)
{
throw
new
IllegalArgumentException
(
"Source and target cannot be null"
);
}
// 使用反射获取源对象的所有属性
Field
[]
sourceFields
=
source
.
getClass
().
getDeclaredFields
();
for
(
Field
sourceField
:
sourceFields
)
{
if
(
sourceField
.
getName
().
equals
(
"serialVersionUID"
)){
continue
;
}
sourceField
.
setAccessible
(
true
);
// 获取目标对象中对应的属性
try
{
Field
targetField
=
target
.
getClass
().
getDeclaredField
(
sourceField
.
getName
());
targetField
.
setAccessible
(
true
);
// 获取源对象的属性值
Object
sourceValue
=
sourceField
.
get
(
source
);
// 如果源对象的属性值不是 null,则复制到目标对象
if
(
sourceValue
!=
null
)
{
targetField
.
set
(
target
,
sourceValue
);
}
}
catch
(
NoSuchFieldException
e
)
{
// 如果目标对象没有对应的属性,则忽略
}
catch
(
IllegalAccessException
e
)
{
// 如果访问属性时发生异常,则抛出运行时异常
throw
new
RuntimeException
(
e
);
}
}
}
}
}
amos-boot-system-jxiop/amos-boot-module-hygf-biz/src/main/java/com/yeejoin/amos/boot/module/hygf/biz/controller/PeasantHouseholdWxController.java
View file @
6a999e74
...
@@ -6,12 +6,15 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
...
@@ -6,12 +6,15 @@ import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import
com.yeejoin.amos.boot.module.hygf.api.dto.MobileLoginParamDto
;
import
com.yeejoin.amos.boot.module.hygf.api.dto.MobileLoginParamDto
;
import
com.yeejoin.amos.boot.module.hygf.api.dto.PeasantHouseholdDto
;
import
com.yeejoin.amos.boot.module.hygf.api.dto.PeasantHouseholdDto
;
import
com.yeejoin.amos.boot.module.hygf.api.dto.PeasantHouseholdWxDto
;
import
com.yeejoin.amos.boot.module.hygf.api.dto.PeasantHouseholdWxDto
;
import
com.yeejoin.amos.boot.module.hygf.api.entity.PeasantHousehold
;
import
com.yeejoin.amos.boot.module.hygf.api.service.IWxService
;
import
com.yeejoin.amos.boot.module.hygf.api.service.IWxService
;
import
com.yeejoin.amos.boot.module.hygf.api.util.BeanDtoUtils
;
import
com.yeejoin.amos.boot.module.hygf.biz.service.impl.HouseholdContractServiceImpl
;
import
com.yeejoin.amos.boot.module.hygf.biz.service.impl.HouseholdContractServiceImpl
;
import
com.yeejoin.amos.boot.module.hygf.biz.service.impl.PeasantHouseholdServiceImpl
;
import
com.yeejoin.amos.boot.module.hygf.biz.service.impl.PeasantHouseholdServiceImpl
;
import
com.yeejoin.amos.boot.module.hygf.biz.service.impl.SurveyInformationServiceImpl
;
import
com.yeejoin.amos.boot.module.hygf.biz.service.impl.SurveyInformationServiceImpl
;
import
com.yeejoin.amos.component.feign.model.FeignClientResult
;
import
com.yeejoin.amos.component.feign.model.FeignClientResult
;
import
com.yeejoin.amos.component.robot.AmosRequestContext
;
import
com.yeejoin.amos.component.robot.AmosRequestContext
;
import
com.yeejoin.amos.feign.privilege.Privilege
;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
import
com.yeejoin.amos.feign.privilege.model.AgencyUserModel
;
import
com.yeejoin.amos.feign.systemctl.Systemctl
;
import
com.yeejoin.amos.feign.systemctl.Systemctl
;
import
com.yeejoin.amos.feign.systemctl.model.RegionModel
;
import
com.yeejoin.amos.feign.systemctl.model.RegionModel
;
...
@@ -21,9 +24,11 @@ import io.swagger.annotations.ApiOperation;
...
@@ -21,9 +24,11 @@ import io.swagger.annotations.ApiOperation;
import
io.swagger.annotations.ApiParam
;
import
io.swagger.annotations.ApiParam
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
import
org.typroject.tyboot.core.restful.doc.TycloudOperation
;
import
org.typroject.tyboot.core.restful.doc.TycloudOperation
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
...
@@ -107,15 +112,33 @@ public class PeasantHouseholdWxController extends BaseController {
...
@@ -107,15 +112,33 @@ public class PeasantHouseholdWxController extends BaseController {
return
ResponseHelper
.
buildResponse
(
peasantHouseholdServiceImpl
.
wxUserLogin
(
mobileLoginParam
));
return
ResponseHelper
.
buildResponse
(
peasantHouseholdServiceImpl
.
wxUserLogin
(
mobileLoginParam
));
}
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@RequestMapping
(
value
=
"/getRegisterPhone"
,
method
=
RequestMethod
.
POST
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"获取手机号及回填信息"
,
notes
=
"获取手机号及回填信息"
)
public
ResponseModel
<
Map
<
String
,
Object
>>
getRegisterPhone
(
@ApiParam
@RequestBody
MobileLoginParamDto
mobileLoginParam
)
{
log
.
info
(
"微信授权注册入参 => {}"
,
mobileLoginParam
);
if
(
StringUtils
.
isBlank
(
mobileLoginParam
.
getAmosUserId
()))
{
// 扫码的userId为空, 则取默认值
mobileLoginParam
.
setAmosUserId
(
defaultUserId
);
}
return
ResponseHelper
.
buildResponse
(
peasantHouseholdServiceImpl
.
getRegisterPhone
(
mobileLoginParam
));
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@RequestMapping
(
value
=
"/register"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/register"
,
method
=
RequestMethod
.
POST
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"微信农户注册"
,
notes
=
"微信农户注册"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"微信农户注册"
,
notes
=
"微信农户注册"
)
public
ResponseModel
<
PeasantHouseholdDto
>
wxUserRegister
(
@ApiParam
@RequestBody
MobileLoginParamDto
mobileLoginParam
)
{
public
ResponseModel
<
PeasantHouseholdWxDto
>
wxUserRegister
(
@ApiParam
@RequestBody
MobileLoginParamDto
mobileLoginParam
)
{
//注册并登录 生成农户信息表数据
PeasantHouseholdWxDto
peasantHouseholdWxDto
=
peasantHouseholdServiceImpl
.
registerAndLogin
(
mobileLoginParam
);
PeasantHousehold
peasantHousehold
=
peasantHouseholdWxDto
.
getPeasantHousehold
();
try
{
log
.
info
(
"微信农户注册, 入参 => {}"
,
mobileLoginParam
);
log
.
info
(
"微信农户注册, 入参 => {}"
,
mobileLoginParam
);
PeasantHouseholdDto
model
=
mobileLoginParam
.
getPeasantHouseholdDto
();
PeasantHouseholdDto
model
=
mobileLoginParam
.
getPeasantHouseholdDto
();
validatedPeasantHouseholdDto
(
model
);
validatedPeasantHouseholdDto
(
model
);
AgencyUserModel
userInfo
=
getUserInfo
();
BeanDtoUtils
.
copyPropertiesNonNull
(
peasantHousehold
,
model
);
model
.
setAmosUserId
(
userInfo
.
getUserId
());
// 绑定平台userId
model
.
setPeasantHouseholdNo
(
peasantHouseholdServiceImpl
.
getPeasantHouseholdNo
(
model
.
getRegionalCompaniesSeq
()));
model
.
setPeasantHouseholdNo
(
peasantHouseholdServiceImpl
.
getPeasantHouseholdNo
(
model
.
getRegionalCompaniesSeq
()));
model
.
setIsCertified
(
1
);
// 这里就实名认证
model
.
setIsCertified
(
1
);
// 这里就实名认证
model
.
setSurveyOrNot
(
0
);
model
.
setSurveyOrNot
(
0
);
...
@@ -150,9 +173,26 @@ public class PeasantHouseholdWxController extends BaseController {
...
@@ -150,9 +173,26 @@ public class PeasantHouseholdWxController extends BaseController {
}
}
}
}
}
}
PeasantHouseholdDto
result
=
peasantHouseholdServiceImpl
.
savePeasantHousehold
(
model
,
userInfo
);
BeanDtoUtils
.
copyPropertiesNonNull
(
model
,
peasantHousehold
);
PeasantHouseholdDto
result
=
peasantHouseholdServiceImpl
.
savePeasantHousehold
(
model
,
null
);
peasantHouseholdWxDto
.
setPeasantHousehold
(
peasantHousehold
);
return
ResponseHelper
.
buildResponse
(
peasantHouseholdWxDto
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
if
(
null
!=
peasantHousehold
)
{
log
.
error
(
"调用平台接口回滚注册的用户 => {}"
,
e
,
peasantHousehold
.
getAmosUserId
());
// 调用平台接口回滚注册的用户
RequestContext
.
setAppKey
(
"AMOS_STUDIO"
);
RequestContext
.
setProduct
(
"AMOS_STUDIO_WEB"
);
RequestContext
.
setToken
(
requestContext
.
getToken
());
Privilege
.
agencyUserClient
.
multDeleteUser
(
peasantHousehold
.
getAmosUserId
());
}
if
(
e
instanceof
BadRequest
||
e
.
getCause
()
instanceof
BadRequest
)
{
throw
new
BadRequest
(
e
.
getMessage
());
}
throw
new
BadRequest
(
e
.
getMessage
());
}
return
ResponseHelper
.
buildResponse
(
result
);
}
}
public
JSONArray
getRegionName
()
{
public
JSONArray
getRegionName
()
{
...
...
amos-boot-system-jxiop/amos-boot-module-hygf-biz/src/main/java/com/yeejoin/amos/boot/module/hygf/biz/service/impl/PeasantHouseholdServiceImpl.java
View file @
6a999e74
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
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