提交 f4e7fcb0 authored 作者: 林业通's avatar 林业通

智能家居修改

上级 d6f0c88b
package tech.glinfo.enbao.common.controller; package tech.glinfo.enbao.common.controller;
import com.baidu.aip.face.AipFace; import com.baidu.aip.face.AipFace;
import tech.glinfo.enbao.common.utils.BaiDuAPIUtils; import tech.glinfo.enbao.common.utils.BaiDuApiUtils;
import tech.glinfo.enbao.common.utils.R; import tech.glinfo.enbao.common.utils.R;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
...@@ -19,7 +19,7 @@ public abstract class BdAbstractController { ...@@ -19,7 +19,7 @@ public abstract class BdAbstractController {
protected Logger logger = LoggerFactory.getLogger(getClass()); protected Logger logger = LoggerFactory.getLogger(getClass());
protected R baiduDetect(String image) { protected R baiduDetect(String image) {
AipFace apiFace = BaiDuAPIUtils.getApiFace(); AipFace apiFace = BaiDuApiUtils.getApiFace();
// 传入可选参数调用接口 // 传入可选参数调用接口
HashMap<String, String> options = new HashMap<String, String>(); HashMap<String, String> options = new HashMap<String, String>();
......
package tech.glinfo.enbao.common.utils;
import com.baidu.aip.face.AipFace;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* 百度api工具类
*/
@ConfigurationProperties(prefix = "baidu")
@Component
public class BaiDuAPIUtils {
private Logger logger = LoggerFactory.getLogger(getClass());
private static String appId;
private static String apiKey;
private static String secretKey;
public static AipFace getApiFace() {
return ApiFaceUtils.instance;
}
private static class ApiFaceUtils {
public final static AipFace instance = new AipFace(appId, apiKey, secretKey);
}
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getApiKey() {
return apiKey;
}
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
public String getSecretKey() {
return secretKey;
}
public void setSecretKey(String secretKey) {
this.secretKey = secretKey;
}
}
package tech.glinfo.enbao.common.utils;
import tech.glinfo.enbao.common.utils.StringUtils;
import tech.glinfo.enbao.modules.oss.cloud.OSSFactory;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.entity.ContentType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import sun.misc.BASE64Decoder;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
@Component
public class WaterMark {
protected Logger logger = LoggerFactory.getLogger(getClass());
public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
// public static String watermarkUrl="/opt/temp/location.png";
/*public static String sourceImg="/opt/temp/110.jpg"; //源图片地址
public static String targetImg="/opt/temp/111.jpg"; //新存储的地址*/
@Value("${upload.watermarkUrl}")
private String watermarkUrl;
@Value("${upload.sourceImg}")
private String sourceImg;
@Value("${upload.targetImg}")
private String targetImg;
public static void main(String[] args) throws IOException {
Font font = new Font("微软雅黑", Font.BOLD, 30);//字体
Color color=new Color(255,255,255,255);
System.out.println(getImgStr());
// StringBuilder sb = new StringBuilder();
// addWatermark("ii");
// markImgMark(watermarkUrl,sourceImg,targetImg);
}
/**
* 为图片添加图片水印
* @param watermarkUrl 原图
* @param source 水印图片
* @param output 制作完成的图片
* @return
* @throws IOException
*/
public String markImgMark(String watermarkUrl, String source, String output) throws IOException {
String result = "添加图片水印出错";
File file = new File(source);
Image img = ImageIO.read(file);
int width = img.getWidth(null);//水印宽度
int height = img.getHeight(null);//水印高
BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g = bi.createGraphics();
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g.drawImage(img.getScaledInstance(width, height, Image.SCALE_SMOOTH), 0, 0, null);
ImageIcon imgIcon = new ImageIcon(watermarkUrl);
Image con = imgIcon.getImage();
float clarity = 1f;//透明度
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, clarity));
g.drawImage(con, width-10, height-10, null);//水印的位置
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
g.dispose();
File sf = new File(output);
ImageIO.write(bi, "jpg", sf); // 保存图片
logger.info("添加图片水印成功");
return result;
}
/** 设置文字水印
* @throws IOException
*/
public String addWatermark(String imgStr, String location) throws IOException {
String imgFilePath = Base64ToImage(imgStr);
return setWaterMark(location, imgFilePath);
}
private String setWaterMark(String location, String imgFilePath) throws IOException {
int fontSize = 80;
Font font = new Font("微软雅黑", Font.BOLD, fontSize);//字体
Color color=new Color(255,255,255,255);
File srcImgFile = new File(imgFilePath);
Image srcImg = ImageIO.read(srcImgFile);
int srcImgWidth = srcImg.getWidth(null);
int srcImgHeight = srcImg.getHeight(null);
BufferedImage bufImg = new BufferedImage(srcImgWidth, srcImgHeight, BufferedImage.TYPE_INT_RGB);
Graphics2D g = bufImg.createGraphics();
g.drawImage(srcImg, 0, 0, srcImgWidth, srcImgHeight, null);
g.setColor(color);
g.setFont(font);
String watermark = format(new Date(), DATE_TIME_PATTERN);
int w = 0;
while (true){
int w1 = g.getFontMetrics(g.getFont()).charsWidth(watermark.toCharArray(), 0, watermark.length()) + 60;
if (StringUtils.isNotBlank(location)) {
int w2 = g.getFontMetrics(g.getFont()).charsWidth(location.toCharArray(), 0, location.length()) + 60;
w = w2 > w1 ? w2 : w1;
}else {
w = w1;
}
if(w > srcImgWidth) {
fontSize -= 2;
font = new Font("微软雅黑", Font.BOLD, fontSize);//字体
g.setFont(font);
continue;
}
logger.info("最后字体大小:" + fontSize);
break;
}
// ImageIcon imgIcon = new ImageIcon(watermarkUrl);
// Image con = imgIcon.getImage();
// float clarity = 1f;//透明度
// g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, clarity));
// g.drawImage(con, 2, srcImgHeight-80, null);//水印的位置
// g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
//设置水印的坐标
// int x = srcImgWidth - (g.getFontMetrics(g.getFont()).charsWidth(watermark.toCharArray(), 0, watermark.length())+20);
int height = g.getFontMetrics(g.getFont()).getHeight();
// logger.info("height:" + height);
int y = srcImgHeight - 15;
g.drawString(watermark, 10, y); //加水印
if (StringUtils.isNotBlank(location)) {
watermark = location;
// x = srcImgWidth - (g.getFontMetrics(g.getFont()).charsWidth(watermark.toCharArray(), 0, watermark.length())+20);
g.drawString(watermark, 10, y-height); //加水印
}
g.dispose();
// 输出图片
FileOutputStream outImgStream = null;
String path =targetImg + File.separator + StringUtils.getUUID() + ".jpg";
try {
outImgStream = new FileOutputStream(path);
ImageIO.write(bufImg, "jpg", outImgStream);
logger.info(path);
File file = new File(path);
InputStream inputStream = new FileInputStream(file);
MultipartFile multipartFile = new MockMultipartFile(file.getName(), file.getName(),
ContentType.APPLICATION_OCTET_STREAM.toString(), inputStream);
String suffix = multipartFile.getOriginalFilename().substring(multipartFile.getOriginalFilename().lastIndexOf("."));
String url = OSSFactory.build().uploadSuffix(multipartFile.getBytes(), suffix);
return url;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally {
logger.info("添加水印完成");
try {
outImgStream.flush();
outImgStream.close();
//删除原本图片
File file = new File(imgFilePath);
if (file.exists()) {
file.delete();
}
//删除原本图片
File file1 = new File(path);
if (file1.exists()) {
file1.delete();
}
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
/** 设置文字水印
* @throws IOException
*/
public String addWatermark1(String imgUrl, String location) throws IOException {
String imgFilePath = sourceImg + File.separator + StringUtils.getUUID() + ".png";
//下载到本地
ImageUtils.downloadPicture(imgUrl, imgFilePath);
return setWaterMark(location, imgFilePath);
}
public String format(Date date, String pattern) {
if(date != null){
SimpleDateFormat df = new SimpleDateFormat(pattern);
return df.format(date);
}
return null;
}
/**
* base64字符串转换成图片
* @param imgStr base64字符串
* @return
*
*/
public String Base64ToImage(String imgStr) { // 对字节数组字符串进行Base64解码并生成图片
String imgFilePath = sourceImg + File.separator + StringUtils.getUUID() + ".png";
BASE64Decoder decoder = new BASE64Decoder();
OutputStream out = null;
try {
String baseValue = imgStr.replaceAll(" ", "+");
// 解密
byte[] b = decoder.decodeBuffer(baseValue.replace("data:image/png;base64,", ""));
// 处理数据
for (int i = 0; i < b.length; ++i) {
if (b[i] < 0) {
b[i] += 256;
}
}
out = new FileOutputStream(imgFilePath);
out.write(b);
out.flush();
return imgFilePath;
} catch (Exception e) {
e.printStackTrace();
return "";
} finally {
if(out != null) {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public static String getImgStr() {
// 将图片文件转化为字节数组字符串,并对其进行Base64编码处理
InputStream in = null;
byte[] data = null;
// 读取图片字节数组
try {
in = new FileInputStream("C:\\Users\\29283\\Downloads\\7a3f8aa1ab886281462e428af617faa5.jpg");
data = new byte[in.available()];
in.read(data);
in.close();
} catch (IOException e) {
e.printStackTrace();
}
return new String(Base64.encodeBase64(data));
}
}
...@@ -61,24 +61,26 @@ public class AppUserController extends AbstractController { ...@@ -61,24 +61,26 @@ public class AppUserController extends AbstractController {
@PostMapping("register") @PostMapping("register")
@ApiOperation("用户注册") @ApiOperation("用户注册")
@ApiLog("用户注册") @ApiLog("用户注册")
public R register(@RequestBody RegisterForm form){ public R register(@RequestBody WxRegisterForm form){
//表单校验 //表单校验
ValidatorUtils.validateEntity(form); ValidatorUtils.validateEntity(form);
AppUserEntity userEntity = otherAppUserService.queryByPhone(form.getPhone()); AppUserEntity userEntity = otherAppUserService.queryByPhone(form.getPhone());
if (userEntity != null) { if (userEntity != null) {
throw new RRException("手机号码已经注册过了"); return R.error("手机号码已经注册过了");
} }
String vcode = redisUtils.get(Constant.VCODE_KEY + Constant.VcodeType.REG.getValue() + "_" + form.getPhone()); /* String vcode = redisUtils.get(Constant.VCODE_KEY + Constant.VcodeType.REG.getValue() + "_" + form.getPhone());
if(!form.getVcode().equals(vcode)) { if(!form.getVcode().equals(vcode)) {
throw new RRException("验证码输入不正确"); throw new RRException("验证码输入不正确");
} }*/
AppUserEntity user = new AppUserEntity(); AppUserEntity user = new AppUserEntity();
user.setPhone(form.getPhone()); user.setPhone(form.getPhone());
user.setNickname(form.getNickname()); user.setNickname(form.getNickname());
user.setPassword(DigestUtils.sha256Hex(form.getPassword())); user.setOpenId(form.getOpenId());
user.setHeadImgUrl(form.getHeadImgUrl());
user.setPassword(DigestUtils.sha256Hex("123456"));
otherAppUserService.save(user); otherAppUserService.save(user);
ShFamilyEntity family = new ShFamilyEntity(); ShFamilyEntity family = new ShFamilyEntity();
family.setName("我的家"); family.setName("我的家");
...@@ -90,7 +92,12 @@ public class AppUserController extends AbstractController { ...@@ -90,7 +92,12 @@ public class AppUserController extends AbstractController {
member.setUserId(user.getId()); member.setUserId(user.getId());
member.setIsAdmin(1);//管理员 member.setIsAdmin(1);//管理员
shFamilyMemberService.save(member); shFamilyMemberService.save(member);
return R.ok(); String token = jwtUtils.generateToken(user.getId() +"#"+user.getPhone());
Map<String, Object> map = new HashMap<>();
map.put("token", token);
map.put("expire", jwtUtils.getExpire());
map.put("user", user);
return R.ok(map);
} }
@PostMapping("update") @PostMapping("update")
...@@ -236,23 +243,28 @@ public class AppUserController extends AbstractController { ...@@ -236,23 +243,28 @@ public class AppUserController extends AbstractController {
String clientId = (String) params.get("clientId"); String clientId = (String) params.get("clientId");
Integer role = (Integer) params.get("role"); Integer role = (Integer) params.get("role");
if (StringUtils.isNotEmpty(unionid)) {//微信登录 if (StringUtils.isNotEmpty(unionid)) {//苹果登录
//open_id 存unionID //open_id 存unionID
AppUserEntity user = otherAppUserService.getOne(new QueryWrapper<AppUserEntity>().eq("unionid", unionid)); AppUserEntity user = otherAppUserService.getOne(new QueryWrapper<AppUserEntity>().eq("unionid", unionid));
if (user != null) { if (user != null) {
// map.put("openId", openId); // map.put("openId", openId);
return R.ok(genTokenAndGetData(user, clientId, role)); return R.ok(genTokenAndGetData(user, clientId, role));
} else { } else {
return R.ok("当前微信暂未绑定任何账号!"); return R.error("当前Apple暂未绑定任何账号!");
} }
} else if (StringUtils.isNotEmpty(openid)) {//苹果登录 } else if (StringUtils.isNotEmpty(openid)) {//微信登录
//open_id 存unionID //open_id 存unionID
AppUserEntity user = otherAppUserService.getOne(new QueryWrapper<AppUserEntity>().eq("open_id", openid)); AppUserEntity user = otherAppUserService.getOne(new QueryWrapper<AppUserEntity>().eq("open_id", openid));
if (user != null) { if (user != null) {
// map.put("openId", openId); String token = jwtUtils.generateToken(user.getId() +"#"+user.getPhone());
return R.ok(genTokenAndGetData(user, clientId, role)); Map<String, Object> map = new HashMap<>();
map.put("token", token);
map.put("expire", jwtUtils.getExpire());
map.put("user", user);
return R.ok(map);
} else { } else {
return R.ok("当前Apple暂未绑定任何账号!"); return R.ok("当前微信暂未绑定任何账号!");
} }
} else { } else {
return R.error("缺少参数,请核查!"); return R.error("缺少参数,请核查!");
......
package tech.glinfo.enbao.modules.appuser.form;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* 注册表单
*
* @author linzhenjie@gltech.com
*/
@Data
@ApiModel(value = "注册表单")
public class WxRegisterForm {
@ApiModelProperty(value = "手机号码")
@NotBlank(message="手机号码不能为空")
private String phone;
@ApiModelProperty(value = "昵称")
@NotBlank(message="昵称不能为空")
private String nickname;
@ApiModelProperty(value = "openId")
@NotBlank(message="openId不能为空")
private String openId;
@ApiModelProperty(value = "头像")
private String headImgUrl;
}
...@@ -302,7 +302,7 @@ public class LockParse implements IParse { ...@@ -302,7 +302,7 @@ public class LockParse implements IParse {
String content = datas.get("content"); String content = datas.get("content");
logger.info("上报试错告警" + content); logger.info("上报试错告警" + content);
int action = Integer.parseInt(content.substring(4, 6), 16); int action = Integer.parseInt(content.substring(4, 6), 16);
AppUserEntity userEntity = appUserService.getById(device.getPublisherId()); AppUserEntity userEntity = appUserService.getById(device.getUserId());
String tishi = action == 1 ? "指纹" : action == 2 ? "密码" : action == 3 ? "卡片" : action == 20 ? "人脸" : action == 21 ? "掌纹" : "未知"; String tishi = action == 1 ? "指纹" : action == 2 ? "密码" : action == 3 ? "卡片" : action == 20 ? "人脸" : action == 21 ? "掌纹" : "未知";
if (StringUtils.isNotBlank(userEntity.getThirdId())) { if (StringUtils.isNotBlank(userEntity.getThirdId())) {
mqProducer.sendPush(tishi + "多次开锁失败提示", "设备: " + device.getNumbering() + " " + tishi + "多次开锁失败提示", userEntity.getThirdId()); mqProducer.sendPush(tishi + "多次开锁失败提示", "设备: " + device.getNumbering() + " " + tishi + "多次开锁失败提示", userEntity.getThirdId());
...@@ -310,13 +310,13 @@ public class LockParse implements IParse { ...@@ -310,13 +310,13 @@ public class LockParse implements IParse {
} }
//处理设备期限使用标志 //处理设备期限使用标志
new Thread(new Runnable() { /*new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
logger.info("start handleEndTime"); logger.info("start handleEndTime");
timeParseUtils.handleEndTime(device.getId(), "06", device.getNumbering(), datas.get("cmd")); timeParseUtils.handleEndTime(device.getId(), "06", device.getNumbering(), datas.get("cmd"));
} }
}).start(); }).start();*/
return ws; return ws;
} }
......
...@@ -122,7 +122,7 @@ public class SpeakerParse implements IParse { ...@@ -122,7 +122,7 @@ public class SpeakerParse implements IParse {
redisUtils.set(AppContants.SPEAKER_FILE_SEND + device.getNumbering() + "-stopsend", 1, 5); redisUtils.set(AppContants.SPEAKER_FILE_SEND + device.getNumbering() + "-stopsend", 1, 5);
return null; return null;
} else if ("00".equals(datas.get("cmd"))) {//解析后的中文 } else if ("00".equals(datas.get("cmd"))) {//解析后的中文
parseText(device.getId(), device.getNumbering(), device.getSpareTwo(), content, null, device.getPublisherId()); parseText(device.getId(), device.getNumbering(), device.getSpareTwo(), content, null, device.getUserId());
return null; return null;
}else if("998".equals(datas.get("cmd"))) {//文件下发后状态 }else if("998".equals(datas.get("cmd"))) {//文件下发后状态
ShSpeakerSongEntity song = shSpeakerSongService.getById(content); ShSpeakerSongEntity song = shSpeakerSongService.getById(content);
......
...@@ -64,4 +64,12 @@ public class ShFamilyController { ...@@ -64,4 +64,12 @@ public class ShFamilyController {
return otherShFamilyService.delete(params, user); return otherShFamilyService.delete(params, user);
} }
@Login
@GetMapping("index")
@ApiOperation("首页")
@ApiLog("首页")
public R index(@RequestBody Map<String, Object> params, @LoginUser AppUserEntity user) {
return otherShFamilyService.index(user.getId(), Integer.valueOf((String) params.get("familyId")));
}
} }
\ No newline at end of file
...@@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import tech.glinfo.enbao.modules.sh.dto.ShFamilyDto; import tech.glinfo.enbao.modules.sh.dto.ShFamilyDto;
import tech.glinfo.enbao.modules.sh.dto.ShFamilyIndex;
import tech.glinfo.enbao.modules.sh.entity.ShDeviceEntity; import tech.glinfo.enbao.modules.sh.entity.ShDeviceEntity;
import tech.glinfo.enbao.modules.sh.entity.ShFamilyEntity; import tech.glinfo.enbao.modules.sh.entity.ShFamilyEntity;
...@@ -33,4 +34,6 @@ public interface OtherShFamilyDao extends BaseMapper<ShFamilyEntity> { ...@@ -33,4 +34,6 @@ public interface OtherShFamilyDao extends BaseMapper<ShFamilyEntity> {
ShFamilyDto familyInfo(@Param("params")Integer id); ShFamilyDto familyInfo(@Param("params")Integer id);
ShFamilyIndex index(@Param("userId")Integer userId, @Param("familyId")Integer familyId);
} }
package tech.glinfo.enbao.modules.sh.dto;
import lombok.Data;
/**
* @author lyt
* @date 2022/1/5 15:28
*/
@Data
public class ShDeviceIndex {
private Integer id;
private String name;
private String numbering;
private Integer onlineStatus;
private String pic;
}
package tech.glinfo.enbao.modules.sh.dto;
import lombok.Data;
import java.util.List;
/**
* @author lyt
* @date 2022/1/5 11:25
*/
@Data
public class ShFamilyIndex {
private Integer id;
private String name;
private List<ShDeviceIndex> devices;
private List<ShFamilyRoomIndex> rooms;
}
...@@ -12,4 +12,6 @@ public class ShFamilyMemberDto { ...@@ -12,4 +12,6 @@ public class ShFamilyMemberDto {
private Integer id; private Integer id;
private String nickname; private String nickname;
private Integer isAdmin;
} }
package tech.glinfo.enbao.modules.sh.dto;
import lombok.Data;
import java.util.List;
/**
* @author lyt
* @date 2022/1/5 11:25
*/
@Data
public class ShFamilyRoomIndex {
private Integer id;
private String name;
}
...@@ -22,4 +22,6 @@ public interface OtherShFamilyService extends IService<ShFamilyEntity> { ...@@ -22,4 +22,6 @@ public interface OtherShFamilyService extends IService<ShFamilyEntity> {
R list(AppUserEntity user); R list(AppUserEntity user);
R info(Integer id); R info(Integer id);
R index(Integer userId, Integer familyId);
} }
...@@ -9,6 +9,7 @@ import tech.glinfo.enbao.common.utils.StringUtils; ...@@ -9,6 +9,7 @@ import tech.glinfo.enbao.common.utils.StringUtils;
import tech.glinfo.enbao.modules.appuser.entity.AppUserEntity; import tech.glinfo.enbao.modules.appuser.entity.AppUserEntity;
import tech.glinfo.enbao.modules.sh.dao.OtherShFamilyDao; import tech.glinfo.enbao.modules.sh.dao.OtherShFamilyDao;
import tech.glinfo.enbao.modules.sh.dto.ShFamilyDto; import tech.glinfo.enbao.modules.sh.dto.ShFamilyDto;
import tech.glinfo.enbao.modules.sh.dto.ShFamilyIndex;
import tech.glinfo.enbao.modules.sh.entity.ShFamilyEntity; import tech.glinfo.enbao.modules.sh.entity.ShFamilyEntity;
import tech.glinfo.enbao.modules.sh.entity.ShFamilyMemberEntity; import tech.glinfo.enbao.modules.sh.entity.ShFamilyMemberEntity;
import tech.glinfo.enbao.modules.sh.service.OtherShFamilyService; import tech.glinfo.enbao.modules.sh.service.OtherShFamilyService;
...@@ -88,5 +89,11 @@ public class OtherShFamilyServiceImpl extends ServiceImpl<OtherShFamilyDao, ShFa ...@@ -88,5 +89,11 @@ public class OtherShFamilyServiceImpl extends ServiceImpl<OtherShFamilyDao, ShFa
return R.ok().put("family", family); return R.ok().put("family", family);
} }
@Override
public R index(Integer userId, Integer familyId) {
ShFamilyIndex index = this.baseMapper.index(userId, familyId);
return R.ok().put("data", index);
}
} }
...@@ -12,7 +12,7 @@ server: ...@@ -12,7 +12,7 @@ server:
spring: spring:
# 环境 dev|test|prod # 环境 dev|test|prod
profiles: profiles:
active: dev active: local
# jackson时间格式化 # jackson时间格式化
jackson: jackson:
time-zone: GMT+8 time-zone: GMT+8
...@@ -66,4 +66,23 @@ baidu: ...@@ -66,4 +66,23 @@ baidu:
apiKey: 45lWoxeKGTxjQTdliVSCj6G8 apiKey: 45lWoxeKGTxjQTdliVSCj6G8
secretKey: Mk7QVOthvwqxFHZvZ0X7gOOTMcUEBBS8 secretKey: Mk7QVOthvwqxFHZvZ0X7gOOTMcUEBBS8
# netty-socketio 配置
socketio:
host: 127.0.0.1
port: 8888
# 设置最大每帧处理数据的长度,防止他人利用大数据来攻击服务器
maxFramePayloadLength: 1048576
# 设置http交互最大内容长度
maxHttpContentLength: 1048576
# socket连接数大小(如只监听一个端口boss线程组为1即可)
bossCount: 1
workCount: 100
allowCustomRequests: true
# 协议升级超时时间(毫秒),默认10秒。HTTP握手升级为ws协议超时时间
upgradeTimeout: 1000000
# Ping消息超时时间(毫秒),默认60秒,这个时间间隔内没有接收到心跳消息就会发送超时事件
pingTimeout: 6000000
# Ping消息间隔(毫秒),默认25秒。客户端向服务器发送一条心跳消息间隔
pingInterval: 25000
...@@ -10,17 +10,58 @@ ...@@ -10,17 +10,58 @@
<collection property="members" ofType="tech.glinfo.enbao.modules.sh.dto.ShFamilyMemberDto" columnPrefix="item_"> <collection property="members" ofType="tech.glinfo.enbao.modules.sh.dto.ShFamilyMemberDto" columnPrefix="item_">
<result column="id" property="id"/> <result column="id" property="id"/>
<result column="nickname" property="nickname"/> <result column="nickname" property="nickname"/>
<result column="is_admin" property="isAdmin"/>
</collection>
</resultMap>
<resultMap id="familyIndexResultMap" type="tech.glinfo.enbao.modules.sh.dto.ShFamilyIndex">
<result column="id" property="id"/>
<result column="name" property="name"/>
<collection property="devices" ofType="tech.glinfo.enbao.modules.sh.dto.ShDeviceIndex" columnPrefix="device_">
<result column="id" property="id"/>
<result column="name" property="name"/>
<result column="numbering" property="numbering"/>
<result column="onlineStatus" property="onlineStatus"/>
<result column="pic" property="pic"/>
</collection>
<collection property="rooms" ofType="tech.glinfo.enbao.modules.sh.dto.ShFamilyRoomIndex" columnPrefix="room_">
<result column="id" property="id"/>
<result column="name" property="name"/>
</collection> </collection>
</resultMap> </resultMap>
<select id="familyInfo" resultMap="familyResultMap"> <select id="familyInfo" resultMap="familyResultMap">
SELECT a.id, a.name, COUNT(c.id) room, SELECT a.id, a.name, COUNT(c.id) room,
b.id item_id, b.id item_id,
d.nickname item_nickname d.nickname item_nickname,
b.is_admin item_isAdmin
FROM FROM
sh_family a, sh_family_member b, sh_family_room c, app_user d sh_family a, sh_family_member b, sh_family_room c, app_user d
WHERE WHERE
a.id = b.family_id AND a.id = c.family_id AND b.user_id = d.id AND a.id = ${id} a.id = b.family_id AND a.id = c.family_id AND b.user_id = d.id AND a.id = ${id}
</select> </select>
<select id="index" resultMap="familyIndexResultMap">
SELECT a.id, a.name,
b.id device_id,
b.name device_name,
b.numbering device_numbering,
b.online_status device_onlineStatus,
b.pic device_pic,
c.id room_id,
c.name room_name
FROM
sh_family a LEFT JOIN sh_device b ON a.id = b.family_id LEFT JOIN sh_family_room c ON a.id = c.family_id
WHERE
<choose>
<when test="familyId != null and familyId !=''">
a.id = ${familyId}
</when>
<otherwise>
a.id = (SELECT d.id FROM sh_family d WHERE d.user_id = ${userId} LIMIT 1)
</otherwise>
</choose>
</select>
</mapper> </mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="tech.glinfo.enbao.modules.sysuser.dao.SysUserDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="tech.glinfo.enbao.modules.sysuser.entity.SysUserEntity" id="sysUserMap">
<result property="userId" column="user_id"/>
<result property="username" column="username"/>
<result property="password" column="password"/>
<result property="salt" column="salt"/>
<result property="email" column="email"/>
<result property="mobile" column="mobile"/>
<result property="status" column="status"/>
<result property="type" column="type"/>
<result property="createUserId" column="create_user_id"/>
<result property="createTime" column="create_time"/>
</resultMap>
</mapper>
\ No newline at end of file
...@@ -16,6 +16,21 @@ CREATE TABLE `app_user` ( ...@@ -16,6 +16,21 @@ CREATE TABLE `app_user` (
KEY `app_user_phone` (`phone`) USING BTREE KEY `app_user_phone` (`phone`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='APP用户'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='APP用户';
DROP TABLE IF EXISTS `app_api_log`;
CREATE TABLE `app_api_log` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键id',
`userid` int(11) COMMENT '用户',
`phone` varchar(11) COMMENT '手机号码',
`operation` varchar(50) COMMENT '用户操作',
`method` varchar(200) COMMENT '请求方法',
`params` text COMMENT '请求参数',
`time` bigint NOT NULL COMMENT '执行时长(毫秒)',
`ip` varchar(64) COMMENT 'IP地址',
`create_date` datetime COMMENT '创建时间',
PRIMARY KEY (`id`),
KEY `app_api_log_phone` (`phone`) USING BTREE
) ENGINE=`InnoDB` DEFAULT CHARACTER SET utf8mb4 COMMENT='API日志';
CREATE TABLE `sh_category` ( CREATE TABLE `sh_category` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(64) DEFAULT NULL COMMENT '分类名称', `name` varchar(64) DEFAULT NULL COMMENT '分类名称',
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论