From 23bd719cebe5feeff4e48fde925b0b39755eea93 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期二, 15 十一月 2022 10:59:50 +0800 Subject: [PATCH] 2022.11.15 --- src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/UserinfoServiceImpl.kt | 82 ++++++++++++++++++++++++++++++++++++----- 1 files changed, 72 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/UserinfoServiceImpl.kt b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/UserinfoServiceImpl.kt index 7fd7c72..c371dc0 100644 --- a/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/UserinfoServiceImpl.kt +++ b/src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/UserinfoServiceImpl.kt @@ -1,5 +1,7 @@ package cn.flightfeather.supervision.lightshare.service.Impl +import cn.flightfeather.supervision.domain.entity.BaseInfo +import cn.flightfeather.supervision.domain.entity.Company import cn.flightfeather.supervision.domain.entity.Userinfo import cn.flightfeather.supervision.domain.enumeration.SceneType import cn.flightfeather.supervision.domain.mapper.* @@ -12,6 +14,8 @@ import org.springframework.stereotype.Service import org.springframework.web.multipart.MultipartFile import tk.mybatis.mapper.entity.Example +import java.math.BigDecimal +import java.util.* import javax.servlet.http.HttpServletResponse @Service @@ -21,7 +25,9 @@ val companyMapper: CompanyMapper, val restaurantBaseInfoMapper: RestaurantBaseInfoMapper, val vehicleBaseInfoMapper: VehicleBaseInfoMapper, - val userMapMapper: UserMapMapper + val userMapMapper: UserMapMapper, + val personalInfoMapper: PersonalInfoMapper, + val userInfoWxMapper: UserInfoWxMapper ) : UserinfoService { //鏍规嵁userinfo鏉′欢鏌ヨ @@ -37,7 +43,7 @@ } } - override fun findOne(id: String): Userinfo{ + override fun findOne(id: String): Userinfo { val userInfo = userinfoMapper.selectByPrimaryKey(id) userMapMapper.selectByPrimaryKey(id)?.let { userInfo?.extension3 = it.svUserId @@ -97,6 +103,55 @@ } } + override fun register2(loginRequestVo: LoginRequestVo): AccessToken { + val result = userinfoMapper.selectByExample(Example(Userinfo::class.java).apply { + createCriteria().andEqualTo("realname", loginRequestVo.userName) + }) + if (result.isNotEmpty()) { + return AccessToken().apply { success = false } + } else { + val userInfo = Userinfo().apply { + guid = UUIDGenerator.generate16ShortUUID() + acountname = loginRequestVo.userName + realname = loginRequestVo.userName + password = loginRequestVo.password + usertypeid = 3 + usertype = "浼佷笟" + isenable = true + extension2 = loginRequestVo.sceneType + } + val company = Company().apply { + ciGuid = UUIDGenerator.generate16ShortUUID() + ciName = loginRequestVo.department + ciAddress = loginRequestVo.address + ciLongitude = BigDecimal.ZERO + ciLatitude = BigDecimal.ZERO + ciOrgCode = loginRequestVo.orgCode + ciBuildDate = Date() + ciTelephone = loginRequestVo.telephone + } + val baseInfo = BaseInfo().apply { + biGuid = userInfo.guid + biName = userInfo.realname + ciGuid = company.ciGuid + ciName = company.ciName + biTelephone = loginRequestVo.telephone + biAddress + biCreateTime = Date() + biUpdateTime = Date() + biExtension1 = userInfo.acountname + } + save(userInfo) + baseInfoMapper.insert(baseInfo) + companyMapper.insert(company) + + return AccessToken().apply { + userId = userInfo.guid + success = true + } + } + } + override fun getAddressBook(userId: String): List<FriendVo> { val resultList = mutableListOf<FriendVo>() val userInfo = findOne(userId) @@ -149,16 +204,21 @@ } } - override fun changePassword(userId: String, oldPassword: String, newPassword: String): Int { + override fun changePassword(userId: String, oldPassword: String, newPassword: String): BaseResponse<String> { + if (newPassword.trim() == "") return BaseResponse(false, "鏂板瘑鐮佷笉鑳戒负绌�") + if (oldPassword == newPassword) return BaseResponse(false, "鏂板瘑鐮佷笉鑳藉拰鍘熷瘑鐮佺浉鍚�") + val userInfo = findOne(userId) return if (oldPassword != userInfo.password) { - 0 + BaseResponse(false, "鍘熷瘑鐮侀敊璇�") } else { val newUserInfo = Userinfo().apply { guid = userInfo.guid password = newPassword + remark = "pwChanged" } update(newUserInfo) + BaseResponse(true, "瀵嗙爜淇敼鎴愬姛") } } @@ -192,20 +252,22 @@ return result } - override fun getBaseInfo(userId: String): UserBaseInfo { + override fun getBaseInfo(userId: String, wxUserId: String?): UserBaseInfo { val userInfo = userinfoMapper.selectByPrimaryKey(userId) ?: return UserBaseInfo(userId) - val baseInfo = baseInfoMapper.selectByPrimaryKey(userId) ?: return UserBaseInfo(userId) + val baseInfo = baseInfoMapper.selectByPrimaryKey(userId) + val wxUser = if (wxUserId != null) userInfoWxMapper.selectByPrimaryKey(wxUserId) else null val mapper = when (userInfo.extension2) { SceneType.Restaurant.value.toString() -> restaurantBaseInfoMapper SceneType.VehicleRepair.value.toString() -> vehicleBaseInfoMapper - else -> restaurantBaseInfoMapper + else -> null } - val specialInfo = mapper.selectByPrimaryKey(baseInfo.biGuid) - val companyInfo = companyMapper.selectByPrimaryKey(baseInfo.ciGuid) + val specialInfo = mapper?.selectByPrimaryKey(baseInfo?.biGuid) + val companyInfo = companyMapper.selectByPrimaryKey(if (baseInfo?.ciGuid != null) baseInfo.ciGuid else wxUser?.ciGuid) + val personalInfo = personalInfoMapper.selectByPrimaryKey(wxUser?.piGuid) - return UserBaseInfo(userId, userInfo.realname, baseInfo, companyInfo, specialInfo) + return UserBaseInfo(userId, userInfo.realname, baseInfo, companyInfo, specialInfo, personalInfo) } override fun search(district: String?, sceneType: Int?, userType: Int?, page: Int, perPage: Int): BaseResponse<List<Userinfo>> { -- Gitblit v1.9.3