From 06f8a78e6a731825c7d72e305292dbcab2160f01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=8D=9A?= Date: Fri, 8 Nov 2024 13:29:08 +0800 Subject: [PATCH] =?UTF-8?q?=E8=99=B9=E8=BD=AF=E6=BF=80=E6=B4=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/controller/AppApiController.java | 13 +- .../modules/appparent/annotation/Login.java | 12 + .../appparent/annotation/LoginUser.java | 15 + .../appparent/config/WebMvcConfig.java | 32 + .../controller/AppApiController.java | 553 ++++++++++++++++++ .../modules/appparent/controller/AppComm.java | 16 + .../controller/AppInfoApiController.java | 156 +++++ .../controller/AppLoginController.java | 96 +++ .../controller/AppRegisterController.java | 266 +++++++++ .../modules/appparent/form/LoginForm.java | 43 ++ .../modules/appparent/form/RegisterForm.java | 40 ++ .../appparent/form/RegisterSmsForm.java | 40 ++ .../interceptor/AuthorizationInterceptor.java | 62 ++ ...oginUserHandlerMethodArgumentResolver.java | 44 ++ .../appparent/utils/AliyunSmsUtils.java | 143 +++++ .../modules/appparent/utils/JwtUtils.java | 85 +++ .../appparent/utils/MonyunSmsUtils.java | 50 ++ .../ten/controller/TenBuildController.java | 17 +- .../ten/controller/TenParentController.java | 18 +- .../modules/ten/entity/TenParent.java | 15 + .../modules/ten/service/TenParentService.java | 5 + .../service/impl/TenParentServiceImpl.java | 26 + 22 files changed, 1721 insertions(+), 26 deletions(-) create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/appparent/annotation/Login.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/appparent/annotation/LoginUser.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/appparent/config/WebMvcConfig.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/appparent/controller/AppApiController.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/appparent/controller/AppComm.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/appparent/controller/AppInfoApiController.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/appparent/controller/AppLoginController.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/appparent/controller/AppRegisterController.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/appparent/form/LoginForm.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/appparent/form/RegisterForm.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/appparent/form/RegisterSmsForm.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/appparent/interceptor/AuthorizationInterceptor.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/appparent/resolver/LoginUserHandlerMethodArgumentResolver.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/appparent/utils/AliyunSmsUtils.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/appparent/utils/JwtUtils.java create mode 100644 shapelight-admin/src/main/java/net/shapelight/modules/appparent/utils/MonyunSmsUtils.java diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/app/controller/AppApiController.java b/shapelight-admin/src/main/java/net/shapelight/modules/app/controller/AppApiController.java index d3ac0db..4c38624 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/app/controller/AppApiController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/app/controller/AppApiController.java @@ -1019,17 +1019,14 @@ public class AppApiController { @PostMapping("/remove") public R removeBind(@LoginUser AppUserEntity user, @RequestBody List> params) { //AppUserScopeEntity userScopeEntity = appUserScopeService.getById(user.getCurrentScopeId()); - Map opParams = new HashMap<>(); + /*Map opParams = new HashMap<>(); opParams.put("operation","delUserContactData"); opParams.put("accountNumber",globalValue.accountNumber); opParams.put("passKey", KeysEntity.passKey); opParams.put("empowerText",KeysEntity.empowerText); List> dataInfo = new ArrayList<>(); Map info = new HashMap<>(); - List list = new ArrayList<>(); - params.forEach(item -> { - list.add(item.get("personId").toString()); - }); + List relations = relationService.list(new LambdaQueryWrapper() .eq(TenRelation::getParentId,user.getUserId()) .in(TenRelation::getStudentId,list)); @@ -1044,7 +1041,11 @@ public class AppApiController { } if(!jsonObject.getJSONArray("errInfo").isEmpty()) { return R.error("同步联系人失败"); - } + }*/ + List list = new ArrayList<>(); + params.forEach(item -> { + list.add(item.get("personId").toString()); + }); relationService.remove(new LambdaQueryWrapper() .eq(TenRelation::getParentId,user.getUserId()) .in(TenRelation::getStudentId,list)); diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/appparent/annotation/Login.java b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/annotation/Login.java new file mode 100644 index 0000000..af37cd5 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/annotation/Login.java @@ -0,0 +1,12 @@ +package net.shapelight.modules.appparent.annotation; + +import java.lang.annotation.*; + +/** + * app登录效验 + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface Login { +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/appparent/annotation/LoginUser.java b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/annotation/LoginUser.java new file mode 100644 index 0000000..ce68ef5 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/annotation/LoginUser.java @@ -0,0 +1,15 @@ +package net.shapelight.modules.appparent.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 登录用户信息 + */ +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +public @interface LoginUser { + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/appparent/config/WebMvcConfig.java b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/config/WebMvcConfig.java new file mode 100644 index 0000000..39c54cc --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/config/WebMvcConfig.java @@ -0,0 +1,32 @@ +package net.shapelight.modules.appparent.config; + +import net.shapelight.modules.appparent.interceptor.AuthorizationInterceptor; +import net.shapelight.modules.appparent.resolver.LoginUserHandlerMethodArgumentResolver; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import java.util.List; + +/** + * MVC配置 + */ +@Configuration +public class WebMvcConfig implements WebMvcConfigurer { + @Autowired + private AuthorizationInterceptor authorizationInterceptor; + @Autowired + private LoginUserHandlerMethodArgumentResolver loginUserHandlerMethodArgumentResolver; + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(authorizationInterceptor).addPathPatterns("/app/**"); + } + + @Override + public void addArgumentResolvers(List argumentResolvers) { + argumentResolvers.add(loginUserHandlerMethodArgumentResolver); + } +} \ No newline at end of file diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/appparent/controller/AppApiController.java b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/controller/AppApiController.java new file mode 100644 index 0000000..c0e311d --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/controller/AppApiController.java @@ -0,0 +1,553 @@ +package net.shapelight.modules.appparent.controller; + + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import io.minio.MinioClient; +import io.minio.PutObjectOptions; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import net.shapelight.common.config.GlobalValue; +import net.shapelight.common.config.MinioConfig; +import net.shapelight.common.utils.*; +import net.shapelight.modules.app.service.AppUserService; +import net.shapelight.modules.appparent.annotation.Login; +import net.shapelight.modules.appparent.annotation.LoginUser; +import net.shapelight.modules.nettyapi.service.ServerApiService; +import net.shapelight.modules.sys.entity.SysDeviceAppEntity; +import net.shapelight.modules.sys.service.SysDeviceAppService; +import net.shapelight.modules.sys.service.SysUserService; +import net.shapelight.modules.ten.entity.*; +import net.shapelight.modules.ten.service.*; +import net.shapelight.modules.tripartitePlatform.operatorPlatform.OpFeignClient; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.io.FilenameUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.io.InputStream; +import java.util.*; +import java.util.stream.Collectors; + +/** + * APP测试接口 + */ +@RestController +@RequestMapping("/parent/app") +@Api("APP接口") +public class AppApiController { + + @Autowired + private TenPersonService tenPersonService; + @Autowired + private TenCellService tenCellService; + @Autowired + private TenBuildService tenBuildService; + @Autowired + private TenRoomService tenRoomService; + @Autowired + private TenDeviceService tenDeviceService; + @Autowired + private MinioConfig minioConfig; + @Autowired + private MinioClient minioClient; + @Autowired + private TenNoticeService tenNoticeService; + @Autowired + private TenFeedbackService tenFeedbackService; + @Autowired + private TenRepairService tenRepairService; + @Autowired + private GlobalValue globalValue; + @Autowired + private TenRecordService tenRecordService; + @Autowired + private SysUserService sysUserService; + @Autowired + private SysDeviceAppService sysDeviceAppService; + @Autowired + private ServerApiService serverApiService; + @Autowired + private TenCellDeptService tenCellDeptService; + @Autowired + private TenLabelService tenLabelService; + @Autowired + private RedisUtils redisUtils; + @Autowired + private TenParentService tenParentService; + @Autowired + private TenRelationService relationService; + @Qualifier("net.shapelight.modules.tripartitePlatform.operatorPlatform.OpFeignClient") + @Autowired + private OpFeignClient opFeignClient; + @Autowired + private AppUserService appUserService; + + + @Login + @GetMapping("systeminfo") +// @ApiOperation("获取系统消息") + public R systeminfo(@LoginUser TenParent user) { + if(user == null){ + return R.error("用户不存在"); + } + List list = tenParentService.list(); + return R.ok().put("data", list); + } + + + @PostMapping("checkCellAdmin") + @ApiOperation("验证小区管理员是否正确") + @ApiImplicitParams({ + @ApiImplicitParam(name = "adminMobile", value = "管理员手机号", paramType = "query", dataType = "String", required = true), + }) + public R checkCellAdmin(@RequestBody Map params) { + String adminMobile = (String) params.get("adminMobile"); + String cellId = appUserService.checkCellAdmin(adminMobile); + String tenantId = String.valueOf(tenCellService.getById(cellId).getTenantId()); + if (cellId != null && !cellId.isEmpty()) { + Map cellMap = new HashMap<>(); + cellMap.put("cellId", cellId); + cellMap.put("tenantId",tenantId); + return R.ok().put("data", cellMap); + } else { + return R.error("验证失败,请检查输入是否正确或者联系校园管理员"); + } + } + + + @PostMapping("/registerUser") + @ApiOperation("注册用户") + @Transactional + public R registerUser(@RequestBody TenPersonEntity tenPerson) { + //1.验证用户名 + TenParent parent = tenParentService.getOne(new LambdaQueryWrapper().eq(TenParent::getUserName,tenPerson.getUsername())); + if (parent != null) { + return R.error("用户名已经注册"); + } + //2.验证手机号 + parent = tenParentService.findByMobile(tenPerson.getMobile()); + if (parent != null) { + return R.error("手机号已经注册"); + } + TenParent tenParent = new TenParent(); + parent.setUserName(tenPerson.getUsername()); + parent.setMobile(tenPerson.getMobile()); + //sha256加密 +// String salt = RandomStringUtils.randomAlphanumeric(20); +// appUser.setPassword(new Sha256Hash(entity.getPassword(), salt).toHex()); +// appUser.setSalt(salt); + parent.setPassword(DigestUtils.sha256Hex(tenPerson.getPassword())); + parent.setCreateTime(new Date()); + parent.setCellId(tenPerson.getCellId()); + tenParent.setName(tenPerson.getName()); + tenParent.setGender(tenPerson.getGender()); + tenParent.setIdCard(tenPerson.getIdCard()); + tenParent.setRegisterType(Constant.RESGISTER_TYPE_APP); + tenParentService.save(tenParent); + return R.ok(); + } + + + /** + * 下拉框选择楼栋单元 + */ + @PostMapping("/build/selectByCellId") + @ApiOperation(value = "下拉选择楼栋,通过选择小区联动查询", response = TenBuildEntity.class) + @ApiImplicitParams({ + @ApiImplicitParam(name = "cellId", value = "小区ID", paramType = "query", dataType = "String", required = true), + }) + public R selectByCellId(@RequestBody Map params) { + String cellIdStr = (String) params.get("cellId"); + Long cellId = Long.parseLong(cellIdStr); +// TenCellEntity cell = tenCellService.getById(cellId); +// String tenantId = cell.getTenantId()+""; + //Map params = new HashMap<>(); +// params.put("tenantId",tenantId+""); + List buildList = tenBuildService.selectByCellId(cellId); + for(TenBuildEntity buildEntity: buildList){ + buildEntity.setName(buildEntity.getName()+buildEntity.getUnit()+"单元"); + } + return R.ok().put("data", buildList); + } + + /** + * 下拉框选择房间 + */ + @PostMapping("/room/select") + @ApiOperation(value = "下拉选择房间名称,通过单元楼层", response = TenBuildEntity.class) + @ApiImplicitParams({ + @ApiImplicitParam(name = "cellId", value = "小区ID", paramType = "query", dataType = "String", required = true), + @ApiImplicitParam(name = "buildId", value = "楼栋ID", paramType = "query", dataType = "String", required = true), + @ApiImplicitParam(name = "layer", value = "楼层", paramType = "query", dataType = "String", required = true), + }) + public R select(@RequestBody Map params) { + Long cellId = Long.parseLong((String) params.get("cellId")); + Long buildId = Long.parseLong((String) params.get("buildId")); + Integer layer = Integer.parseInt((String) params.get("layer")); + List buildList = tenRoomService.getLayerRooms(buildId, cellId); + return R.ok().put("data", buildList); + } + + + + @Login + @PostMapping("addVisitor") + @ApiOperation("添加访客") + public R addVisitor(@LoginUser TenParent user, @RequestBody TenPersonEntity tenPerson) throws Exception { + +// public static final int PERSON_TYPE_OWNER = 5000; //业主 +// public static final int PERSON_TYPE_MEMBER = 5001; //家属住户 +// public static final int PERSON_TYPE_TENANT = 5002; //租户 +// public static final int PERSON_TYPE_GUEST = 5005; //访客 + tenPerson.setLabelId(Constant.PERSON_TYPE_GUEST); + tenPerson.setAppFlag(Constant.APP_LOGIN_NO); + + +// TenPersonEntity tenPersonEntity = tenPersonService.findByName(tenPerson.getName(), +// tenPerson.getRoomId(),tenPerson.getCellId()); +// if(tenPersonEntity!=null){ +// return R.error("姓名在此房间已存在"); +// } + + long id = new SnowflakeIdWorker().nextId(); + tenPerson.setPersonId(id); + tenPerson.setUuid(UUIDUtil.uuid()); + //tenPerson.setCellId(appUserScopeEntity.getCellId()); + //tenPerson.setTenantId(appUserScopeEntity.get()); +// tenPerson.setCreateBy(user.getUsername()); + tenPerson.setCreateTime(new Date()); + tenPerson.setRegisterType(Constant.RESGISTER_TYPE_APP); + /*Date now = new Date(); + tenPerson.setLiveStart(new Date()); + tenPerson.setLiveEnd(new Date(now.getTime()+3600000L));*/ + tenPerson.setCreateBy(user.getUserId().toString()); + tenPerson.setStatus(2); + tenPerson.setPersonType(Constant.PERSON_TYPE_GUEST); + String res; + try { + res = tenPersonService.save(tenPerson); + } catch (Exception e) { + return R.error(e.getMessage()); + } + if (res!=null) { + return R.error(res); + } + return R.ok(); + } + + + @PostMapping("/uploadImage") + @ApiOperation("上传临时人员照片") + public R uploadImage(@RequestParam("file") MultipartFile file) { + //String tenantId = getUser().getTenantId()+""; + if (file.isEmpty() || file.getSize() == 0) { + return R.error("文件不能为空"); + } + try { +// MinioClient minioClient = MinioUtil.getMinioClient(); + String extension = FilenameUtils.getExtension(file.getOriginalFilename()); //后缀名 + String fileName = "temp/" + "t_" + UUIDUtil.uuid() + "." + extension; + InputStream inputStream = file.getInputStream(); + PutObjectOptions putObjectOptions = new PutObjectOptions(inputStream.available(), -1); + putObjectOptions.setContentType(file.getContentType()); + minioClient.putObject( + minioConfig.getBucketName(), fileName, inputStream, putObjectOptions) ; + inputStream.close(); + return R.ok().put("data", fileName); + } catch (Exception e) { + return R.error(e.getMessage()); + } + } + + @Login + @PostMapping("addPerson") + @ApiOperation("管理员添加人员") + public R addPerson(@LoginUser TenParent user, @RequestBody TenPersonEntity tenPerson) throws Exception { + if(user == null){ + return R.error("用户不存在"); + } + if(tenPerson.getPersonType() == 5000 || tenPerson.getPersonType() == 5001 || tenPerson.getPersonType() == 5002){ + TenLabelEntity labelEntity = tenLabelService.getOne(new QueryWrapper() + .eq("type",tenPerson.getPersonType()) + .eq("cell_id",user.getCellId())); + if(labelEntity!=null){ + tenPerson.setLabelId(labelEntity.getLabelId().intValue()); + } + } + if(tenPerson.getPersonType() == 5000){ + tenPerson.setAppFlag(Constant.APP_LOGIN_YES); + }else{ + tenPerson.setAppFlag(Constant.APP_LOGIN_NO); + } + if(tenPerson.getIdCard()!=null){ + if(tenPerson.getIdCard().length() == 15){ + String id18 = Convert.toEighteen(tenPerson.getIdCard()); + tenPerson.setIdCard(id18); + } + } + //验证app人员是否注册 + if (tenPerson.getAppFlag()==Constant.APP_LOGIN_YES) { + //1.验证用户名 + TenParent appUser = tenParentService.getOne(new LambdaQueryWrapper().eq(TenParent::getUserName,tenPerson.getUsername())); + if (appUser!=null) { + return R.error("用户名已经注册"); + } + //2.验证手机号 + appUser = tenParentService.findByMobile(tenPerson.getMobile()); + if (appUser!=null) { + return R.error("手机号已经注册"); + } + } + TenPersonEntity tenPersonEntity = tenPersonService.findByName(tenPerson.getName(), + tenPerson.getRoomId(),tenPerson.getCellId()); + if(tenPersonEntity!=null){ + return R.error("姓名在此房间已存在"); + } + + if(tenPerson.getIdCard()!=null){ +// TenPersonEntity tenPersonIdcard = tenPersonService.findByIdCard(tenPerson.getIdCard(), +// tenPerson.getRoomId(),tenPerson.getCellId()); +// if(tenPersonIdcard!=null){ +// return R.error("身份证在此房间已存在"); +// } + List list = tenPersonService.findByIdCardAndDept(tenPerson.getIdCard(),tenPerson.getDeptId()); + if(list.size()>0){ + return R.error("身份证在此组织已存在"); + } + } + + long id = new SnowflakeIdWorker().nextId(); + tenPerson.setPersonId(id); + tenPerson.setUuid(UUIDUtil.uuid()); + //tenPerson.setTenantId(user.getTenantId()); + tenPerson.setCreateBy(user.getUserName()); + tenPerson.setCreateTime(new Date()); + tenPerson.setRegisterType(Constant.RESGISTER_TYPE_APP); + tenPerson.setStatus(Constant.PESON_SUATUS_NOMOR); + String res; + try { + res = tenPersonService.save(tenPerson); + } catch (Exception e) { + return R.error(e.getMessage()); + } + if (res!=null) { + return R.error(res); + } + return R.ok(); + } + + + @Login + @PostMapping("getPersons") + @ApiOperation("获取人员列表") + @ApiImplicitParams({ + @ApiImplicitParam(name="limit",value = "每页条数",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="page",value = "页码",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="key",value = "关键字",paramType = "query",dataType = "String",required = true), + }) + + public R getPersons(@LoginUser TenParent user, @RequestBody Map params) { + String key = (String)params.get("key"); + List relationList = null; + if(params.get("status")!=null) { + relationList = relationService.list(new LambdaQueryWrapper() + .eq(TenRelation::getParentId,user.getUserId()) + .eq(TenRelation::getStatus,params.get("status"))); + } else { + relationList = relationService.list(new LambdaQueryWrapper() + .eq(TenRelation::getParentId,user.getUserId())); + } + + + if(!relationList.isEmpty()) { + List list = relationList.stream().map(TenRelation::getStudentId).collect(Collectors.toList()); + params.put("cellId",user.getCellId()); + params.put("personIds",list.stream().distinct().collect(Collectors.toList())); + PageUtils page = tenPersonService.selectBypersonIds(params); + return R.ok().put("data",page); + } + return R.ok().put("data",new PageUtils(new ArrayList<>(),0,0,0)); + + } + + + + @Login + @PostMapping("getGuest") + @ApiOperation("业主获取访客列表") + @ApiImplicitParams({ + @ApiImplicitParam(name="limit",value = "每页条数",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="page",value = "页码",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="key",value = "关键字",paramType = "query",dataType = "String",required = true), + }) + + public R getGuest(@LoginUser TenParent user, @RequestBody Map params) { + String key = (String)params.get("key"); + params.put("cellId", user.getCellId().toString()); + params.put("createBy", user.getId().toString()); + PageUtils page = tenPersonService.selectByCreateByQueryPage(params); + return R.ok().put("data", page); + + } + + + @Login + @PostMapping("/uploadPublicImage") + @ApiOperation("上传公共照片") + public R uploadImage(@LoginUser TenParent user, @RequestParam("file") MultipartFile file) { + if(user == null){ + return R.error("用户不存在"); + } + //String tenantId = getUser().getTenantId()+""; + Long cellId = user.getCellId(); + if (file.isEmpty() || file.getSize() == 0) { + return R.error("文件不能为空"); + } + try { + String userFileUrl = globalValue.getImagesDir() + "/" + + cellId.toString() + "/" + Constant.IMAGE_DIR_REPAIR+"/"; + String extension = FilenameUtils.getExtension(file.getOriginalFilename()); //后缀名 + String fileName = userFileUrl + UUIDUtil.uuid() + "." + extension; + InputStream inputStream = file.getInputStream(); + PutObjectOptions putObjectOptions = new PutObjectOptions(inputStream.available(), -1); + putObjectOptions.setContentType(file.getContentType()); + minioClient.putObject( + minioConfig.getBucketName(), fileName, inputStream, putObjectOptions); + inputStream.close(); + return R.ok().put("data", fileName); + } catch (Exception e) { + return R.error(e.getMessage()); + } + } + +// @Login + @PostMapping("/getFeature") + @ApiOperation("获取版本") + @ApiImplicitParams({ + @ApiImplicitParam(name = "appName", value = "XAEJ", paramType = "query", dataType = "String", required = true), + }) + public R getFeature(@LoginUser TenParent user, @RequestBody Map param) { + String appName = (String)param.get("appName"); + SysDeviceAppEntity app = sysDeviceAppService.getOne(new QueryWrapper() + .eq("app_name",appName)); + String version = "1"; + if(app!=null){ + version = app.getVersion(); + } + return R.ok().put("data",version); + } + + @Login + @PostMapping("/binding") + @ApiOperation("绑定学员") + @ApiImplicitParams({ + @ApiImplicitParam(name = "cellId", value = "学校ID", paramType = "query", dataType = "String", required = true), + @ApiImplicitParam(name = "studentId", value = "学号", paramType = "query", dataType = "String", required = true) + }) + public R binding(@LoginUser TenParent user, @RequestBody Map params) { + Long cellId = user.getCellId(); + if(params.get("ryId")==null) { + return R.error("请输入学号"); + } + if(params.get("idCard")==null) { + return R.error("请输入身份证号"); + } + String ryId = params.get("ryId").toString(); + String idCard = params.get("idCard").toString(); + TenPersonEntity entity = tenPersonService.getByRyId(ryId,cellId,idCard); + if(entity == null) { + return R.error("学生未录入"); + } + TenRelation tenRelation =relationService.getOne(new LambdaQueryWrapper() + .eq(TenRelation::getParentId,user.getUserId()) + .eq(TenRelation::getStudentId,entity.getPersonId())); + if(tenRelation!=null) { + if(tenRelation.getStatus()==2) { + return R.error("您已提交绑定审批,请耐心等待"); + } + if(tenRelation.getStatus()==1) { + return R.error("该学生已和您绑定"); + } + } + TenRelation relation = new TenRelation(); + relation.setParentId(user.getUserId()); + relation.setStudentId(entity.getPersonId()); + relation.setCreateTime(new Date()); + relation.setStatus(2); + relation.setRelation(params.get("salutation").toString()); + relationService.save(relation); + return R.ok(); + } + + @Login + @PostMapping("/remove") + public R removeBind(@LoginUser TenParent user, @RequestBody List> params) { + //AppUserScopeEntity userScopeEntity = appUserScopeService.getById(user.getCurrentScopeId()); + /* Map opParams = new HashMap<>(); + opParams.put("operation","delUserContactData"); + opParams.put("accountNumber",globalValue.accountNumber); + opParams.put("passKey", KeysEntity.passKey); + opParams.put("empowerText",KeysEntity.empowerText); + List> dataInfo = new ArrayList<>(); + Map info = new HashMap<>(); + List list = new ArrayList<>(); + params.forEach(item -> { + list.add(item.get("personId").toString()); + }); + List relations = relationService.list(new LambdaQueryWrapper() + .eq(TenRelation::getParentId,user.getUserId()) + .in(TenRelation::getStudentId,list)); + relations.forEach(relation -> { + info.put("objectUuid",relation.getId().toString()); + dataInfo.add(info); + }); + opParams.put("dataInfo",dataInfo); + JSONObject jsonObject = opFeignClient.submitData(opParams); + if(!jsonObject.getString("shrgStatus").equals("S")) { + return R.error("同步联系人失败"); + } + if(!jsonObject.getJSONArray("errInfo").isEmpty()) { + return R.error("同步联系人失败"); + }*/ + List list = new ArrayList<>(); + params.forEach(item -> { + list.add(item.get("personId").toString()); + }); + relationService.remove(new LambdaQueryWrapper() + .eq(TenRelation::getParentId,user.getUserId()) + .in(TenRelation::getStudentId,list)); + return R.ok(); + } + + @Login + @GetMapping("/selectByCellId/{cellId}") + @ApiOperation(value = "下拉选择楼栋,通过选择小区联动查询",response = TenBuildEntity.class) + public R selectByCellId(@LoginUser TenParent user, @PathVariable("cellId") Long cellId){ + List buildList = tenBuildService.selectByCellId(cellId); +// for(TenBuildEntity buildEntity: buildList){ +// buildEntity.setName(buildEntity.getName()+buildEntity.getUnit()+"单元"); +// } + return R.ok().put("data", buildList); + } + + /** + * 下拉框选择 + */ + @Login + @GetMapping("/select/{cellId}/{buildId}") + @ApiOperation(value = "下拉选择房间名称,通过单元楼层",response = TenBuildEntity.class) + public R select(@PathVariable("cellId") Long cellId, + @PathVariable("buildId") Long buildId){ + List buildList = tenRoomService.getLayerRooms(buildId,cellId); + return R.ok().put("data", buildList); + } +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/appparent/controller/AppComm.java b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/controller/AppComm.java new file mode 100644 index 0000000..f1fd2f7 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/controller/AppComm.java @@ -0,0 +1,16 @@ +package net.shapelight.modules.appparent.controller; + +public class AppComm { + public static int FLAG_DEVICE_ALART = 2; + public static int FLAG_APP_TO_SERVER = 0; + public static int FLAG_SERVER_TO_DEVICE = 1; + public static int FLAG_RESPONSED = 3; + public static int FLAG_ALERT_MSG_DELETE = 4; + public static String STRING_ALEAM = "告警"; + public static String TYPE_MOVECAR = "movecar"; + public static String SIGNAL_STATUS_ON = "正常"; + public static String SIGNAL_STATUS_OFF = "离线"; + public static String SIGNAL_STATUS_ERROR = "异常"; + public static String SIGNAL_STATUS_INIT = "初始导入"; + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/appparent/controller/AppInfoApiController.java b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/controller/AppInfoApiController.java new file mode 100644 index 0000000..11e02eb --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/controller/AppInfoApiController.java @@ -0,0 +1,156 @@ +package net.shapelight.modules.appparent.controller; + + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import io.minio.MinioClient; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import net.shapelight.common.config.GlobalValue; +import net.shapelight.common.config.MinioConfig; +import net.shapelight.common.utils.Constant; +import net.shapelight.common.utils.MyDateUtils; +import net.shapelight.common.utils.PageUtils; +import net.shapelight.common.utils.R; +import net.shapelight.modules.appparent.annotation.Login; +import net.shapelight.modules.appparent.annotation.LoginUser; +import net.shapelight.modules.appparent.entity.AppUserEntity; +import net.shapelight.modules.appparent.entity.AppUserScopeEntity; +import net.shapelight.modules.appparent.service.AppUserScopeService; +import net.shapelight.modules.appparent.service.AppUserService; +import net.shapelight.modules.ten.entity.*; +import net.shapelight.modules.ten.service.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * APP测试接口 + */ +@RestController +@RequestMapping("/parent/app") +@Api("APP接口") +public class AppInfoApiController { + + @Autowired + private TenCellService tenCellService; + @Autowired + private AppUserScopeService appUserScopeService; + @Autowired + private TenNoticeService tenNoticeService; + @Autowired + private TenRecordService tenRecordService; + @Autowired + private TenRelationService relationService; + + + @Login + @PostMapping("listNotice") + @ApiOperation(value = "查看公告",response = TenNoticeEntity.class) +// @ApiImplicitParams({ +// @ApiImplicitParam(name="cellId",value = "小区",paramType = "query",dataType = "String",required = true) +// }) + public R listNotice(@LoginUser TenParent user, @RequestBody Map params) { + if(user == null){ + return R.error("用户不存在"); + } + Long cellId = user.getCellId(); + params.put("cellId",cellId); + List list = new ArrayList<>(); + //业主显示发不时间到了的公告 + list = tenNoticeService.list(new QueryWrapper() + .eq("cell_id", cellId) + .le("publish_time", new Date()) + .orderByDesc("publish_time") + .last("LIMIT 10")); + return R.ok().put("data", list); + } + + + @Login + @PostMapping("listNoticeTop") + @ApiOperation(value = "查看公告一条",response = TenNoticeEntity.class) + public R listNoticeTop(@LoginUser TenParent user, @RequestBody Map params) { + if(user == null){ + return R.error("用户不存在"); + } + Long cellId = user.getCellId(); + params.put("cellId",cellId); + List list = tenNoticeService.list(new QueryWrapper() + .eq("cell_id",cellId) + .le("publish_time",new Date()) + .orderByDesc("publish_time") + .last("LIMIT 1")); + return R.ok().put("data",list); + } + + @Login + @PostMapping("/openDoorRecordList") + @ApiOperation(value = "查询开门记录分页",response = TenRecordEntity.class) + @ApiImplicitParams({ + @ApiImplicitParam(name="limit",value = "每页条数",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="page",value = "页码",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="name",value = "姓名",paramType = "query",dataType = "String",required = true), + @ApiImplicitParam(name="during",value = "时间段0当天1本周2本月",paramType = "query",dataType = "String",required = true), +// @ApiImplicitParam(name="recordTimeStart",value = "开始时间",paramType = "query",dataType = "String",required = true), +// @ApiImplicitParam(name="recordTimeEnd",value = "结束时间",paramType = "query",dataType = "String",required = true), + }) + public R openDoorRecordList(@LoginUser AppUserEntity user, @RequestBody Map params){ + if(user == null){ + return R.error("用户不存在"); + } + + AppUserScopeEntity scope = appUserScopeService.getById(user.getCurrentScopeId()); + TenCellEntity cellEntity = tenCellService.getById(scope.getCellId()); + if(cellEntity!=null){ + params.put("cellId",cellEntity.getCellId()); + int during = Integer.parseInt((String)params.get("during")); + String recordTimeStart = null; + String recordTimeEnd = null; + if(during == 0){ //当天 + recordTimeStart = MyDateUtils.getCurrentDayStartTime(); + recordTimeEnd = MyDateUtils.getCurrentDayEndTime(); + }else if(during == 1){ //本周 + recordTimeStart = MyDateUtils.getCurrentWeekStartTime(); + recordTimeEnd = MyDateUtils.getCurrentWeekEndTime(); + }else if(during == 2){ //本月 + recordTimeStart = MyDateUtils.getCurrentMonthStartTime(); + recordTimeEnd = MyDateUtils.getCurrentMonthEndTime(); + } + params.put("recordTimeStart",recordTimeStart); + params.put("recordTimeEnd",recordTimeEnd); + + ///小区管理员 + if(scope.getRoleId() == Constant.ROLE_TEN_CELL){ + params.put("cellId",scope.getCellId().toString()); + PageUtils page = tenRecordService.queryPage(params); + return R.ok().put("data", page); + } + //业主 + else if(scope.getRoleId() == Constant.PERSON_TYPE_PARENT){ + List relationList = relationService.list(new LambdaQueryWrapper() + .eq(TenRelation::getParentId,user.getUserId()).eq(TenRelation::getStatus,1)); + if(!relationList.isEmpty()) { + List list = relationList.stream().map(TenRelation::getStudentId).collect(Collectors.toList()); + params.put("tenantId",user.getTenantId()); + params.put("personIds",list); + PageUtils page = tenRecordService.getByPersonIds(params); + return R.ok().put("data", page); + } + } + } + + return R.ok().put("data",new PageUtils(new ArrayList<>(),0,0,0)); + } + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/appparent/controller/AppLoginController.java b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/controller/AppLoginController.java new file mode 100644 index 0000000..563f202 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/controller/AppLoginController.java @@ -0,0 +1,96 @@ +package net.shapelight.modules.appparent.controller; + + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import net.shapelight.common.utils.IpUtils; +import net.shapelight.common.utils.R; +import net.shapelight.common.utils.ServletUtils; +import net.shapelight.common.validator.ValidatorUtils; +import net.shapelight.modules.appparent.annotation.Login; +import net.shapelight.modules.appparent.annotation.LoginUser; +import net.shapelight.modules.appparent.entity.AppUserEntity; +import net.shapelight.modules.appparent.form.LoginForm; +import net.shapelight.modules.appparent.service.AppUserService; +import net.shapelight.modules.appparent.utils.JwtUtils; +import net.shapelight.modules.ten.entity.TenParent; +import net.shapelight.modules.ten.service.TenParentService; +import net.shapelight.modules.vo.TokenVo; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.Date; + +/** + * APP登录授权 + */ +@RestController +@RequestMapping("/parent/app") +@Api("APP登录接口") +public class AppLoginController { + @Autowired + private AppUserService userService; + @Autowired + private JwtUtils jwtUtils; +// @Autowired +// PushService pushService; + @Autowired + TenParentService parentService; + + /** + * 登录 + */ + @PostMapping("login") + @ApiOperation("登录") + public R login(@RequestBody LoginForm form){ + //表单校验 + ValidatorUtils.validateEntity(form); + //用户登录 + TenParent user = parentService.login(form); + //生成token + String token = jwtUtils.generateToken(user.getUserId()); + TokenVo tokenVo = new TokenVo(); + tokenVo.setToken(token); + tokenVo.setExpire((int)jwtUtils.getExpire()); + String ip = IpUtils.getIpAddr(ServletUtils.getRequest()); + user.setLoginTime(new Date()); + user.setLoginIp(ip); + parentService.saveOrUpdate(user); + return R.ok().put("data",tokenVo); + + } + /* + * Token登陆 + */ + @Login + @GetMapping("checkin") + @ApiOperation("获取用户信息") + public R userInfo(@LoginUser TenParent user){ +// if(user == null){ +// return R.error(401,"用户不存在"); +// } + if(user == null){ + return R.error("用户不存在"); + } + String ip = IpUtils.getIpAddr(ServletUtils.getRequest()); + user.setLoginTime(new Date()); + user.setLoginIp(ip); + //TenParent parent = parentService.getOne(new LambdaQueryWrapper().eq(TenParent::getUserId,user.getUserId())); + //user.setParent(parent); + parentService.saveOrUpdate(user); + return R.ok().put("data", user); + } + +// @Login +// @PostMapping("logout") +// @ApiOperation("退出登陆") +// //public R updateMobile(@LoginUser UserEntity user,HttpServletRequest request,String mobile, String password,String smscode){ +// public R logout(HttpServletRequest request, @LoginUser AppUserEntity user){ +// //删除这个用户的rid +// String token = request.getHeader("token"); +//// pushService.deleteFromToken(token); +// return R.ok(); +// } + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/appparent/controller/AppRegisterController.java b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/controller/AppRegisterController.java new file mode 100644 index 0000000..3b3f05e --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/controller/AppRegisterController.java @@ -0,0 +1,266 @@ +package net.shapelight.modules.appparent.controller; + + +//import net.shapelight.common.utils.AliyunSmsUtils; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import net.shapelight.common.utils.R; +import net.shapelight.common.utils.RedisUtils; +import net.shapelight.modules.appparent.annotation.Login; +import net.shapelight.modules.appparent.annotation.LoginUser; +import net.shapelight.modules.appparent.entity.AppUserEntity; +import net.shapelight.modules.appparent.service.AppUserService; +import net.shapelight.modules.appparent.utils.MonyunSmsUtils; +import net.shapelight.modules.ten.entity.TenParent; +import net.shapelight.modules.ten.service.TenParentService; +import org.apache.commons.codec.digest.DigestUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.HashMap; +import java.util.Map; +import java.util.Random; + +/** + * 注册 + */ +@RestController +@RequestMapping("/parent/app") +@Api("APP注册接口") +public class AppRegisterController { + @Autowired + private AppUserService userService; + @Autowired + private RedisUtils redisUtils; + @Autowired + private TenParentService parentService; + + + @PostMapping("sendsms") + @ApiOperation("获取验证码") + @ApiImplicitParams({ + @ApiImplicitParam(name = "mobile", value = "手机号", paramType = "query", dataType = "String", required = true), + @ApiImplicitParam(name = "type", value = "类型1注册2忘记密码", paramType = "query", dataType = "String", required = true) + }) + public R sendsms(@RequestBody Map params) { + //验证手机是否注册 + String mobile = (String) params.get("mobile"); + int type = (Integer) params.get("type"); + //type=1 //注册 + //type=2 //忘记密码 + //type=1 //修改绑定的手机 + if (type == 1) {//注册//修改绑定的手机 + AppUserEntity user = userService.findByMobile(mobile); + if (user != null) { + return R.error("手机号码已注册"); + } + } else if (type == 2) {//忘记密码 + AppUserEntity user = userService.findByMobile(mobile); + if (user == null) { + return R.error("当前手机号未被使用"); + } + } else { + return R.error("未知类型"); + } + String verifyCode = String.valueOf(new Random().nextInt(899999) + 100000); + int result = MonyunSmsUtils.sendSms(mobile, verifyCode); + Map resMap = new HashMap<>(); + resMap.put("result", result); + if (result != 0) { + return R.error(result+""); + } + redisUtils.set(mobile,verifyCode,120L); + return R.ok(); + } + +// @PostMapping("register") +// public R register(@RequestBody Map map) { +// String mobile = (String) map.get("mobile"); +// String password = (String) map.get("password"); +// String smscode = (String) map.get("smscode"); +// +// JSONObject SessionJson = (JSONObject) request.getSession().getAttribute("verifyCode"); +// +// if (SessionJson == null) { +// return R.error("请先发送验证码"); +// } +// String s_msg_id = SessionJson.getString("msg_id"); +// String s_mobile = SessionJson.getString("mobile"); +// String verifyCode = SessionJson.getString("verifyCode"); +// +// if (!verifyCode.equals(smscode)) { +// return R.error("验证码错误"); +// } +// +// AppUserEntity user = new AppUserEntity(); +// user.setMobile(mobile); +// user.setUsername(mobile); +// user.setPassword(DigestUtils.sha256Hex(password)); +// user.setCreateTime(new Date()); +// userService.save(user); +// request.getSession().setAttribute("verifyCode", null); +// return R.ok(); +// } + + @PostMapping("checkCode") + @ApiOperation("检测验证码") + @ApiImplicitParams({ + @ApiImplicitParam(name = "mobile", value = "手机号", paramType = "query", dataType = "String", required = true), + @ApiImplicitParam(name = "smscode", value = "验证码", paramType = "query", dataType = "String", required = true) + }) + public R checkCode(@RequestBody Map map) { + String mobile = (String) map.get("mobile"); + String smscode = (String) map.get("smscode"); + +// JSONObject SessionJson = (JSONObject) request.getSession().getAttribute("verifyCode"); + + String verifyCode = (String)redisUtils.get(mobile); + +// if (SessionJson == null) { +// return R.error("请先发送验证码"); +// } +// String s_msg_id = SessionJson.getString("msg_id"); +// String s_mobile = SessionJson.getString("mobile"); +// String verifyCode = SessionJson.getString("verifyCode"); +// String rMobile = SessionJson.getString("mobile"); + + if (verifyCode!=null && !verifyCode.equals(smscode)) { + return R.error("验证码错误"); + } + + if (verifyCode == null){ + return R.error("验证码已过期"); + } +// if (!rMobile.equals(mobile)) { +// return R.error("请输入验证码对应的手机号"); +// } + return R.ok(); + } + + + @PostMapping("forgetPassword") + @ApiOperation("忘记密码重置密码") + @ApiImplicitParams({ + @ApiImplicitParam(name = "mobile", value = "手机号", paramType = "query", dataType = "String", required = true), + @ApiImplicitParam(name = "password", value = "密码", paramType = "query", dataType = "String", required = true), + @ApiImplicitParam(name = "smscode", value = "验证码", paramType = "query", dataType = "String", required = true) + }) + public R forgetPassword(HttpServletRequest request, @RequestBody Map map) { + String mobile = (String) map.get("mobile"); + String password = (String) map.get("password"); +// String smscode = (String) map.get("smscode"); + +// JSONObject SessionJson = (JSONObject) request.getSession().getAttribute("verifyCode"); + +// if (SessionJson == null) { +// return R.error("请先发送验证吗"); +// } +// String s_msg_id = SessionJson.getString("msg_id"); +// String s_mobile = SessionJson.getString("mobile"); +// String verifyCode = SessionJson.getString("verifyCode"); +// +// if (!verifyCode.equals(smscode)) { +// return R.error("验证码错误"); +// } + + TenParent user = parentService.findByMobile(mobile); + user.setPassword(DigestUtils.sha256Hex(password)); + parentService.saveOrUpdate(user); + return R.ok(); + } + + @Login + @PostMapping("updatePassword") + @ApiOperation("修改密码") + @ApiImplicitParams({ + @ApiImplicitParam(name = "oldPassword", value = "旧密码", paramType = "query", dataType = "String", required = true), + @ApiImplicitParam(name = "newPassword", value = "新密码", paramType = "query", dataType = "String", required = true), + }) + //public R updatePassword(@LoginUser UserEntity user, String oldPassword,String newPassword){ + public R updatePassword(@LoginUser TenParent user, @RequestBody Map map) { + if(user == null){ + return R.error("用户不存在"); + } + String oldPassword = (String) map.get("oldPassword"); + String newPassword = (String) map.get("newPassword"); + if (user.getPassword().equals(DigestUtils.sha256Hex(oldPassword))) { + user.setPassword(DigestUtils.sha256Hex(newPassword)); + if (oldPassword.equals(newPassword)) { + return R.error("新密码和旧密码不能相同"); + } + parentService.saveOrUpdate(user); + return R.ok(); + } else { + return R.error("初始密码不正确"); + } + } + +/* + @Login + @PostMapping("updateMobile") + @ApiOperation("修改绑定的手机") + public R updateMobile(@LoginUser UserEntity user,HttpServletRequest request,@RequestBody Map map){ + String oldMoblie = user.getMobile(); + int delFlag = 0; + String mobile = (String)map.get("mobile"); + String password = (String)map.get("password"); + String smscode = (String)map.get("smscode"); + + JSONObject SessionJson = (JSONObject)request.getSession().getAttribute("verifyCode"); + + if(SessionJson==null) { + return R.error("请先发送验证吗"); + } + String s_msg_id = SessionJson.getString("msg_id"); + String s_mobile = SessionJson.getString("mobile"); + String res = JSMSUtil.sendValidSMSCode(s_msg_id,smscode); + if(res.equals("")){ + return R.error("无法验证"); + } + + JSONObject vjson = JSONObject.parseObject(res); + boolean valid = vjson.getBoolean("is_valid"); + if(!valid){ + String err_msg = JSONObject.parseObject(vjson.getString("error")).getString("message"); + return R.error("验证码错误"); + } + + if(user.getPassword().equals(DigestUtils.sha256Hex(password))) { + //将用户信息存入数据库 + user.setMobile(mobile); + user.setUsername(mobile); + user.setPassword(DigestUtils.sha256Hex(password)); + user.setCreateTime(new Date()); + userService.saveOrUpdate(user); + + + List bl = bindService.queryByMoblie(oldMoblie,delFlag); + for(int i = 0;i + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package net.shapelight.modules.appparent.form; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * 登录表单 + * + */ +@ApiModel(value = "登录表单") +@Data +public class LoginForm { + @ApiModelProperty(value = "手机号") + @NotBlank(message="手机号不能为空") + private String mobile; + + @ApiModelProperty(value = "密码") + @NotBlank(message="密码不能为空") + private String password; + +// @ApiModelProperty(value = "推送ID") +// private String registrationId; + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/appparent/form/RegisterForm.java b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/form/RegisterForm.java new file mode 100644 index 0000000..cc5a14d --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/form/RegisterForm.java @@ -0,0 +1,40 @@ +/** + * Copyright 2018 http://www.gfirefly.com + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package net.shapelight.modules.appparent.form; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * 注册表单 + * + */ +@Data +@ApiModel(value = "注册表单") +public class RegisterForm { + @ApiModelProperty(value = "手机号") + @NotBlank(message="手机号不能为空") + private String mobile; + + @ApiModelProperty(value = "密码") + @NotBlank(message="密码不能为空") + private String password; + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/appparent/form/RegisterSmsForm.java b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/form/RegisterSmsForm.java new file mode 100644 index 0000000..245668a --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/form/RegisterSmsForm.java @@ -0,0 +1,40 @@ +/** + * Copyright 2018 http://www.gfirefly.com + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package net.shapelight.modules.appparent.form; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +/** + * 注册表单 + */ +@Data +@ApiModel(value = "注册表单") +public class RegisterSmsForm { + @ApiModelProperty(value = "手机号") + @NotBlank(message="手机号不能为空") + private String mobile; + + @ApiModelProperty(value = "密码") + @NotBlank(message="密码不能为空") + private String password; + + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/appparent/interceptor/AuthorizationInterceptor.java b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/interceptor/AuthorizationInterceptor.java new file mode 100644 index 0000000..6b5a619 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/interceptor/AuthorizationInterceptor.java @@ -0,0 +1,62 @@ +package net.shapelight.modules.appparent.interceptor; + + +import io.jsonwebtoken.Claims; +import net.shapelight.common.exception.RRException; +import net.shapelight.modules.appparent.annotation.Login; +import net.shapelight.modules.appparent.utils.JwtUtils; +import org.apache.commons.lang.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Component; +import org.springframework.web.method.HandlerMethod; +import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * 权限(Token)验证 + */ +@Component +public class AuthorizationInterceptor extends HandlerInterceptorAdapter { + @Autowired + private JwtUtils jwtUtils; + + public static final String USER_KEY = "userId"; + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + Login annotation; + if(handler instanceof HandlerMethod) { + annotation = ((HandlerMethod) handler).getMethodAnnotation(Login.class); + }else{ + return true; + } + + if(annotation == null){ + return true; + } + + //获取用户凭证 + String token = request.getHeader(jwtUtils.getHeader()); + if(StringUtils.isBlank(token)){ + token = request.getParameter(jwtUtils.getHeader()); + } + + //凭证为空 + if(StringUtils.isBlank(token)){ + throw new RRException(jwtUtils.getHeader() + "不能为空", HttpStatus.UNAUTHORIZED.value()); + } + + Claims claims = jwtUtils.getClaimByToken(token); + if(claims == null || jwtUtils.isTokenExpired(claims.getExpiration())){ + throw new RRException(jwtUtils.getHeader() + "失效,请重新登录", HttpStatus.UNAUTHORIZED.value()); + } + + //设置userId到request里,后续根据userId,获取用户信息 + request.setAttribute(USER_KEY, Long.parseLong(claims.getSubject())); + + return true; + } +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/appparent/resolver/LoginUserHandlerMethodArgumentResolver.java b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/resolver/LoginUserHandlerMethodArgumentResolver.java new file mode 100644 index 0000000..37dd2b9 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/resolver/LoginUserHandlerMethodArgumentResolver.java @@ -0,0 +1,44 @@ +package net.shapelight.modules.appparent.resolver; + +import net.shapelight.modules.appparent.annotation.LoginUser; +import net.shapelight.modules.appparent.interceptor.AuthorizationInterceptor; +import net.shapelight.modules.ten.entity.TenParent; +import net.shapelight.modules.ten.service.TenParentService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.MethodParameter; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.support.WebDataBinderFactory; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.method.support.HandlerMethodArgumentResolver; +import org.springframework.web.method.support.ModelAndViewContainer; + +/** + * 有@LoginUser注解的方法参数,注入当前登录用户 + */ +@Component +public class LoginUserHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver { + @Autowired + private TenParentService parentService; + + @Override + public boolean supportsParameter(MethodParameter parameter) { + return parameter.getParameterType().isAssignableFrom(TenParent.class) && parameter.hasParameterAnnotation(LoginUser.class); + } + + @Override + public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer container, + NativeWebRequest request, WebDataBinderFactory factory) throws Exception { + //获取用户ID + Object object = request.getAttribute(AuthorizationInterceptor.USER_KEY, RequestAttributes.SCOPE_REQUEST); + if(object == null){ + return null; + } + + //获取用户信息 + //UserEntity user = userService.selectById((Long)object); + TenParent user = parentService.getById((Long)object); + + return user; + } +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/appparent/utils/AliyunSmsUtils.java b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/utils/AliyunSmsUtils.java new file mode 100644 index 0000000..298ea8b --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/utils/AliyunSmsUtils.java @@ -0,0 +1,143 @@ +package net.shapelight.modules.appparent.utils; + +/** + + * 阿里云短信服务: + + * 注意:需要 签名名称、模版CODE 以及 RAM访问控制中的 AccessKeyID 和 AccessKeySecret + + */ + +public class AliyunSmsUtils { + +// protected static final Logger LOG = LoggerFactory.getLogger(JSMSExample.class); +// +// //产品名称:云通信短信API产品,开发者无需替换 +// static final String product = "Dysmsapi"; +// //产品域名,开发者无需替换 +// static final String domain = "dysmsapi.aliyuncs.com"; +// // TODO 此处需要替换成开发者自己的AK(在阿里云访问控制台寻找) +// static final String accessKeyId = "LTAI7uAVsj2pgLJA"; // TODO 修改成自己的 +// static final String accessKeySecret = "NjPbUUCruxZIrhDeYBlMi62JKN94pf"; // TODO 修改成自己的 +// static final String signName = "智慧挪车"; +// static final String templateCode = "SMS_162732858"; +// +// public static String sendSms(String telephone, String code) throws ClientException { +// //可自助调整超时时间 +// System.setProperty("sun.net.client.defaultConnectTimeout", "10000"); +// System.setProperty("sun.net.client.defaultReadTimeout", "10000"); +// //初始化acsClient,暂不支持region化 +// IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret); +// DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain); +// IAcsClient acsClient = new DefaultAcsClient(profile); +// //组装请求对象-具体描述见控制台-文档部分内容 +// SendSmsRequest request = new SendSmsRequest(); +// //必填:待发送手机号 +// request.setPhoneNumbers(telephone); +// //必填:短信签名-可在短信控制台中找到 +// request.setSignName(signName); +// //必填:短信模板-可在短信控制台中找到 +// request.setTemplateCode(templateCode); +// //可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为 +//// request.setTemplateParam("{\"name\":\"Tom\", \"code\":\"123\"}"); +// request.setTemplateParam("{\"code\":\"" + code + "\"}"); +// //选填-上行短信扩展码(无特殊需求用户请忽略此字段) +// //request.setSmsUpExtendCode("90997"); +// //可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者 +// //request.setOutId("90999"); +// //hint 此处可能会抛出异常,注意catch +// SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request); +// if(sendSmsResponse.getCode()!= null && sendSmsResponse.getCode().equals("OK")){ +// //System.out.println("短信发送成功!"); +// return "OK"; +// }else { +// //System.out.println("短信发送失败!"); +// LOG.error("SMS-Error:"+"Code=" + sendSmsResponse.getCode()+" Message=" + sendSmsResponse.getMessage()); +// return sendSmsResponse.getMessage(); +// } +// } + + + + + +// public static void main(String[] args) throws ClientException, InterruptedException { +// +// String verifyCode = String.valueOf(new Random().nextInt(899999) + 100000); +// +// System.out.println("发送的验证码为:"+verifyCode); +// +// //发短信 +// String response =sendSms("158",verifyCode); // TODO 填写你需要测试的手机号码 +// System.out.println("短信接口返回的数据----------------"+response); +///* +// SendSmsResponse response =sendSms("xxx",verifyCode); // TODO 填写你需要测试的手机号码 +// +// System.out.println("短信接口返回的数据----------------"); +// +// System.out.println("Code=" + response.getCode()); +// +// System.out.println("Message=" + response.getMessage()); +// +// System.out.println("RequestId=" + response.getRequestId()); +// +// System.out.println("BizId=" + response.getBizId()); +//*/ +// +// +// /* 不删 留着 以后可能有用 +// +// System.out.println(" ============================================== "); +// +// Thread.sleep(3000L); +// +// //查明细 +// +// if(response.getCode() != null && response.getCode().equals("OK")) { +// +// QuerySendDetailsResponse querySendDetailsResponse = querySendDetails(response.getBizId()); +// +// System.out.println("短信明细查询接口返回数据----------------"); +// +// System.out.println("Code=" + querySendDetailsResponse.getCode()); +// +// System.out.println("Message=" + querySendDetailsResponse.getMessage()); +// +// int i = 0; +// +// for(QuerySendDetailsResponse.SmsSendDetailDTO smsSendDetailDTO : querySendDetailsResponse.getSmsSendDetailDTOs()) +// +// { +// +// System.out.println("SmsSendDetailDTO["+i+"]:"); +// +// System.out.println("Content=" + smsSendDetailDTO.getContent()); +// +// System.out.println("ErrCode=" + smsSendDetailDTO.getErrCode()); +// +// System.out.println("OutId=" + smsSendDetailDTO.getOutId()); +// +// System.out.println("PhoneNum=" + smsSendDetailDTO.getPhoneNum()); +// +// System.out.println("ReceiveDate=" + smsSendDetailDTO.getReceiveDate()); +// +// System.out.println("SendDate=" + smsSendDetailDTO.getSendDate()); +// +// System.out.println("SendStatus=" + smsSendDetailDTO.getSendStatus()); +// +// System.out.println("Template=" + smsSendDetailDTO.getTemplateCode()); +// +// } +// +// System.out.println("TotalCount=" + querySendDetailsResponse.getTotalCount()); +// +// System.out.println("RequestId=" + querySendDetailsResponse.getRequestId()); +// +// }*/ +// +// +// +// } + + +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/appparent/utils/JwtUtils.java b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/utils/JwtUtils.java new file mode 100644 index 0000000..a6c6a73 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/utils/JwtUtils.java @@ -0,0 +1,85 @@ +package net.shapelight.modules.appparent.utils; + +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +import java.util.Date; + +/** + * jwt工具类 + */ +@ConfigurationProperties(prefix = "shapelight.jwt") +@Component +public class JwtUtils { + private Logger logger = LoggerFactory.getLogger(getClass()); + + private String secret; + private long expire; + private String header; + + /** + * 生成jwt token + */ + public String generateToken(long userId) { + Date nowDate = new Date(); + //过期时间 + Date expireDate = new Date(nowDate.getTime() + expire * 1000); + + return Jwts.builder() + .setHeaderParam("typ", "JWT") + .setSubject(userId+"") + .setIssuedAt(nowDate) + .setExpiration(expireDate) + .signWith(SignatureAlgorithm.HS512, secret) + .compact(); + } + + public Claims getClaimByToken(String token) { + try { + return Jwts.parser() + .setSigningKey(secret) + .parseClaimsJws(token) + .getBody(); + }catch (Exception e){ + logger.debug("validate is token error ", e); + return null; + } + } + + /** + * token是否过期 + * @return true:过期 + */ + public boolean isTokenExpired(Date expiration) { + return expiration.before(new Date()); + } + + public String getSecret() { + return secret; + } + + public void setSecret(String secret) { + this.secret = secret; + } + + public long getExpire() { + return expire; + } + + public void setExpire(long expire) { + this.expire = expire; + } + + public String getHeader() { + return header; + } + + public void setHeader(String header) { + this.header = header; + } +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/appparent/utils/MonyunSmsUtils.java b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/utils/MonyunSmsUtils.java new file mode 100644 index 0000000..6422423 --- /dev/null +++ b/shapelight-admin/src/main/java/net/shapelight/modules/appparent/utils/MonyunSmsUtils.java @@ -0,0 +1,50 @@ +package net.shapelight.modules.appparent.utils; + + +import com.alibaba.fastjson.JSONObject; +import lombok.extern.slf4j.Slf4j; + +import java.net.URLEncoder; + +import static net.shapelight.common.utils.RestTemplateUtils.postHttp; + +/** + */ + +@Slf4j +public class MonyunSmsUtils { + public static final String apikey = "9fa361745374a7acd777e923fbe564aa"; + public static final String URL = "http://api01.monyun.cn:7901/sms/v2/std/single_send"; + + /** + * + * @param mobile + * @param code + * @return 0 成功 其他失败 + */ + public static int sendSms(String mobile, String code) { + JSONObject jsobj1 = new JSONObject(); + jsobj1.put("apikey", apikey); + jsobj1.put("mobile", mobile); + String con = "您的验证码是"+code+",在3分钟内输入有效。如非本人操作请忽略此短信。"; + try { + jsobj1.put("content",URLEncoder.encode(con, "GBK")); + }catch (Exception e){ + e.printStackTrace(); + } + String res = postHttp(URL,jsobj1); + JSONObject resObj = JSONObject.parseObject(res); + int r = -1; + if(resObj.get("result")!=null){ + r = (Integer)resObj.get("result"); + } + log.info(res); + return r; + } + + + public static void main(String args[]){ + int res = sendSms("158290","123456"); + log.debug("result:"+res); + } +} diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenBuildController.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenBuildController.java index 369ce94..6d3699c 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenBuildController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenBuildController.java @@ -160,7 +160,7 @@ public class TenBuildController extends AbstractController { gradeCode String[0-50] 年级编码 年级编码传递请看附录A 必传*/ - Map params = new HashMap<>(); + /* Map params = new HashMap<>(); params.put("operation","editGradeData"); params.put("accountNumber",accountNumber); params.put("passKey", KeysEntity.passKey); @@ -176,7 +176,7 @@ public class TenBuildController extends AbstractController { } if(jsonObject.getJSONArray("errInfo")!=null &&!jsonObject.getJSONArray("errInfo").isEmpty()) { return R.error(tenBuild.getName() + "同步失败"); - } + }*/ long id = new SnowflakeIdWorker().nextId(); tenBuild.setBuildId(id); tenBuild.setTenantId(getUser().getTenantId()); @@ -198,7 +198,7 @@ public class TenBuildController extends AbstractController { tenBuild.setTenantId(getUser().getTenantId()); tenBuild.setLastUpdateBy(getUser().getUsername()); tenBuild.setLastUpdateTime(new Date()); - Map params = new HashMap<>(); + /* Map params = new HashMap<>(); params.put("operation","editGradeData"); params.put("accountNumber",accountNumber); params.put("passKey", KeysEntity.passKey); @@ -214,7 +214,7 @@ public class TenBuildController extends AbstractController { } if(jsonObject.getJSONArray("errInfo")!=null &&!jsonObject.getJSONArray("errInfo").isEmpty()) { return R.error("修改年级失败"); - } + }*/ tenBuildService.updateById(tenBuild); return R.ok(); @@ -233,7 +233,6 @@ public class TenBuildController extends AbstractController { }) @Transactional public R delete(@RequestBody List> params){ - JSONArray jsonArray = new JSONArray(); for(Map param: params){ Long buildId = Long.parseLong(param.get("buildId")); Long cellId = Long.parseLong(param.get("cellId")); @@ -241,12 +240,8 @@ public class TenBuildController extends AbstractController { if (pCount>0) { return R.error("当前年级有"+pCount+"个学生,请先删除学生"); } - TenBuildEntity tenBuild = tenBuildService.getById(buildId,cellId); - Map grade = new HashMap<>(); - grade.put("gradeCode",tenBuild.getNumber()); - jsonArray.add(grade); } - Map gradeParams = new HashMap<>(); + /* Map gradeParams = new HashMap<>(); gradeParams.put("operation","delGradeData"); gradeParams.put("accountNumber",accountNumber); gradeParams.put("passKey", KeysEntity.passKey); @@ -260,7 +255,7 @@ public class TenBuildController extends AbstractController { return R.error(jsonObject.getJSONArray("errInfo") + "删除失败"); - } + }*/ tenBuildService.removeByIdList(params); return R.ok(); } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenParentController.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenParentController.java index 56f5781..6f36669 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenParentController.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/controller/TenParentController.java @@ -70,35 +70,35 @@ public class TenParentController { @PostMapping("/delete") @Transactional public R deleteParent(@RequestBody List> params) throws Exception { - Map opParams = new HashMap<>(); + /*Map opParams = new HashMap<>(); opParams.put("operation","delUserContactData"); opParams.put("accountNumber",globalValue.accountNumber); opParams.put("passKey", KeysEntity.passKey); opParams.put("empowerText",KeysEntity.empowerText); List> dataInfo = new ArrayList<>(); - Map info = new HashMap<>(); + Map info = new HashMap<>();*/ params.forEach(item -> { - TenParent tenParent = tenParentService.getById(item.get("id")); + /* TenParent tenParent = tenParentService.getById(item.get("id")); List relations = relationService.list(new LambdaQueryWrapper().eq(TenRelation::getParentId,tenParent.getUserId())); List ids = relations.stream().map(TenRelation::getId).collect(Collectors.toList()); ids.stream().forEach(id -> { info.put("objectUuid",id.toString()); }); - dataInfo.add(info); + dataInfo.add(info);*/ tenParentService.removeById(item.get("id")); - appUserService.removeById(tenParent.getUserId()); + /*appUserService.removeById(tenParent.getUserId()); appUserScopeService.remove(new LambdaQueryWrapper() - .eq(AppUserScopeEntity::getUserId,tenParent.getUserId())); - relationService.remove(new LambdaQueryWrapper().eq(TenRelation::getParentId,tenParent.getUserId())); + .eq(AppUserScopeEntity::getUserId,tenParent.getUserId()));*/ + relationService.remove(new LambdaQueryWrapper().eq(TenRelation::getParentId,item.get("id"))); }); - opParams.put("dataInfo",dataInfo); + /*opParams.put("dataInfo",dataInfo); JSONObject jsonObject = opFeignClient.submitData(opParams); if(!jsonObject.getString("shrgStatus").equals("S")) { return R.error("同步联系人失败"); } if(!jsonObject.getJSONArray("errInfo").isEmpty()) { return R.error("同步联系人失败"); - } + }*/ return R.ok(); } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenParent.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenParent.java index 53260de..9f99dfa 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenParent.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/entity/TenParent.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import java.io.Serializable; +import java.util.Date; /** * @@ -40,4 +41,18 @@ public class TenParent implements Serializable { private Integer registerType; private Long userId; + + private String mobile; + + private String password; + + private Date createTime; + + private Date loginTime; + + private String loginIp; + + private Long cellId; + + private String userName; } \ No newline at end of file diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenParentService.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenParentService.java index 3ab93e3..780e26e 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenParentService.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/TenParentService.java @@ -2,6 +2,7 @@ package net.shapelight.modules.ten.service; import com.baomidou.mybatisplus.extension.service.IService; import net.shapelight.common.utils.PageUtils; +import net.shapelight.modules.appparent.form.LoginForm; import net.shapelight.modules.ten.entity.TenParent; import java.util.Map; @@ -15,4 +16,8 @@ public interface TenParentService extends IService { PageUtils getParentList(Map params); + TenParent login(LoginForm form); + + TenParent findByMobile(String mobile); + } diff --git a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenParentServiceImpl.java b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenParentServiceImpl.java index b7fb16d..0b92e3c 100644 --- a/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenParentServiceImpl.java +++ b/shapelight-admin/src/main/java/net/shapelight/modules/ten/service/impl/TenParentServiceImpl.java @@ -1,16 +1,23 @@ package net.shapelight.modules.ten.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import net.shapelight.common.exception.RRException; import net.shapelight.common.utils.PageUtils; +import net.shapelight.common.validator.Assert; +import net.shapelight.modules.appparent.entity.AppUserEntity; +import net.shapelight.modules.appparent.form.LoginForm; import net.shapelight.modules.ten.dao.TenParentMapper; import net.shapelight.modules.ten.entity.TenParent; import net.shapelight.modules.ten.entity.TenRelation; import net.shapelight.modules.ten.service.TenParentService; import net.shapelight.modules.ten.service.TenRelationService; import net.shapelight.modules.vo.ParentVo; +import org.apache.commons.codec.digest.DigestUtils; +import org.apache.poi.ss.formula.functions.T; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -43,6 +50,25 @@ public class TenParentServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper(); + queryWrapper.eq("mobile", mobile); + //return baseMapper.selectOne(userEntity); + return baseMapper.selectOne(queryWrapper); + } }