diff --git a/src/main/java/com/ifish/Interceptor/CheckSumBuilder.java b/src/main/java/com/ifish/Interceptor/CheckSumBuilder.java new file mode 100644 index 0000000..2545bb2 --- /dev/null +++ b/src/main/java/com/ifish/Interceptor/CheckSumBuilder.java @@ -0,0 +1,52 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.ifish.Interceptor; + +import java.security.MessageDigest; + +/** + * + * @author Administrator + */ +public class CheckSumBuilder { + + // 计算并获取CheckSum + public static String getCheckSum(String appSecret, String nonce, String curTime) { + return encode("sha1", appSecret + nonce + curTime); + } + + // 计算并获取md5值 + public static String getMD5(String requestBody) { + return encode("md5", requestBody); + } + + private static String encode(String algorithm, String value) { + if (value == null) { + return null; + } + try { + MessageDigest messageDigest + = MessageDigest.getInstance(algorithm); + messageDigest.update(value.getBytes()); + return getFormattedText(messageDigest.digest()); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private static String getFormattedText(byte[] bytes) { + int len = bytes.length; + StringBuilder buf = new StringBuilder(len * 2); + for (int j = 0; j < len; j++) { + buf.append(HEX_DIGITS[(bytes[j] >> 4) & 0x0f]); + buf.append(HEX_DIGITS[bytes[j] & 0x0f]); + } + return buf.toString(); + } + + private static final char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + +} diff --git a/src/main/java/com/ifish/Interceptor/IfishException.java b/src/main/java/com/ifish/Interceptor/IfishException.java new file mode 100644 index 0000000..a9d5e6a --- /dev/null +++ b/src/main/java/com/ifish/Interceptor/IfishException.java @@ -0,0 +1,28 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.ifish.Interceptor; + +import com.ifish.enums.ResultEnum; + +/** + * + * @author Administrator + */ +public class IfishException extends RuntimeException { + + private static final long serialVersionUID = 4182058914725642218L; + + private String result; + + public IfishException(ResultEnum resultEnum) { + super(resultEnum.getValue()); + this.result = resultEnum.getKey(); + } + + public String getResult() { + return result; + } +} diff --git a/src/main/java/com/ifish/bean/Tbl_Device.java b/src/main/java/com/ifish/bean/Tbl_Device.java index 112f6a4..71433d8 100644 --- a/src/main/java/com/ifish/bean/Tbl_Device.java +++ b/src/main/java/com/ifish/bean/Tbl_Device.java @@ -23,7 +23,7 @@ public class Tbl_Device implements java.io.Serializable { /** * 版本号 */ - private static final long serialVersionUID = -7095234476683939631L; + private static final long serialVersionUID = 204106348073538365L; /** * 设备Id @@ -80,12 +80,6 @@ public class Tbl_Device implements java.io.Serializable { @Column(name = "on_off", nullable = true, length = 1) private String onOff; - /** - * 是否接收离线通知:1接收,0不接受 - */ - @Column(name = "off_line", nullable = true, length = 1) - private String offLine; - /** * 今天是否提醒:1提醒、0不提醒 */ @@ -314,24 +308,6 @@ public class Tbl_Device implements java.io.Serializable { this.onOff = onOff; } - /** - * 获取是否接收离线通知:1接收,0不接受 - * - * @return 是否接收离线通知:1接收 - */ - public String getOffLine() { - return this.offLine; - } - - /** - * 设置是否接收离线通知:1接收,0不接受 - * - * @param offLine 是否接收离线通知:1接收,0不接受 - */ - public void setOffLine(String offLine) { - this.offLine = offLine; - } - /** * 获取今天是否提醒:1提醒、0不提醒 * diff --git a/src/main/java/com/ifish/bean/Tbl_Device_User.java b/src/main/java/com/ifish/bean/Tbl_Device_User.java index 08184a0..9cd6a89 100644 --- a/src/main/java/com/ifish/bean/Tbl_Device_User.java +++ b/src/main/java/com/ifish/bean/Tbl_Device_User.java @@ -24,7 +24,7 @@ public class Tbl_Device_User implements java.io.Serializable { /** * 版本号 */ - private static final long serialVersionUID = -4018159739383033383L; + private static final long serialVersionUID = 5123379244673522530L; /** * id @@ -36,7 +36,7 @@ public class Tbl_Device_User implements java.io.Serializable { /** * 用户Id */ - @Column(name = "user_id", unique = true, nullable = false, length = 10) + @Column(name = "user_id", nullable = false, length = 10) private Integer userId; /** @@ -93,6 +93,12 @@ public class Tbl_Device_User implements java.io.Serializable { @Column(name = "is_live", nullable = true, length = 1) private String isLive; + /** + * 是否开启离线提醒,1开启,0关闭,默认1 + */ + @Column(name = "off_line", nullable = true, length = 1) + private String offLine; + /** * 获取id * @@ -290,4 +296,22 @@ public class Tbl_Device_User implements java.io.Serializable { public void setIsLive(String isLive) { this.isLive = isLive; } + + /** + * 获取是否开启离线提醒,1开启,0关闭,默认1 + * + * @return 是否开启离线提醒 + */ + public String getOffLine() { + return this.offLine; + } + + /** + * 设置是否开启离线提醒,1开启,0关闭,默认1 + * + * @param offLine 是否开启离线提醒,1开启,0关闭,默认1 + */ + public void setOffLine(String offLine) { + this.offLine = offLine; + } } diff --git a/src/main/java/com/ifish/bean/Tbl_Vender_List.java b/src/main/java/com/ifish/bean/Tbl_Vender_List.java new file mode 100644 index 0000000..3c9caf3 --- /dev/null +++ b/src/main/java/com/ifish/bean/Tbl_Vender_List.java @@ -0,0 +1,245 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.ifish.bean; + +import java.util.Date; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +/** + * 鱼缸场详情表(tbl_vender_list) + * + * @author bianj + * @version 1.0.0 2017-06-27 + */ +@Entity +@Table(name = "tbl_vender_list") +public class Tbl_Vender_List implements java.io.Serializable { + + /** + * 版本号 + */ + private static final long serialVersionUID = 2462685903502867014L; + + /** + * 鱼缸厂编号 + */ + @Id + @Column(name = "brand_code", unique = true, nullable = false, length = 20) + private String brandCode; + + /** + * logo + */ + @Column(name = "brand_logo", nullable = true, length = 100) + private String brandLogo; + + /** + * 鱼缸厂名称 + */ + @Column(name = "brand_name", nullable = false, length = 20) + private String brandName; + + /** + * 品牌介绍 + */ + @Column(name = "brand_introduce", nullable = true, length = 100) + private String brandIntroduce; + + /** + * app展示 + */ + @Column(name = "app_show", nullable = true, length = 1) + private String appShow; + + /** + * 联系电话 + */ + @Column(name = "contact_phone", nullable = true, length = 30) + private String contactPhone; + + /** + * 联系地址 + */ + @Column(name = "contact_address", nullable = true, length = 50) + private String contactAddress; + + /** + * 更新时间 + */ + @Column(name = "update_time", nullable = true) + private Date updateTime; + + /** + * 创建时间 + */ + @Column(name = "create_time", nullable = true) + private Date createTime; + + /** + * 获取鱼缸厂编号 + * + * @return 鱼缸厂编号 + */ + public String getBrandCode() { + return this.brandCode; + } + + /** + * 设置鱼缸厂编号 + * + * @param brandCode 鱼缸厂编号 + */ + public void setBrandCode(String brandCode) { + this.brandCode = brandCode; + } + + /** + * 获取logo + * + * @return logo + */ + public String getBrandLogo() { + return this.brandLogo; + } + + /** + * 设置logo + * + * @param brandLogo logo + */ + public void setBrandLogo(String brandLogo) { + this.brandLogo = brandLogo; + } + + /** + * 获取鱼缸厂名称 + * + * @return 鱼缸厂名称 + */ + public String getBrandName() { + return this.brandName; + } + + /** + * 设置鱼缸厂名称 + * + * @param brandName 鱼缸厂名称 + */ + public void setBrandName(String brandName) { + this.brandName = brandName; + } + + /** + * 获取品牌介绍 + * + * @return 品牌介绍 + */ + public String getBrandIntroduce() { + return this.brandIntroduce; + } + + /** + * 设置品牌介绍 + * + * @param brandIntroduce 品牌介绍 + */ + public void setBrandIntroduce(String brandIntroduce) { + this.brandIntroduce = brandIntroduce; + } + + /** + * 获取app展示 + * + * @return app展示 + */ + public String getAppShow() { + return this.appShow; + } + + /** + * 设置app展示 + * + * @param appShow app展示 + */ + public void setAppShow(String appShow) { + this.appShow = appShow; + } + + /** + * 获取联系电话 + * + * @return 联系电话 + */ + public String getContactPhone() { + return this.contactPhone; + } + + /** + * 设置联系电话 + * + * @param contactPhone 联系电话 + */ + public void setContactPhone(String contactPhone) { + this.contactPhone = contactPhone; + } + + /** + * 获取联系地址 + * + * @return 联系地址 + */ + public String getContactAddress() { + return this.contactAddress; + } + + /** + * 设置联系地址 + * + * @param contactAddress 联系地址 + */ + public void setContactAddress(String contactAddress) { + this.contactAddress = contactAddress; + } + + /** + * 获取更新时间 + * + * @return 更新时间 + */ + public Date getUpdateTime() { + return this.updateTime; + } + + /** + * 设置更新时间 + * + * @param updateTime 更新时间 + */ + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + /** + * 获取创建时间 + * + * @return 创建时间 + */ + public Date getCreateTime() { + return this.createTime; + } + + /** + * 设置创建时间 + * + * @param createTime 创建时间 + */ + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } +} diff --git a/src/main/java/com/ifish/config/WebConfig.java b/src/main/java/com/ifish/config/WebConfig.java index 9efb747..397583b 100644 --- a/src/main/java/com/ifish/config/WebConfig.java +++ b/src/main/java/com/ifish/config/WebConfig.java @@ -11,6 +11,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.web.multipart.MultipartResolver; +import org.springframework.web.multipart.commons.CommonsMultipartResolver; import org.springframework.web.multipart.support.StandardServletMultipartResolver; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer; @@ -81,8 +82,8 @@ public class WebConfig extends WebMvcConfigurerAdapter { } @Bean - public MultipartResolver multipartResolver() throws IOException { - return new StandardServletMultipartResolver(); + public CommonsMultipartResolver multipartResolver() { + return new CommonsMultipartResolver(); } @Bean diff --git a/src/main/java/com/ifish/controller/Factory.java b/src/main/java/com/ifish/controller/Factory.java index a996fb6..b5aee83 100644 --- a/src/main/java/com/ifish/controller/Factory.java +++ b/src/main/java/com/ifish/controller/Factory.java @@ -5,6 +5,7 @@ */ package com.ifish.controller; +import com.ifish.bean.Tbl_Factory_List; import com.ifish.helper.FactoryHelperI; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; @@ -72,7 +73,7 @@ public class Factory { } /** - * 修改电子厂 + * 修改(添加)电子厂 * * @return */ @@ -94,4 +95,23 @@ public class Factory { return factoryHelperI.deleteFactory(code); } + /** + * 添加电子厂页面 + * + * @return + */ + @RequestMapping(value = {"/addFactory"}, method = RequestMethod.GET) + public ModelAndView addFactory() { + return factoryHelperI.addFactory(); + } + + /** + * 查询统计 + * + * @return + */ + @RequestMapping(value = {"/querylist"}, method = RequestMethod.GET) + public ModelAndView querylist() { + return factoryHelperI.addFactory(); + } } diff --git a/src/main/java/com/ifish/controller/Vender.java b/src/main/java/com/ifish/controller/Vender.java new file mode 100644 index 0000000..ffdaf68 --- /dev/null +++ b/src/main/java/com/ifish/controller/Vender.java @@ -0,0 +1,115 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.ifish.controller; + +import com.ifish.bean.Tbl_Vender_List; +import com.ifish.helper.VenderHelperI; +import java.io.File; +import javax.servlet.http.HttpServletRequest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; +import org.springframework.web.servlet.ModelAndView; + +/** + * + * @author Administrator + */ +@Controller +public class Vender { + + @Autowired + private VenderHelperI venderHelperI; + + /** + * 鱼缸厂列表页面 + * + * @return + */ + @RequestMapping(value = {"/venderlist"}, method = RequestMethod.GET) + public ModelAndView getlist() { + return venderHelperI.getlist(); + } + + /** + * 鱼缸厂列表页数据 + * + * @param draw + * @param start + * @param length + * @return + */ + @RequestMapping(value = {"/venderdata"}, method = RequestMethod.POST) + @ResponseBody + public Object getlistData(String draw, Integer start, Integer length, String appShow, String sortField, String sortMode, String brandName) { + return venderHelperI.getlistData(draw, start, length, appShow, sortField, sortMode, brandName); + } + + /** + * 鱼缸厂详情展示页 + * + * @param brandCode + * @return + */ + @RequestMapping(value = {"/venderdetail"}, method = RequestMethod.GET) + public ModelAndView getvender(String brandCode) { + return venderHelperI.getvender(brandCode); + } + + /** + * 修改,插入 鱼缸厂信息 + * + * @param brandLogoImg + * @param tbl_Vender_List + * @return + */ + @RequestMapping(value = {"/updateVender"}, method = RequestMethod.POST, produces = " text/html;charset=utf-8") + @ResponseBody + public Object updateVender(Tbl_Vender_List tbl_Vender_List, MultipartFile brandLogoImg) { + return venderHelperI.updateVender(brandLogoImg, tbl_Vender_List); + } + + /** + * 新增鱼缸厂页面 + * + * @return + */ + @RequestMapping(value = {"/addVender"}, method = RequestMethod.GET) + public ModelAndView addVender() { + return venderHelperI.addVender(); + } + + /** + * 根据鱼缸厂code删除鱼缸厂信息 + * + * @param code + * @return + */ + @RequestMapping(value = {"/deleteVender"}, method = RequestMethod.POST, produces = " text/html;charset=utf-8") + @ResponseBody + public Object deleteVender(String code) { + return venderHelperI.deleteVender(code); + } + + /** + * 修改鱼缸厂在APP端是否展示 + * + * @param code + * @param appshow + * @return + */ + @RequestMapping(value = {"/updateAppShow"}, method = RequestMethod.POST, produces = " text/html;charset=utf-8") + @ResponseBody + public Object updateAppShow(String code, String appshow) { + return venderHelperI.updateAppShow(code, appshow); + } + +} diff --git a/src/main/java/com/ifish/helper/FactoryHelper.java b/src/main/java/com/ifish/helper/FactoryHelper.java index 3d236df..fa201e3 100644 --- a/src/main/java/com/ifish/helper/FactoryHelper.java +++ b/src/main/java/com/ifish/helper/FactoryHelper.java @@ -207,25 +207,91 @@ public class FactoryHelper implements FactoryHelperI { */ @Override public Object updateFactory(String[] brandCodes, String[] hardwareTypes, String factoryName, String factoryCode) { - int i = tbl_Factory_List_Mapper.updateFactory(factoryName, factoryCode); - if (i > 0) { - List allHardWare_Types = tbl_Factory_List_Mapper.getAllHardWare_TypeList(); - List hardwareTypeslist = Arrays.asList(hardwareTypes); - for (Tbl_HardWare_Type HardWare_Type : allHardWare_Types) { - if (hardwareTypeslist.contains(HardWare_Type.getHardwareType()) && (StringUtils.isBlank(HardWare_Type.getFactoryCode()) || !HardWare_Type.getFactoryCode().equals(factoryCode))) { - tbl_Factory_List_Mapper.updateHardWareType(factoryCode, HardWare_Type.getHardwareType()); - } else if (!hardwareTypeslist.contains(HardWare_Type.getHardwareType()) && (StringUtils.isNotBlank(HardWare_Type.getFactoryCode()) && HardWare_Type.getFactoryCode().equals(factoryCode))) { - tbl_Factory_List_Mapper.updateHardWareType(null, HardWare_Type.getHardwareType()); + Tbl_Factory_List tbl_Factory_List = tbl_Factory_List_Mapper.getFactory_ListByCode(factoryCode); + if (tbl_Factory_List != null) { + int i = tbl_Factory_List_Mapper.updateFactory(factoryName, factoryCode); + if (i > 0) { + List allHardWare_Types = tbl_Factory_List_Mapper.getAllHardWare_TypeList(); + List hardwareTypeslist = Arrays.asList(hardwareTypes); + for (Tbl_HardWare_Type HardWare_Type : allHardWare_Types) { + if (hardwareTypeslist.contains(HardWare_Type.getHardwareType()) && (StringUtils.isBlank(HardWare_Type.getFactoryCode()) || !HardWare_Type.getFactoryCode().equals(factoryCode))) { + tbl_Factory_List_Mapper.updateHardWareType(factoryCode, HardWare_Type.getHardwareType()); + } else if (!hardwareTypeslist.contains(HardWare_Type.getHardwareType()) && (StringUtils.isNotBlank(HardWare_Type.getFactoryCode()) && HardWare_Type.getFactoryCode().equals(factoryCode))) { + tbl_Factory_List_Mapper.updateHardWareType(null, HardWare_Type.getHardwareType()); + } } - } - tbl_Factory_List_Mapper.deleteFactoryVender(factoryCode); - for (String brandCode : brandCodes) { - tbl_Factory_List_Mapper.insertFactoryVender(factoryCode, brandCode); - } - return "修改成功!"; + tbl_Factory_List_Mapper.deleteFactoryVender(factoryCode); + for (String brandCode : brandCodes) { + tbl_Factory_List_Mapper.insertFactoryVender(factoryCode, brandCode); + } + return "修改成功!"; + } else { + return "修改失败"; + } + } else { + tbl_Factory_List = new Tbl_Factory_List(); + tbl_Factory_List.setFactoryCode(factoryCode); + tbl_Factory_List.setFactoryName(factoryName); + int i = tbl_Factory_List_Mapper.insertFactoryList(tbl_Factory_List); + if (i > 0) { + List allHardWare_Types = tbl_Factory_List_Mapper.getAllHardWare_TypeList(); + List hardwareTypeslist = Arrays.asList(hardwareTypes); + for (Tbl_HardWare_Type HardWare_Type : allHardWare_Types) { + if (hardwareTypeslist.contains(HardWare_Type.getHardwareType()) && (StringUtils.isBlank(HardWare_Type.getFactoryCode()) || !HardWare_Type.getFactoryCode().equals(factoryCode))) { + tbl_Factory_List_Mapper.updateHardWareType(factoryCode, HardWare_Type.getHardwareType()); + } else if (!hardwareTypeslist.contains(HardWare_Type.getHardwareType()) && (StringUtils.isNotBlank(HardWare_Type.getFactoryCode()) && HardWare_Type.getFactoryCode().equals(factoryCode))) { + tbl_Factory_List_Mapper.updateHardWareType(null, HardWare_Type.getHardwareType()); + } + } + + tbl_Factory_List_Mapper.deleteFactoryVender(factoryCode); + for (String brandCode : brandCodes) { + tbl_Factory_List_Mapper.insertFactoryVender(factoryCode, brandCode); + } + return "添加电子厂成功!"; + } + return "添加电子厂失败!"; } - return "修改失败!"; + } + + /** + * 添加电子厂页面 + * + * @return + */ + @Override + public ModelAndView addFactory() { + ModelAndView mv = new ModelAndView(); + + //所有鱼缸厂关系 + List vendList = tbl_Factory_List_Mapper.getAllVenderList(); + mv.addObject("vendlist", vendList); + //设备信息 + List allHardWare_Types = tbl_Factory_List_Mapper.getAllHardWare_TypeList(); + mv.addObject("hardlist", allHardWare_Types); + + mv.setViewName("factorydetail"); + mv.addObject("title", "添加电子厂"); + mv.addObject("pagetitle", "添加电子厂"); + mv.addObject("myjs", "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "" + + "" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "" + + " "); + return mv; } } diff --git a/src/main/java/com/ifish/helper/FactoryHelperI.java b/src/main/java/com/ifish/helper/FactoryHelperI.java index 327ce0c..0473a80 100644 --- a/src/main/java/com/ifish/helper/FactoryHelperI.java +++ b/src/main/java/com/ifish/helper/FactoryHelperI.java @@ -5,6 +5,7 @@ */ package com.ifish.helper; +import com.ifish.bean.Tbl_Factory_List; import org.springframework.web.servlet.ModelAndView; /** @@ -63,4 +64,11 @@ public interface FactoryHelperI { * @return */ Object updateFactory(String[] brandCodes, String[] hardwareTypes, String factoryName, String factoryCode); + + /** + * 添加电子厂页面 + * + * @return + */ + public ModelAndView addFactory(); } diff --git a/src/main/java/com/ifish/helper/FastDFSClient.java b/src/main/java/com/ifish/helper/FastDFSClient.java new file mode 100644 index 0000000..189a2df --- /dev/null +++ b/src/main/java/com/ifish/helper/FastDFSClient.java @@ -0,0 +1,139 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.ifish.helper; + +import com.ifish.util.IfishFilePath; +import com.ifish.util.IfishUtil; +import org.apache.commons.lang3.StringUtils; +import org.csource.fastdfs.ClientGlobal; +import org.csource.fastdfs.StorageClient1; +import org.csource.fastdfs.StorageServer; +import org.csource.fastdfs.TrackerClient; +import org.csource.fastdfs.TrackerServer; +import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; + +@Component +public class FastDFSClient implements FastDFSClientI { + + private TrackerClient trackerClient = null; + private TrackerServer trackerServer = null; + private StorageServer storageServer = null; + //使用StorageClient1进行上传 + private StorageClient1 storageClient1 = null; + + public FastDFSClient() throws Exception { + //获取classpath路径下配置文件"fdfs_client.conf"的路径 + //conf直接写相对于classpath的位置,不需要写classpath: + String conf = ""; + if (IfishFilePath.link_img_head.contains("ifish7")) { + conf = "fdfs_client_ifish7.conf"; + } else { + conf = "fdfs_client_zhangxinyanv5.conf"; + } + + String configPath = this.getClass().getClassLoader().getResource(conf).getFile(); + System.out.println(configPath); + ClientGlobal.init(configPath); + + trackerClient = new TrackerClient(); + trackerServer = trackerClient.getConnection(); + storageServer = trackerClient.getStoreStorage(trackerServer); + storageClient1 = new StorageClient1(trackerServer, storageServer); + } + + /** + * 上传一个字节型文件 + * + * @param file_buff 字节数组 + * @param file_ext_name 文件后缀 + * @return + * @throws Exception + */ + @Override + public String uploadFile(byte[] file_buff, String file_ext_name) throws Exception { + + String result = ""; + + try { + result = storageClient1.upload_file1(file_buff, file_ext_name, null); + } catch (Exception e) { + try { + result = storageClient1.upload_file1(file_buff, file_ext_name, null); + } catch (Exception a) { + return ""; + } + } + + return result; + } + + /** + * 上传一个本地文件 + * + * @param local_filename 本地文件名(路径+文件名+后缀) + * @param file_ext_name 文件后缀 + * @return + * @throws Exception + */ + @Override + public String uploadFile(String local_filename, String file_ext_name) throws Exception { + + String result = storageClient1.upload_file1(local_filename, file_ext_name, null); + + return result; + } + + /** + * 上传一个文件 + * + * @param group_name 指定位置 + * @param local_filename 本地文件名(路径+文件名+后缀) + * @param file_ext_name 文件后缀 + * @return + * @throws Exception + */ + @Override + public String uploadFile(String group_name, String local_filename, String file_ext_name) throws Exception { + + String result = storageClient1.upload_file1(group_name, local_filename, file_ext_name, null); + + return result; + } + + public String getFileType(MultipartFile file) { + String[] allowTypes = new String[]{".mp4", ".png", ".jpg", ".bmp"}; + String filename = file.getOriginalFilename(); + if (StringUtils.isNotBlank(filename)) { + for (String allowType : allowTypes) { + if (filename.contains(allowType)) { + return allowType.replace(".", ""); + } + } + } + return ""; + } + + @Override + public String uploadFileToFastDFS(MultipartFile file) { + try { + String type = getFileType(file); + if (StringUtils.isBlank(type)) { + return null; + } + byte[] bt = file.getBytes(); + String url = uploadFile(bt, type); + if (url.contains("group1/M00/")) { + url = url.replace("group1/M00/", ""); + } else { + return ""; + } + return IfishFilePath.link_img_head + url; + } catch (Exception e) { + return ""; + } + } +} diff --git a/src/main/java/com/ifish/helper/FastDFSClientI.java b/src/main/java/com/ifish/helper/FastDFSClientI.java new file mode 100644 index 0000000..a937ff3 --- /dev/null +++ b/src/main/java/com/ifish/helper/FastDFSClientI.java @@ -0,0 +1,55 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.ifish.helper; + +import org.springframework.web.multipart.MultipartFile; + +/** + * FastDFS分布式文件管理系统接口方法 + * + * @author Administrator + */ +public interface FastDFSClientI { + + /** + * 上传一个字节型文件 + * + * @param file_buff 字节数组 + * @param file_ext_name 文件后缀 + * @return + * @throws Exception + */ + String uploadFile(byte[] file_buff, String file_ext_name) throws Exception; + + /** + * 上传一个本地文件 + * + * @param local_filename 本地文件名(路径+文件名+后缀) + * @param file_ext_name 文件后缀 + * @return + * @throws Exception + */ + String uploadFile(String local_filename, String file_ext_name) throws Exception; + + /** + * 上传一个文件 + * + * @param group_name 指定位置 + * @param local_filename 本地文件名(路径+文件名+后缀) + * @param file_ext_name 文件后缀 + * @return + * @throws Exception + */ + String uploadFile(String group_name, String local_filename, String file_ext_name) throws Exception; + + /** + * 上传一个MultipartFile类型文件,返回成功后文件路径,适用于保存完整路径方法 + * + * @param file + * @return + */ + String uploadFileToFastDFS(MultipartFile file); +} diff --git a/src/main/java/com/ifish/helper/LiveRoomHelper.java b/src/main/java/com/ifish/helper/LiveRoomHelper.java new file mode 100644 index 0000000..c722e96 --- /dev/null +++ b/src/main/java/com/ifish/helper/LiveRoomHelper.java @@ -0,0 +1,696 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.ifish.helper; + +import com.ifish.API.JiGuangPush; +import com.ifish.Interceptor.IfishException; +import com.ifish.bean.LiveRoomPageInfo; +import com.ifish.bean.PageResult; +import com.ifish.bean.Tbl_Device_User; +import com.ifish.bean.Tbl_Live_Message; +import com.ifish.bean.Tbl_Live_Room; +import com.ifish.bean.Tbl_Live_Watch; +import com.ifish.bean.Tbl_Push_List; +import com.ifish.bean.Tbl_User; +import com.ifish.enums.PushTypeEnum; +import com.ifish.enums.ResultEnum; +import com.ifish.mapper.Tbl_Live_Room_Mapper; +import com.ifish.util.IfishUtil; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; + +/** + * + * @author Administrator + */ +@Component +public class LiveRoomHelper implements LiveRoomHelperI { + + @Autowired + private FastDFSClientI fastDFSClientI; + + @Autowired + private Tbl_Live_Room_Mapper tbl_Live_Room_Mapper; + + @Autowired + private UserHelperI userHelperI; + + @Autowired + private DeviceHelperI deviceHelperI; + + @Autowired + private RedisHelperI redisHelperI; + + @Autowired + private RedisKeyHelperI redisKeyHelperI; + + @Autowired + private JiGuangPush jiGuangPush; + + @Autowired + private PushMessageHelperI pushMessageHelperI; + + /** + * 新增直播间 + * + * @param fileUpload + * @param liveRoom + */ + @Override + public Object addLiveRoom(MultipartFile fileUpload, Tbl_Live_Room liveRoom) { + try { + if (StringUtils.isNotBlank(liveRoom.getRoomName())) { + String roomName = new String(liveRoom.getRoomName().getBytes("iso-8859-1"), "UTF-8"); + liveRoom.setRoomName(roomName); + } + if (StringUtils.isNotBlank(liveRoom.getRoomDesc())) { + String roomDesc = new String(liveRoom.getRoomDesc().getBytes("iso-8859-1"), "UTF-8"); + liveRoom.setRoomDesc(roomDesc); + } + + if (liveRoom.getUserId() == null || liveRoom.getUserId() <= 0) { + throw new IfishException(ResultEnum.error401); + } + if (StringUtils.isBlank(liveRoom.getRoomName()) || liveRoom.getRoomName().length() > 20) { + throw new IfishException(ResultEnum.error401); + } + if (StringUtils.isBlank(liveRoom.getRoomDesc()) || liveRoom.getRoomDesc().length() > 70) { + throw new IfishException(ResultEnum.error401); + } + if (StringUtils.isBlank(liveRoom.getRoomStatus()) || liveRoom.getRoomStatus().length() > 1) { + throw new IfishException(ResultEnum.error401); + } + if (StringUtils.isBlank(liveRoom.getCameraId()) || liveRoom.getCameraId().length() > 20) { + throw new IfishException(ResultEnum.error401); + } + if (fileUpload == null || fileUpload.getSize() > 1048576) { + throw new IfishException(ResultEnum.warn205); + } + String file = fastDFSClientI.uploadFileToFastDFS(fileUpload); + if (StringUtils.isNotBlank(file)) { + liveRoom.setRoomImg(file); + } + + //用户ID + Integer userId = liveRoom.getUserId(); + Tbl_User user = userHelperI.getUserById(userId); + if (user == null) { + throw new IfishException(ResultEnum.error402); + } + //用户是否绑定摄像头 + String cameraId = liveRoom.getCameraId(); + Tbl_Device_User cameraUser = deviceHelperI.getDeviceUserByUserId_CameraId(userId, cameraId); + + if (cameraUser == null) { + throw new IfishException(ResultEnum.error402); + } + //原来不是开启状态 + Boolean cameraChange = false; + if (cameraUser.getIsLive().equals("0")) { + cameraUser.setIsLive("1"); + cameraChange = true; + } + + //新增直播间 + liveRoom.setCreateTime(new Date()); + liveRoom.setPopularityValue(0); + int i = tbl_Live_Room_Mapper.insertLiveRoom(liveRoom); + if (i > 0) { + if (cameraChange) { + deviceHelperI.updateDeviceUser(cameraUser); + } + redisKeyHelperI.deleteRedisByTbl_Live_Room(liveRoom); + Map map = new HashMap(); + map.put("roomId", liveRoom.getRoomId()); + map.put("userId", liveRoom.getUserId()); + map.put("cameraId", liveRoom.getCameraId()); + map.put("roomName", liveRoom.getRoomName()); + map.put("roomDesc", liveRoom.getRoomDesc()); + map.put("popularityValue", liveRoom.getPopularityValue()); + map.put("roomStatus", liveRoom.getRoomStatus()); + map.put("roomImg", liveRoom.getRoomImg()); + map.put("createTime", liveRoom.getCreateTime()); + map.put("zanNum", liveRoom.getZanNum()); + return IfishUtil.returnJson(ResultEnum.success.getKey(), map); + } + return IfishUtil.returnJson(ResultEnum.fail101.getKey(), ""); + } catch (Exception e) { + return IfishUtil.returnJson(ResultEnum.fail101.getKey(), ""); + } + + } + + /** + * 根据直播间ID获取直播间详情 + * + * @param roomId + * @return + */ + public Tbl_Live_Room getTbl_Live_RoomByCameraId(String cameraId) throws Exception { + Tbl_Live_Room live_Room = null; + String key = redisKeyHelperI.getTbl_Live_RoomRedisKeyByCameraId(cameraId); + String redisString = redisHelperI.getRedis(key); + if (StringUtils.isNotBlank(redisString)) { + live_Room = (Tbl_Live_Room) IfishUtil.JsonToBean(redisString, Tbl_Live_Room.class); + } else { + live_Room = tbl_Live_Room_Mapper.getTbl_Live_RoomByCameraId(cameraId); + if (live_Room != null && live_Room.getRoomId() > 0) { + redisHelperI.setRedis(key, IfishUtil.ObjectToJson(live_Room)); + } + } + return live_Room; + } + + /** + * 根据房间ID查询直播间 + * + * @param roomId + * @return + */ + public Tbl_Live_Room getTbl_Live_RoomByRoomId(Integer roomId) throws Exception { + Tbl_Live_Room live_Room = null; + String key = redisKeyHelperI.getTbl_Live_RoomRedisKeyByRoomId(roomId); + String redisString = redisHelperI.getRedis(key); + if (StringUtils.isNotBlank(redisString)) { + live_Room = (Tbl_Live_Room) IfishUtil.JsonToBean(redisString, Tbl_Live_Room.class); + } else { + live_Room = tbl_Live_Room_Mapper.getTbl_Live_RoomById(roomId); + if (live_Room != null && live_Room.getRoomId() > 0) { + redisHelperI.setRedis(key, IfishUtil.ObjectToJson(live_Room)); + } + } + return live_Room; + } + + /** + * 直播间点赞 + * + * @param roomId + * @param userId + * @return + */ + @Override + public Object liveRoomsZan(Integer roomId, Integer userId) { + try { + //以前的方式,每人每个直播间只能点赞一次,这里不采用这种方式 +// //点赞和人气值不一样,人气值只此直播间点击数,点赞指观看此直播并点赞的人数 +// Tbl_Live_Room room = getTbl_Live_RoomById(roomId); +// if (room == null) { +// throw new IfishException(ResultEnum.error402); +// } +// Tbl_User user = userHelperI.getUserById(userId); +// if (user == null) { +// throw new IfishException(ResultEnum.error402); +// } +// //点赞数量 +// Integer zanNum = tbl_Live_Room_Mapper.getLiveRoomZanCountByRoomId(roomId); +// //是否点过赞 +// int i = tbl_Live_Room_Mapper.IsZan(roomId, userId); +// Map map = new HashMap(); +// //点赞过,取消点赞 +// if (i > 0) { +// int j = tbl_Live_Room_Mapper.cancelZan(roomId, userId); +// //成功取消 +// if (j > 0) { +// zanNum--; +// map.put("isZan", 0); +// map.put("zanNum", zanNum); +// return IfishUtil.returnJson(ResultEnum.success.getKey(), map); +// } +// } //没有点赞,点赞一次 +// else { +// int j = tbl_Live_Room_Mapper.ImplementZan(roomId, userId); +// if (j > 0) { +// zanNum++; +// map.put("isZan", 1); +// map.put("zanNum", zanNum); +// return IfishUtil.returnJson(ResultEnum.success.getKey(), map); +// } +// } + Tbl_Live_Room live = getTbl_Live_RoomByRoomId(roomId); + if (live != null) { + if (live.getZanNum() != null && live.getZanNum() >= 0) { + live.setZanNum(live.getZanNum() + 1); + } else { + live.setZanNum(1); + } + int i = tbl_Live_Room_Mapper.updateLiveRoom(live); + if (i > 0) { + redisKeyHelperI.deleteRedisByTbl_Live_Room(live); + Map map = new HashMap(); + map.put("isZan", 1); + map.put("zanNum", live.getZanNum()); + return IfishUtil.returnJson(ResultEnum.success.getKey(), map); + } + } + + } catch (Exception e) { + return IfishUtil.returnJson(ResultEnum.fail101.getKey(), ""); + } + return IfishUtil.returnJson(ResultEnum.fail101.getKey(), ""); + } + + /** + * 直播间留言 + * + * @param liveMessage + * @return + */ + @Override + public Object leaveMessage(Tbl_Live_Message liveMessage) { + try { + Integer roomId = liveMessage.getRoomId(); + Integer userId = liveMessage.getUserId(); + String messageContent = liveMessage.getMessageContent(); + if (roomId != null && userId != null && StringUtils.isNotBlank(messageContent)) { + Tbl_Live_Room live_Room = getTbl_Live_RoomByRoomId(roomId); + Tbl_User user = userHelperI.getUserById(userId); + if (live_Room != null && user != null) { + liveMessage.setCreateTime(new Date()); + int i = tbl_Live_Room_Mapper.insertLiveMessage(liveMessage); + if (i > 0) { + liveMessage.setUserName(user.getNickName()); + liveMessage.setUserImg(user.getUserImg()); + redisKeyHelperI.deleteRedisByTbl_Live_Message(liveMessage); + } + liveMessage.setUserImg(user.getUserImg()); + liveMessage.setUserName(user.getNickName()); + Integer asUserId = liveMessage.getAsUserId(); + if (asUserId != null) { + Tbl_User asUser = userHelperI.getUserById(asUserId); + if (asUser != null) { + liveMessage.setAsUserName(asUser.getNickName()); + if (!asUserId.equals(userId)) { + String timestamp = IfishUtil.format(new Date()); + //发送云信消息给所@的用户 + //neteaseIM.sendMsg(userId.toString(), asUserId.toString(), "来自爱鱼看看的回复:" + messageContent, ""); + //基本参数 + Map baseMap = new HashMap(); + baseMap.put("title", PushTypeEnum.pinglun_push.getValue()); + baseMap.put("content", "来自爱鱼看看的回复:" + messageContent); + baseMap.put("user_id", asUserId.toString()); + baseMap.put("loginType", asUser.getLoginType()); + //推送参数 + Map pushMap = new HashMap(); + pushMap.put("timestamp", timestamp); + pushMap.put("msg_type", PushTypeEnum.pinglun_push.getKey()); + //推送消息 + jPushNotifcation(baseMap, pushMap); + } + } else { + Integer roomUserId = live_Room.getUserId(); + if (!roomUserId.equals(userId)) { + //发送云信消息给房主 + //neteaseIM.sendMsg(userId.toString(), roomUserId.toString(), "来自爱鱼看看的留言:" + messageContent, ""); + String timestamp = IfishUtil.format(new Date()); + //基本参数 + Map baseMap = new HashMap(); + baseMap.put("title", PushTypeEnum.pinglun_push.getValue()); + baseMap.put("content", "来自爱鱼看看的回复:" + messageContent); + baseMap.put("user_id", user.getUserId().toString()); + baseMap.put("loginType", user.getLoginType()); + //推送参数 + Map pushMap = new HashMap(); + pushMap.put("timestamp", timestamp); + pushMap.put("msg_type", PushTypeEnum.pinglun_push.getKey()); + //推送消息 + jPushNotifcation(baseMap, pushMap); + } + } + } + return IfishUtil.toJson(ResultEnum.success.getKey(), liveMessage); + } + } + return IfishUtil.toJson(ResultEnum.fail101.getKey(), ""); + } catch (Exception e) { + return IfishUtil.toJson(ResultEnum.fail101.getKey(), ""); + } + } + + /** + * 根据直播间ID获取直播间评论列表 + * + * @param roomId + * @return + */ + @Override + public Object getLeaveMessage(Integer firstResult, Integer pageSize, Integer roomId) { + try { + if (firstResult == null) { + firstResult = 0; + } + if (pageSize == null) { + pageSize = 10; + } + List list = null; + String key = redisKeyHelperI.getTbl_Live_Message(firstResult, pageSize, roomId); + String redisString = redisHelperI.getRedis(key); + if (StringUtils.isNotBlank(redisString)) { + list = (List) IfishUtil.JsonToList(redisString, Map.class); + } else { + list = tbl_Live_Room_Mapper.getLive_MessagesListByRoomId(roomId, firstResult, pageSize); + if (list != null && list.size() > 0) { + redisHelperI.setRedis(key, IfishUtil.ObjectToJson(list)); + } + } + key = redisKeyHelperI.getTbl_Live_MessageCount(roomId); + redisString = redisHelperI.getRedis(key); + Integer count = 0; + if (StringUtils.isNotBlank(redisString)) { + count = Integer.parseInt(redisString); + } else { + count = tbl_Live_Room_Mapper.getLive_MessagesCountByRoomId(roomId); + if (count > 0) { + redisHelperI.setRedis(key, count.toString()); + } + } + PageResult page = new PageResult(); + page.setList(list); + page.setTotalCount(count); + return IfishUtil.returnPageData(page, ResultEnum.success.getKey()); + } catch (Exception e) { + } + return IfishUtil.toJson(ResultEnum.fail101.getKey(), ""); + } + + /** + * 根据用户ID获取直播间信息 + * + * @param userId + * @return + */ + @Override + public Object getLiveRoomInfoByRoomId(Integer roomId) { + try { + if (roomId != null) { + //查找直播间信息 + Tbl_Live_Room curLiveRoom = getTbl_Live_RoomByRoomId(roomId); + if (curLiveRoom != null) { + Tbl_User user = userHelperI.getUserById(curLiveRoom.getUserId()); + Map map = new HashMap(); + map.put("roomId", roomId); + map.put("userImg", user.getUserImg()); + map.put("userId", curLiveRoom.getUserId()); + map.put("cameraId", curLiveRoom.getCameraId()); + map.put("roomName", curLiveRoom.getRoomName()); + map.put("roomDesc", curLiveRoom.getRoomDesc()); + map.put("popularityValue", curLiveRoom.getPopularityValue()); + map.put("roomStatus", curLiveRoom.getRoomStatus()); + map.put("roomImg", curLiveRoom.getRoomImg()); + map.put("createTime", curLiveRoom.getCreateTime()); + map.put("zanNum", curLiveRoom.getZanNum()); + return IfishUtil.toJson(ResultEnum.success.getKey(), map); + } + } + return IfishUtil.toJson(ResultEnum.success.getKey(), ""); + } catch (Exception e) { + return IfishUtil.toJson(ResultEnum.fail101.getKey(), ""); + } + } + + /** + * 根据摄像头ID获取直播间信息 + * + * @param userId + * @return + */ + @Override + public Object getLiveRoomInfoByCameraId(String cameraId) { + try { + if (cameraId != null) { + //查找直播间信息 + Tbl_Live_Room curLiveRoom = getTbl_Live_RoomByCameraId(cameraId); + if (curLiveRoom != null) { + Tbl_User user = userHelperI.getUserById(curLiveRoom.getUserId()); + Map map = new HashMap(); + map.put("roomId", curLiveRoom.getRoomId()); + map.put("userImg", user.getUserImg()); + map.put("cameraId", curLiveRoom.getCameraId()); + map.put("userId", curLiveRoom.getUserId()); + map.put("roomName", curLiveRoom.getRoomName()); + map.put("roomDesc", curLiveRoom.getRoomDesc()); + map.put("popularityValue", curLiveRoom.getPopularityValue()); + map.put("roomStatus", curLiveRoom.getRoomStatus()); + map.put("roomImg", curLiveRoom.getRoomImg()); + map.put("createTime", curLiveRoom.getCreateTime()); + return IfishUtil.toJson(ResultEnum.success.getKey(), map); + } + } + return IfishUtil.toJson(ResultEnum.success.getKey(), ""); + } catch (Exception e) { + return IfishUtil.toJson(ResultEnum.fail101.getKey(), ""); + } + } + + /** + * 根据条件查询直播间列表 + * + * @param firstResult + * @param pageSize + * @param userId + * @param orders + * @return + */ + @Override + public Object getLiveRooms(Integer firstResult, Integer pageSize, String orders) { + + try { + if (firstResult != null && pageSize != null) { + List timeList = new ArrayList(); + String key = redisKeyHelperI.getListTbl_Live_Room_RedisKey(firstResult, pageSize, orders); + String redisString = redisHelperI.getRedis(key); + if (StringUtils.isNotBlank(redisString)) { + timeList = (List) IfishUtil.JsonToList(redisString, LiveRoomPageInfo.class); + } else { + if (orders != null && orders.equals("2")) { + timeList = tbl_Live_Room_Mapper.getLiveRoomListByRenqi(pageSize, firstResult); + } else { + timeList = tbl_Live_Room_Mapper.getLiveRoomListByCreateTime(pageSize, firstResult); + } + if (timeList != null && timeList.size() > 0) { + redisHelperI.setRedis(key, IfishUtil.ObjectToJson(timeList)); + } + } + + Integer count = 0; + key = redisKeyHelperI.getTbl_Live_Room_CountRedisKey(); + redisString = redisHelperI.getRedis(key); + if (StringUtils.isNotBlank(redisString)) { + count = Integer.parseInt(redisString); + } else { + count = tbl_Live_Room_Mapper.getLiveRoomListCount(); + redisHelperI.setRedis(key, count.toString()); + } + PageResult page = new PageResult(); + page.setList(timeList); + page.setTotalCount(count); + return IfishUtil.returnPageData(page, ResultEnum.success.getKey()); + } + return IfishUtil.toJson(ResultEnum.fail101.getKey(), ""); + } catch (Exception e) { + return IfishUtil.toJson(ResultEnum.fail101.getKey(), ""); + } + + } + + /** + * 修改直播间 + * + * @param fileUpload + * @param liveRoom + * @return + */ + @Override + public Object updateLiveRoom(MultipartFile fileUpload, Tbl_Live_Room liveRoom) { + + try { + if (StringUtils.isNotBlank(liveRoom.getRoomName())) { + String roomName = new String(liveRoom.getRoomName().getBytes("iso-8859-1"), "UTF-8"); + liveRoom.setRoomName(roomName); + } + if (StringUtils.isNotBlank(liveRoom.getRoomDesc())) { + String roomDesc = new String(liveRoom.getRoomDesc().getBytes("iso-8859-1"), "UTF-8"); + liveRoom.setRoomDesc(roomDesc); + } + if (fileUpload != null && fileUpload.getSize() <= 1048576) { + String file = fastDFSClientI.uploadFileToFastDFS(fileUpload); + if (StringUtils.isNotBlank(file)) { + liveRoom.setRoomImg(file); + } + } + + int i = tbl_Live_Room_Mapper.updateLiveRoom(liveRoom); + if (i > 0) { + redisKeyHelperI.deleteRedisByTbl_Live_Room(liveRoom); + Tbl_Live_Room live = getTbl_Live_RoomByRoomId(liveRoom.getRoomId()); + return IfishUtil.toJson(ResultEnum.success.getKey(), live); + } + } catch (Exception e) { + } + return IfishUtil.toJson(ResultEnum.fail101.getKey(), ""); + } + + /** + * 修改直播间 + * + * @param fileUpload + * @param liveRoom + * @return + */ + @Override + public Object updateLiveRoom(Tbl_Live_Room liveRoom) { + + try { + + int i = tbl_Live_Room_Mapper.updateLiveRoom(liveRoom); + if (i > 0) { + redisKeyHelperI.deleteRedisByTbl_Live_Room(liveRoom); + Tbl_Live_Room live = getTbl_Live_RoomByRoomId(liveRoom.getRoomId()); + return IfishUtil.toJson(ResultEnum.success.getKey(), live); + } + } catch (Exception e) { + } + return IfishUtil.toJson(ResultEnum.fail101.getKey(), ""); + } + + /** + * 直播间人气值加1 + * + * @param roomId + * @param userId + * @return + */ + @Override + public Object popularityValue(Integer roomId, Integer userId) { + try { + if (roomId != null && userId != null) { + //浏览直播间记录 + Tbl_Live_Watch browseRoom = tbl_Live_Room_Mapper.getTbl_Live_WatchByRoomIdAndUserId(roomId, userId); + Date date = new Date(); + //新增浏览记录 + if (browseRoom != null) { + browseRoom.setUpdateTime(date); + tbl_Live_Room_Mapper.updateTbl_Live_Watch(browseRoom); + } else { + //更新浏览记录 + browseRoom = new Tbl_Live_Watch(); + browseRoom.setRoomId(roomId); + browseRoom.setUserId(userId); + browseRoom.setUpdateTime(date); + browseRoom.setCreateTime(date); + tbl_Live_Room_Mapper.insertTbl_Live_Watch(browseRoom); + } + //查找直播间信息 + Tbl_Live_Room curLiveRoom = getTbl_Live_RoomByRoomId(roomId); + if (curLiveRoom != null) { + Integer popularityValue = null; + if (curLiveRoom.getPopularityValue() == null) { + popularityValue = 0; + } else { + popularityValue = curLiveRoom.getPopularityValue(); + } + //人气值加一 + popularityValue++; + curLiveRoom.setPopularityValue(popularityValue); + tbl_Live_Room_Mapper.updateLiveRoomPopularityValue(curLiveRoom); + redisKeyHelperI.deleteRedisByTbl_Live_Room(curLiveRoom); + Map map = new HashMap(); + map.put("roomId", roomId); + map.put("popularityValue", popularityValue); + return IfishUtil.toJson(ResultEnum.success.getKey(), popularityValue); + } + } + } catch (Exception e) { + } + return IfishUtil.toJson(ResultEnum.fail101.getKey(), ""); + } + + /** + * 极光推送 + * + * @param userId + */ + public boolean jPushNotifcation(Map baseMap, Map pushMap) { + try { + //登录类型 + String loginType = baseMap.get("loginType"); + if (loginType != null) { + //推送消息类型 + String msgType = pushMap.get("msg_type"); + String userId = baseMap.get("user_id"); + String title = baseMap.get("title"); + String content = baseMap.get("content"); + boolean result = false; + if (loginType.equals("ios")) { + result = jiGuangPush.pushMessageByIOS(title, content, userId, pushMap); + } else if (loginType.equals("android")) { + result = jiGuangPush.pushMessageByAndroid(title, content, userId, pushMap); + } + //推送记录 + Tbl_Push_List pushList = new Tbl_Push_List(); + if (msgType.equals(PushTypeEnum.remove_device.getKey())) { + pushList.setUserId(Integer.valueOf(userId)); + pushList.setDeviceId(Integer.valueOf(pushMap.get("device_id"))); + pushList.setPhoneType(loginType); + pushList.setShowName(pushMap.get("showName")); + pushList.setPushType(msgType); + pushList.setPushTitle(title); + pushList.setPushContext(content); + pushList.setJpushStatus(result ? "1" : "0"); + pushList.setCreateTime(new Date()); + pushMessageHelperI.save(pushList); + return true; + } //发送看护报告推送 + else if (msgType.equals(PushTypeEnum.send_report.getKey())) { + String reportId = baseMap.get("reportId"); + if (reportId != null) { + pushList.setReportId(Integer.valueOf(reportId)); + } + pushList.setUserId(Integer.valueOf(userId)); + pushList.setPhoneType(loginType); + pushList.setPushType(msgType); + pushList.setPushTitle(title); + pushList.setPushContext(content); + pushList.setPushLink(pushMap.get("push_link")); + pushList.setJpushStatus(result ? "1" : "0"); + pushList.setCreateTime(new Date()); + pushMessageHelperI.save(pushList); + return true; + } + } + } catch (Exception e) { + throw new RuntimeException(); + } + return false; + } + + /** + * 根据摄像头删除直播间 + * + * @param cameraId + * @return + */ + @Override + public Integer deleteLiveRoom(String cameraId) { + try { + Tbl_Live_Room live_Room = getTbl_Live_RoomByCameraId(cameraId); + if (live_Room != null) { + redisKeyHelperI.deleteRedisByTbl_Live_Room(live_Room); + } + int i = tbl_Live_Room_Mapper.deleteLive_RoomByCameraId(cameraId); + return i; + } catch (Exception e) { + return 0; + } + } +} diff --git a/src/main/java/com/ifish/helper/LiveRoomHelperI.java b/src/main/java/com/ifish/helper/LiveRoomHelperI.java new file mode 100644 index 0000000..24f0194 --- /dev/null +++ b/src/main/java/com/ifish/helper/LiveRoomHelperI.java @@ -0,0 +1,112 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.ifish.helper; + +import com.ifish.bean.Tbl_Live_Message; +import com.ifish.bean.Tbl_Live_Room; +import org.springframework.web.multipart.MultipartFile; + +/** + * + * @author Administrator + */ +public interface LiveRoomHelperI { + + /** + * 新增直播间 + * + * @param fileUpload + * @param liveRoom + */ + Object addLiveRoom(MultipartFile fileUpload, Tbl_Live_Room liveRoom); + + /** + * 直播间点赞 + * + * @param roomId + * @param userId + * @return + */ + Object liveRoomsZan(Integer roomId, Integer userId); + + /** + * 直播间留言 + * + * @param liveMessage + * @return + */ + Object leaveMessage(Tbl_Live_Message liveMessage); + + /** + * 根据直播间ID获取直播间评论列表 + * + * @param roomId + * @return + */ + Object getLeaveMessage(Integer firstResult, Integer pageSize, Integer roomId); + + /** + * 根据用户ID获取直播间信息 + * + * @param userId + * @return + */ + Object getLiveRoomInfoByRoomId(Integer rommId); + + /** + * 根据摄像头ID获取直播间信息 + * + * @param userId + * @return + */ + public Object getLiveRoomInfoByCameraId(String cameraId); + + /** + * 根据条件查询直播间列表 + * + * @param firstResult + * @param pageSize + * @param userId + * @param orders + * @return + */ + Object getLiveRooms(Integer firstResult, Integer pageSize, String orders); + + /** + * 修改直播间 + * + * @param fileUpload + * @param liveRoom + * @return + */ + Object updateLiveRoom(MultipartFile fileUpload, Tbl_Live_Room liveRoom); + + /** + * 修改直播间 + * + * @param fileUpload + * @param liveRoom + * @return + */ + Object updateLiveRoom(Tbl_Live_Room liveRoom); + + /** + * 直播间人气值加1 + * + * @param roomId + * @param userId + * @return + */ + Object popularityValue(Integer roomId, Integer userId); + + /** + * 根据摄像头删除直播间 + * + * @param cameraId + * @return + */ + Integer deleteLiveRoom(String cameraId); +} diff --git a/src/main/java/com/ifish/helper/RedisKeyHelper.java b/src/main/java/com/ifish/helper/RedisKeyHelper.java index a659f28..879d7a2 100644 --- a/src/main/java/com/ifish/helper/RedisKeyHelper.java +++ b/src/main/java/com/ifish/helper/RedisKeyHelper.java @@ -12,6 +12,7 @@ import com.ifish.bean.Tbl_Live_Message; import com.ifish.bean.Tbl_Live_Room; import com.ifish.bean.Tbl_Push_List; import com.ifish.bean.Tbl_User; +import com.ifish.mapper.Tbl_Live_Room_Mapper; import com.ifish.util.RedisKey; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -30,6 +31,8 @@ public class RedisKeyHelper implements RedisKeyHelperI { private DeviceHelperI deviceHelper; @Autowired private UserHelperI userHelperI; + @Autowired + private Tbl_Live_Room_Mapper tbl_Live_Room_Mapper; /** * 根据phoneNumber获取Tbl_User用户信息的Redis缓存key键值 @@ -507,7 +510,11 @@ public class RedisKeyHelper implements RedisKeyHelperI { */ @Override public void deleteRedisByTbl_Live_Room(Tbl_Live_Room live_Room) { - + if ((live_Room.getRoomId() == null || live_Room.getRoomId() == 0) && StringUtils.isNotBlank(live_Room.getCameraId())) { + live_Room = tbl_Live_Room_Mapper.getTbl_Live_RoomByCameraId(live_Room.getCameraId()); + } else if (StringUtils.isBlank(live_Room.getCameraId()) && (live_Room.getRoomId() != null && live_Room.getRoomId() > 0)) { + live_Room = tbl_Live_Room_Mapper.getTbl_Live_RoomById(live_Room.getRoomId()); + } if (live_Room.getRoomId() != null && live_Room.getRoomId() > 0) { redisHelperI.deleteRedis(getTbl_Live_RoomRedisKeyByRoomId(live_Room.getRoomId())); } @@ -602,6 +609,7 @@ public class RedisKeyHelper implements RedisKeyHelperI { * * @param pushId */ + @Override public void deleteRedisByTbl_Push_List(Tbl_Push_List tbl_Push_List) { if (tbl_Push_List.getPushId() != null) { redisHelperI.deleteRedis(getTbl_Push_List_RedisByPushId(tbl_Push_List.getPushId())); @@ -612,8 +620,17 @@ public class RedisKeyHelper implements RedisKeyHelperI { /** * 删除推送列表类缓存 */ + @Override public void deleteRedisByTbl_Push_ListToAllRedisList() { redisHelperI.delRedisByTagKey(RedisKey.PUSHLIST_SELECT); } + /** + * 删除鱼缸厂信息缓存 + */ + @Override + public void deleteTbl_Vender_List_RedisKey() { + redisHelperI.delRedisByTagKey(RedisKey.VENDER_CODE); + } + } diff --git a/src/main/java/com/ifish/helper/RedisKeyHelperI.java b/src/main/java/com/ifish/helper/RedisKeyHelperI.java index de5cbf0..bb36d7f 100644 --- a/src/main/java/com/ifish/helper/RedisKeyHelperI.java +++ b/src/main/java/com/ifish/helper/RedisKeyHelperI.java @@ -383,4 +383,9 @@ public interface RedisKeyHelperI { */ public void deleteRedisByTbl_Push_ListToAllRedisList(); + /** + * 删除鱼缸厂信息缓存 + */ + public void deleteTbl_Vender_List_RedisKey(); + } diff --git a/src/main/java/com/ifish/helper/VenderHelper.java b/src/main/java/com/ifish/helper/VenderHelper.java new file mode 100644 index 0000000..6f09980 --- /dev/null +++ b/src/main/java/com/ifish/helper/VenderHelper.java @@ -0,0 +1,269 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.ifish.helper; + +import com.ifish.bean.Tbl_Vender_List; +import com.ifish.mapper.Tbl_Vender_List_Mapper; +import com.ifish.util.IfishUtil; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.ModelAndView; + +/** + * + * @author Administrator + */ +@Component +public class VenderHelper implements VenderHelperI { + + @Autowired + private Tbl_Vender_List_Mapper tbl_Vender_List_Mapper; + + @Autowired + private FastDFSClientI fastDFSClientI; + + @Autowired + private RedisKeyHelperI redisKeyHelperI; + + /** + * 鱼缸厂列表 + * + * @return + */ + public ModelAndView getlist() { + ModelAndView mv = new ModelAndView(); + mv.setViewName("venderlist"); + mv.addObject("title", "鱼缸厂列表"); + mv.addObject("myjs", "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "" + + "" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "" + + " "); + return mv; + } + + /** + * 鱼缸厂列表数据 + * + * @return + */ + @Override + public Object getlistData(String draw, Integer start, Integer length, String appShow, String sortField, String sortMode, String brandName) { + if (StringUtils.isBlank(sortMode)) { + sortMode = "ASC"; + } + if (StringUtils.isBlank(sortField)) { + sortField = "brand_code"; + } + List list = tbl_Vender_List_Mapper.getlistData(start, length, appShow, sortField, sortMode, brandName); + for (Map map : list) { + String dateTime = IfishUtil.format((Date) map.get("createTime")); + map.put("createTime", dateTime); + } + int allCount = tbl_Vender_List_Mapper.getlistDataAllCount(); + int count = tbl_Vender_List_Mapper.getlistDataCount(appShow, brandName); + + Map map = new HashMap(); + map.put("data", list); + map.put("draw", draw); + map.put("recordsTotal", allCount); + map.put("recordsFiltered", count); + return map; + } + + /** + * 根据鱼缸厂code获取详情页 + * + * @param brandCode + * @return + */ + @Override + public ModelAndView getvender(String brandCode) { + ModelAndView mv = new ModelAndView(); + + if (StringUtils.isBlank(brandCode)) { + mv.setViewName("redirect:venderlist"); + return mv; + } + Tbl_Vender_List vender = tbl_Vender_List_Mapper.getTbl_Vender_ListByBrandCode(brandCode); + if (vender == null) { + mv.setViewName("redirect:venderlist"); + return mv; + } else { + mv.addObject("vender", vender); + } + + mv.setViewName("venderdetail"); + mv.addObject("title", "鱼缸厂详情"); + mv.addObject("pagetitle", "鱼缸厂详情"); + mv.addObject("myjs", "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "" + + "" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "" + + " "); + return mv; + } + + /** + * 修改,插入 鱼缸厂信息 + * + * @param brandLogoImg + * @param tbl_Vender_List + * @return + */ + @Override + public Object updateVender(MultipartFile brandLogoImg, Tbl_Vender_List tbl_Vender_List) { + try { + if (StringUtils.isNotBlank(tbl_Vender_List.getBrandName())) { + String brandName = new String(tbl_Vender_List.getBrandName().getBytes("iso-8859-1"), "UTF-8"); + tbl_Vender_List.setBrandName(brandName); + } + if (StringUtils.isNotBlank(tbl_Vender_List.getContactAddress())) { + String contactAddress = new String(tbl_Vender_List.getContactAddress().getBytes("iso-8859-1"), "UTF-8"); + tbl_Vender_List.setContactAddress(contactAddress); + } + Tbl_Vender_List oldTbl_Vender_List = tbl_Vender_List_Mapper.getTbl_Vender_ListByBrandCode(tbl_Vender_List.getBrandCode()); + if (oldTbl_Vender_List == null) { + //插入 + if (brandLogoImg != null) { + String path = fastDFSClientI.uploadFileToFastDFS(brandLogoImg); + tbl_Vender_List.setBrandLogo(path); + } else { + return "请上传正确的Logo图片"; + } + int i = tbl_Vender_List_Mapper.insertVender(tbl_Vender_List); + if (i > 0) { + return "添加成功"; + } else { + return "添加失败"; + } + } else { + //修改 + if (brandLogoImg != null) { + String path = fastDFSClientI.uploadFileToFastDFS(brandLogoImg); + tbl_Vender_List.setBrandLogo(path); + } + int i = tbl_Vender_List_Mapper.updateVender(tbl_Vender_List); + if (i > 0) { + redisKeyHelperI.deleteTbl_Vender_List_RedisKey(); + return "修改成功"; + } else { + return "修改失败"; + } + } + } catch (Exception e) { + } + return "失败"; + } + + /** + * 新增鱼缸厂页面 + * + * @return + */ + @Override + public ModelAndView addVender() { + ModelAndView mv = new ModelAndView(); + + mv.setViewName("venderdetail"); + mv.addObject("title", "添加鱼缸厂"); + mv.addObject("pagetitle", "添加鱼缸厂"); + mv.addObject("myjs", "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "" + + "" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "" + + " "); + return mv; + } + + /** + * 根据鱼缸厂code删除鱼缸厂信息 + * + * @param code + * @return + */ + @Override + public Object deleteVender(String code) { + Tbl_Vender_List tbl_Vender_List = tbl_Vender_List_Mapper.getTbl_Vender_ListByBrandCode(code); + if (tbl_Vender_List != null) { + int i = tbl_Vender_List_Mapper.deleteVender(code); + if (i > 0) { + redisKeyHelperI.deleteTbl_Vender_List_RedisKey(); + return "删除成功"; + } + } else { + return "删除失败!没有找到鱼缸厂信息!"; + } + return "删除失败!"; + } + + /** + * 修改鱼缸厂在APP端是否展示 + * + * @param code + * @param appshow + * @return + */ + @Override + public Object updateAppShow(String code, String appshow) { + try { + Tbl_Vender_List tbl_Vender_List = new Tbl_Vender_List(); + tbl_Vender_List.setAppShow(appshow); + tbl_Vender_List.setBrandCode(code); + int i = tbl_Vender_List_Mapper.updateVender(tbl_Vender_List); + redisKeyHelperI.deleteTbl_Vender_List_RedisKey(); + if (i > 0) { + return "修改成功"; + } else { + return "修改失败"; + } + } catch (Exception e) { + } + return "修改失败"; + } +} diff --git a/src/main/java/com/ifish/helper/VenderHelperI.java b/src/main/java/com/ifish/helper/VenderHelperI.java new file mode 100644 index 0000000..2252e86 --- /dev/null +++ b/src/main/java/com/ifish/helper/VenderHelperI.java @@ -0,0 +1,72 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.ifish.helper; + +import com.ifish.bean.Tbl_Vender_List; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.ModelAndView; + +/** + * + * @author Administrator + */ +public interface VenderHelperI { + + /** + * 鱼缸厂列表 + * + * @return + */ + ModelAndView getlist(); + + /** + * 鱼缸厂列表数据 + * + * @return + */ + public Object getlistData(String draw, Integer start, Integer length, String appShow, String sortField, String sortMode, String brandName); + + /** + * 根据鱼缸厂code获取详情页 + * + * @param brandCode + * @return + */ + public ModelAndView getvender(String brandCode); + + /** + * 修改,插入 鱼缸厂信息 + * + * @param brandLogoImg + * @param tbl_Vender_List + * @return + */ + public Object updateVender(MultipartFile brandLogoImg, Tbl_Vender_List tbl_Vender_List); + + /** + * 新增鱼缸厂页面 + * + * @return + */ + public ModelAndView addVender(); + + /** + * 根据鱼缸厂code删除鱼缸厂信息 + * + * @param code + * @return + */ + public Object deleteVender(String code); + + /** + * 修改鱼缸厂在APP端是否展示 + * + * @param code + * @param appshow + * @return + */ + public Object updateAppShow(String code, String appshow); +} diff --git a/src/main/java/com/ifish/mapper/Tbl_Device_Mapper.java b/src/main/java/com/ifish/mapper/Tbl_Device_Mapper.java index 3575015..9213cc0 100644 --- a/src/main/java/com/ifish/mapper/Tbl_Device_Mapper.java +++ b/src/main/java/com/ifish/mapper/Tbl_Device_Mapper.java @@ -30,7 +30,7 @@ public interface Tbl_Device_Mapper { * @param deviceid * @return */ - @Select("SELECT device_id,server_ip,device_ip,is_camera,mac_address,login_time,is_blacklist,hardware_type,on_off,off_line," + @Select("SELECT device_id,server_ip,device_ip,is_camera,mac_address,login_time,is_blacklist,hardware_type,on_off," + "today_remind,water_remind,remind_cycle,remind_date,factory_code,brand_code,create_time,active_code,active_time,update_time,camera_id from tbl_device WHERE device_id= #{deviceid}") Tbl_Device getDeviceById(@Param("deviceid") Integer deviceid); @@ -40,7 +40,7 @@ public interface Tbl_Device_Mapper { * @param deviceid * @return */ - @Select("SELECT device_id,server_ip,device_ip,is_camera,mac_address,login_time,is_blacklist,hardware_type,on_off,off_line," + @Select("SELECT device_id,server_ip,device_ip,is_camera,mac_address,login_time,is_blacklist,hardware_type,on_off," + "today_remind,water_remind,remind_cycle,remind_date,factory_code,brand_code,create_time,active_code,active_time,update_time,camera_id from tbl_device WHERE camera_id= #{cameraID}") Tbl_Device getDeviceByCameraId(@Param("cameraID") String cameraID); @@ -50,7 +50,7 @@ public interface Tbl_Device_Mapper { * @param deviceid * @return */ - @Select("SELECT device_id,server_ip,device_ip,is_camera,mac_address,login_time,is_blacklist,hardware_type,on_off,off_line," + @Select("SELECT device_id,server_ip,device_ip,is_camera,mac_address,login_time,is_blacklist,hardware_type,on_off," + "today_remind,water_remind,remind_cycle,remind_date,factory_code,brand_code,create_time,active_code,active_time,update_time,camera_id from tbl_device WHERE mac_address= #{mac_address}") Tbl_Device getDeviceByMacAddress(@Param("mac_address") String macAddress); @@ -61,7 +61,7 @@ public interface Tbl_Device_Mapper { * @param deviceId * @return */ - @Select("SELECT id,user_id,device_id,is_master,show_name,create_time,update_time,custom_icon_name,custom_show_name,is_look,is_live from tbl_device_user WHERE user_id = #{userid}") + @Select("SELECT id,user_id,device_id,is_master,show_name,create_time,update_time,custom_icon_name,custom_show_name,is_look,is_live,off_line from tbl_device_user WHERE user_id = #{userid}") List getDeviceUsersByUserId(@Param("userid") Integer userid); /** @@ -71,7 +71,7 @@ public interface Tbl_Device_Mapper { * @param deviceId * @return */ - @Select("SELECT id,user_id,device_id,is_master,show_name,create_time,update_time,custom_icon_name,custom_show_name,is_look,is_live from tbl_device_user WHERE user_id <> ${userid} AND device_id = #{deviceid}") + @Select("SELECT id,user_id,device_id,is_master,show_name,create_time,update_time,custom_icon_name,custom_show_name,is_look,is_live,off_line from tbl_device_user WHERE user_id <> ${userid} AND device_id = #{deviceid}") List getOtherDeviceUsersByOtherUserIdAndDeviceId(@Param("userid") Integer userid, @Param("deviceid") Integer deviceId); /** @@ -81,7 +81,7 @@ public interface Tbl_Device_Mapper { * @param deviceId * @return */ - @Select("SELECT id,user_id,device_id,is_master,show_name,create_time,update_time,custom_icon_name,custom_show_name,is_look,is_live from tbl_device_user WHERE user_id = #{userid} AND device_id = #{deviceid}") + @Select("SELECT id,user_id,device_id,is_master,show_name,create_time,update_time,custom_icon_name,custom_show_name,is_look,is_live,off_line from tbl_device_user WHERE user_id = #{userid} AND device_id = #{deviceid}") Tbl_Device_User getDeviceUsersByUserIdAndDeviceId(@Param("userid") Integer userid, @Param("deviceid") Integer deviceId); /** @@ -90,7 +90,7 @@ public interface Tbl_Device_Mapper { * @param deviceId * @return */ - @Select("SELECT id,user_id,device_id,is_master,show_name,create_time,update_time,custom_icon_name,custom_show_name,is_look,is_live from tbl_device_user WHERE device_id = #{deviceid}") + @Select("SELECT id,user_id,device_id,is_master,show_name,create_time,update_time,custom_icon_name,custom_show_name,is_look,is_live,off_line from tbl_device_user WHERE device_id = #{deviceid}") List getDeviceUsersByDeviceId(@Param("deviceid") Integer deviceId); /** diff --git a/src/main/java/com/ifish/mapper/Tbl_Device_MapperSql.java b/src/main/java/com/ifish/mapper/Tbl_Device_MapperSql.java index 9a1045f..3728de7 100644 --- a/src/main/java/com/ifish/mapper/Tbl_Device_MapperSql.java +++ b/src/main/java/com/ifish/mapper/Tbl_Device_MapperSql.java @@ -55,6 +55,9 @@ public class Tbl_Device_MapperSql { if (StringUtils.isNotBlank(device_User.getIsLive())) { sb.append("is_live = #{deviceUser.isLive}, "); } + if (StringUtils.isNotBlank(device_User.getOffLine())) { + sb.append("off_line = #{deviceUser.offLine}, "); + } sb.append("update_time = now() "); sb.append(" WHERE id = #{deviceUser.id}"); return sb.toString(); @@ -234,9 +237,6 @@ public class Tbl_Device_MapperSql { if (StringUtils.isNotBlank(device.getOnOff())) { sb.append("on_off = #{device.onOff}, "); } - if (StringUtils.isNotBlank(device.getOffLine())) { - sb.append("off_line = #{device.offLine} "); - } if (StringUtils.isNotBlank(device.getTodayRemind())) { sb.append("today_remind = #{device.todayRemind}, "); } diff --git a/src/main/java/com/ifish/mapper/Tbl_Factory_List_Mapper.java b/src/main/java/com/ifish/mapper/Tbl_Factory_List_Mapper.java index 82d1c62..be3d8c8 100644 --- a/src/main/java/com/ifish/mapper/Tbl_Factory_List_Mapper.java +++ b/src/main/java/com/ifish/mapper/Tbl_Factory_List_Mapper.java @@ -144,4 +144,13 @@ public interface Tbl_Factory_List_Mapper { */ @Insert("INSERT INTO tbl_factory_vender(factory_code,brand_code) VALUES(#{factorycode},#{brandcode})") Integer insertFactoryVender(@Param("factorycode") String factoryCode, @Param("brandcode") String brandCode); + + /** + * 插入一条电子厂数据 + * + * @param tbl_Factory_List + * @return + */ + @Insert("INSERT INTO Tbl_factory_list(factory_code,factory_name,create_time,is_tax) VALUES(#{factory.factoryCode},#{factory.factoryName},NOW(),'0')") + Integer insertFactoryList(@Param("factory") Tbl_Factory_List tbl_Factory_List); } diff --git a/src/main/java/com/ifish/mapper/Tbl_Live_Room_Mapper.java b/src/main/java/com/ifish/mapper/Tbl_Live_Room_Mapper.java index 440ff78..3ece977 100644 --- a/src/main/java/com/ifish/mapper/Tbl_Live_Room_Mapper.java +++ b/src/main/java/com/ifish/mapper/Tbl_Live_Room_Mapper.java @@ -91,6 +91,15 @@ public interface Tbl_Live_Room_Mapper { @Select("SELECT ROOM_ID,USER_ID,CAMERA_ID,ROOM_NAME,ROOM_DESC,ROOM_STATUS,POPULARITY_VALUE,CREATE_TIME,UPDATE_TIME,room_Img,zanNum FROM TBL_LIVE_ROOM WHERE ROOM_ID = #{roomid}") Tbl_Live_Room getTbl_Live_RoomById(@Param("roomid") Integer roomid); + /** + * 根据摄像头ID查询直播间信息 + * + * @param roomid + * @return + */ + @Select("SELECT ROOM_ID,USER_ID,CAMERA_ID,ROOM_NAME,ROOM_DESC,ROOM_STATUS,POPULARITY_VALUE,CREATE_TIME,UPDATE_TIME,room_Img,zanNum FROM TBL_LIVE_ROOM WHERE CAMERA_ID = #{cameraid}") + Tbl_Live_Room getTbl_Live_RoomByCameraId(@Param("cameraid") String cameraid); + /** * 根据开播时间来查询直播间 * @@ -175,9 +184,18 @@ public interface Tbl_Live_Room_Mapper { + "from tbl_live_message l " + "LEFT JOIN tbl_user u ON l.user_id = u.user_id " + "LEFT JOIN tbl_user uu ON l.as_user_id=uu.user_id " - + "WHERE room_id = #{roomid} LIMIT ${first},${page} ") + + "WHERE room_id = #{roomid} ORDER BY l.create_time DESC LIMIT ${first},${page} ") List getLive_MessagesListByRoomId(@Param("roomid") Integer roomid, @Param("first") Integer firstResult, @Param("page") Integer pageSize); + /** + * 获取直播间评论总数 + * + * @param roomid + * @return + */ + @Select("select count(1) from tbl_live_message WHERE room_id = #{roomid}") + Integer getLive_MessagesCountByRoomId(@Param("roomid") Integer roomid); + /** * 根据直播间和用户ID获取观看记录 * @@ -206,4 +224,12 @@ public interface Tbl_Live_Room_Mapper { @Insert("INSERT INTO TBL_LIVE_WATCH(room_id,user_id,update_time,create_time) VALUES (#{live.roomId},#{live.userId},#{live.updateTime},#{live.createTime})") Integer insertTbl_Live_Watch(@Param("live") Tbl_Live_Watch live); + /** + * 根据摄像头ID删除直播间 + * + * @param cameraId + * @return + */ + @Delete("DELETE TBL_LIVE_ROOM WHERE camera_id = #{cameraid}") + Integer deleteLive_RoomByCameraId(@Param("cameraid") String cameraId); } diff --git a/src/main/java/com/ifish/mapper/Tbl_Vender_List_Mapper.java b/src/main/java/com/ifish/mapper/Tbl_Vender_List_Mapper.java new file mode 100644 index 0000000..2435dbd --- /dev/null +++ b/src/main/java/com/ifish/mapper/Tbl_Vender_List_Mapper.java @@ -0,0 +1,91 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.ifish.mapper; + +import com.ifish.bean.Tbl_Vender_List; +import java.util.List; +import java.util.Map; +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.SelectProvider; +import org.apache.ibatis.annotations.UpdateProvider; + +/** + * + * @author Administrator + */ +public interface Tbl_Vender_List_Mapper { + + /** + * 鱼缸厂获取列表数据 + * + * @param start + * @param length + * @param appShow + * @param sortField + * @param sortMode + * @param brandName + * @return + */ + @SelectProvider(type = Tbl_Vender_List_MapperSql.class, method = "getlistData") + List getlistData(Integer start, Integer length, @Param("appshow") String appShow, String sortField, String sortMode, String brandName); + + /** + * 获取所有鱼缸厂总数 + * + * @return + */ + @Select("SELECT COUNT(1) from tbl_vender_list") + Integer getlistDataAllCount(); + + /** + * 根据条件查询鱼缸厂数量 + * + * @param appShow + * @param brandName + * @return + */ + @SelectProvider(type = Tbl_Vender_List_MapperSql.class, method = "getlistDataCount") + Integer getlistDataCount(@Param("appshow") String appShow, @Param("brandname") String brandName); + + /** + * 根据鱼缸厂代码获取鱼缸厂对象 + * + * @param brandCode + * @return + */ + @Select("SELECT brand_code ,brand_logo ,brand_name,brand_introduce,app_show,contact_phone,contact_address,create_time from tbl_vender_list where brand_code = #{code}") + Tbl_Vender_List getTbl_Vender_ListByBrandCode(@Param("code") String brandCode); + + /** + * 修改鱼缸厂信息 + * + * @param vender_List + * @return + */ + @UpdateProvider(type = Tbl_Vender_List_MapperSql.class, method = "updateVender") + Integer updateVender(@Param("vender") Tbl_Vender_List vender_List); + + /** + * 插入一条鱼缸厂信息 + * + * @param vender_List + * @return + */ + @Insert("INSERT Tbl_Vender_List (brand_code,brand_logo,brand_name,brand_introduce,app_show,contact_phone,contact_address,create_time) VALUES (#{vender.brandCode},#{vender.brandLogo},#{vender.brandName},#{vender.brandIntroduce},#{vender.appShow},#{vender.contactPhone},#{vender.contactAddress},NOW())") + Integer insertVender(@Param("vender") Tbl_Vender_List vender_List); + + /** + * 删除一条鱼缸厂信息 + * + * @param brandCode + * @return + */ + @Delete("DELETE FROM Tbl_Vender_List WHERE brand_code = #{brandCode}") + Integer deleteVender(@Param("brandCode") String brandCode); +} diff --git a/src/main/java/com/ifish/mapper/Tbl_Vender_List_MapperSql.java b/src/main/java/com/ifish/mapper/Tbl_Vender_List_MapperSql.java new file mode 100644 index 0000000..839b00a --- /dev/null +++ b/src/main/java/com/ifish/mapper/Tbl_Vender_List_MapperSql.java @@ -0,0 +1,100 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.ifish.mapper; + +import com.ifish.bean.Tbl_Vender_List; +import org.apache.commons.lang3.StringUtils; +import org.apache.ibatis.annotations.Param; + +/** + * + * @author Administrator + */ +public class Tbl_Vender_List_MapperSql { + + /** + * 根据条件查询鱼缸厂信息 + * + * @param start + * @param length + * @param appShow + * @param sortField + * @param sortMode + * @param brandName + * @return + */ + public String getlistData(Integer start, Integer length, @Param("appshow") String appShow, String sortField, String sortMode, String brandName) { + StringBuilder sb = new StringBuilder(); + + sb.append("SELECT brand_code AS brandCode,brand_logo AS brandLogo,brand_name AS brandName,brand_introduce AS brandIntroduce,app_show AS appShow,contact_phone AS phone,contact_address AS address,create_time AS createTime from tbl_vender_list "); + sb.append(" WHERE 1=1 "); + if (StringUtils.isNotBlank(appShow)) { + sb.append(" AND app_show = #{appshow}"); + } + if (StringUtils.isNotBlank(brandName)) { + sb.append(" AND brand_name LIKE '%" + brandName + "%'"); + } + sb.append(" ORDER BY ").append(sortField + " ").append(sortMode);; + + sb.append(" LIMIT ").append(start).append(",").append(length); + return sb.toString(); + } + + /** + * 根据条件查询鱼缸厂数量 + * + * @param appShow + * @param brandName + * @return + */ + public String getlistDataCount(@Param("appshow") String appShow, @Param("brandname") String brandName) { + StringBuilder sb = new StringBuilder(); + + sb.append("SELECT count(1) from tbl_vender_list "); + sb.append(" WHERE 1=1 "); + if (StringUtils.isNotBlank(appShow)) { + sb.append(" AND app_show = #{appshow}"); + } + if (StringUtils.isNotBlank(brandName)) { + sb.append(" AND brand_name = #{brandname}"); + } + + return sb.toString(); + } + + /** + * 修改鱼缸厂信息 + * + * @param vender_List + * @return + */ + public String updateVender(@Param("vender") Tbl_Vender_List vender_List) { + StringBuilder sb = new StringBuilder(); + + sb.append("UPDATE TBL_VENDER_LIST SET "); + if (StringUtils.isNotBlank(vender_List.getBrandLogo())) { + sb.append(" brand_logo = #{vender.brandLogo}, "); + } + if (StringUtils.isNotBlank(vender_List.getBrandName())) { + sb.append(" brand_name = #{vender.brandName}, "); + } + if (StringUtils.isNotBlank(vender_List.getBrandIntroduce())) { + sb.append(" brand_introduce = #{vender.brandIntroduce}, "); + } + if (StringUtils.isNotBlank(vender_List.getAppShow())) { + sb.append(" app_show = #{vender.appShow}, "); + } + if (StringUtils.isNotBlank(vender_List.getContactPhone())) { + sb.append(" contact_phone = #{vender.contactPhone}, "); + } + if (StringUtils.isNotBlank(vender_List.getContactAddress())) { + sb.append(" contact_address = #{vender.contactAddress}, "); + } + sb.append("update_time = NOW() ").append("WHERE brand_code = #{vender.brandCode}"); + return sb.toString(); + } + +} diff --git a/src/main/webapp/WEB-INF/layout/IndexPage.jsp b/src/main/webapp/WEB-INF/layout/IndexPage.jsp index 59307cd..ab37978 100644 --- a/src/main/webapp/WEB-INF/layout/IndexPage.jsp +++ b/src/main/webapp/WEB-INF/layout/IndexPage.jsp @@ -131,9 +131,9 @@