From 3e2159e45e12b2b8af058b68eafeaf082cf3fe85 Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期四, 15 九月 2022 09:30:31 +0800 Subject: [PATCH] 2022.9.15 1. 根据微信小程序前端需求,添加各对应后台逻辑 --- src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/UserinfoServiceImpl.kt | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 55 insertions(+), 1 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 b0105f7..47d73ed 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 @@ -54,6 +58,7 @@ override fun delete(id: String): Int = userinfoMapper.deleteByPrimaryKey(id) override fun login(loginRequestVo: LoginRequestVo): AccessToken { + if (loginRequestVo.userName.isNullOrEmpty() || loginRequestVo.password.isNullOrEmpty()) return AccessToken() val example = Example(Userinfo::class.java) val criteria = example.createCriteria() criteria.andEqualTo("acountname", loginRequestVo.userName) @@ -89,6 +94,55 @@ isenable = true } save(userInfo) + return AccessToken().apply { + userId = userInfo.guid + success = true + } + } + } + + 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 @@ -132,7 +186,7 @@ val path = "accounts/$userId/" try { //璋冪敤鏂囦欢淇濆瓨鏂规硶 - FileUtil().uploadFile(file.bytes, basePath + path, fileName!!) + FileUtil.uploadFile(file.bytes, basePath + path, fileName!!) } catch (e: Exception) { e.printStackTrace() } -- Gitblit v1.9.3