From 497475defd5d0ebf90ae6a8e2b080a16d78043ab Mon Sep 17 00:00:00 2001 From: feiyu02 <risaku@163.com> Date: 星期五, 23 九月 2022 17:49:34 +0800 Subject: [PATCH] 2022.9.23 --- src/main/kotlin/cn/flightfeather/supervision/lightshare/service/Impl/UserinfoServiceImpl.kt | 93 +++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 86 insertions(+), 7 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 21c3102..1ff3939 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,26 +1,35 @@ package cn.flightfeather.supervision.lightshare.service.Impl +import cn.flightfeather.supervision.common.net.WXHttpService +import cn.flightfeather.supervision.domain.entity.BaseInfo +import cn.flightfeather.supervision.domain.entity.Company +import cn.flightfeather.supervision.domain.entity.UserInfoWx import cn.flightfeather.supervision.domain.entity.Userinfo import cn.flightfeather.supervision.domain.enumeration.SceneType +import cn.flightfeather.supervision.domain.enumeration.UserType import cn.flightfeather.supervision.domain.mapper.* import cn.flightfeather.supervision.infrastructure.utils.FileUtil import cn.flightfeather.supervision.infrastructure.utils.UUIDGenerator import cn.flightfeather.supervision.lightshare.service.UserinfoService import cn.flightfeather.supervision.lightshare.vo.* +import com.alibaba.fastjson.JSONObject import com.github.pagehelper.PageHelper import org.springframework.beans.BeanUtils 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 class UserinfoServiceImpl( - val userinfoMapper: UserinfoMapper, - val baseInfoMapper: BaseInfoMapper, - val companyMapper: CompanyMapper, - val restaurantBaseInfoMapper: RestaurantBaseInfoMapper, - val vehicleBaseInfoMapper: VehicleBaseInfoMapper + val userinfoMapper: UserinfoMapper, + val baseInfoMapper: BaseInfoMapper, + val companyMapper: CompanyMapper, + val restaurantBaseInfoMapper: RestaurantBaseInfoMapper, + val vehicleBaseInfoMapper: VehicleBaseInfoMapper, + val userMapMapper: UserMapMapper, ) : UserinfoService { //鏍规嵁userinfo鏉′欢鏌ヨ @@ -36,7 +45,13 @@ } } - override fun findOne(id: String): Userinfo = userinfoMapper.selectByPrimaryKey(id) + override fun findOne(id: String): Userinfo{ + val userInfo = userinfoMapper.selectByPrimaryKey(id) + userMapMapper.selectByPrimaryKey(id)?.let { + userInfo?.extension3 = it.svUserId + } + return userInfo ?: Userinfo() + } override fun findAll(): MutableList<Userinfo> = userinfoMapper.selectAll() @@ -47,6 +62,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) @@ -55,6 +71,8 @@ return AccessToken().apply { if (result.isNotEmpty()) { userId = result[0].guid + val sUser = userMapMapper.selectByPrimaryKey(userId) + sUserId = sUser?.svUserId success = true } else { success = false @@ -80,6 +98,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 @@ -123,7 +190,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() } @@ -197,4 +264,16 @@ return UserBaseInfo(userId, userInfo.realname, baseInfo, companyInfo, specialInfo) } + + override fun search(district: String?, sceneType: Int?, userType: Int?, page: Int, perPage: Int): BaseResponse<List<Userinfo>> { + val result = userinfoMapper.selectByExample(Example(Userinfo::class.java).apply { + createCriteria().apply { + district?.let { andEqualTo("extension1", it) } + sceneType?.let { andEqualTo("extension2", it) } + userType?.let { andEqualTo("usertypeid", it) } + } + }) + + return BaseResponse(true, data = result) + } } \ No newline at end of file -- Gitblit v1.9.3