diff --git a/nb-configuration.xml b/nb-configuration.xml
index 99174dc..cd0068d 100644
--- a/nb-configuration.xml
+++ b/nb-configuration.xml
@@ -13,7 +13,7 @@ You can copy and paste the single properties, into the pom.xml file and the IDE
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
- 1.6-web
+ 1.7-web
Tomcat
diff --git a/src/main/java/com/ifish/config/MyUserDetailService.java b/src/main/java/com/ifish/config/MyUserDetailService.java
new file mode 100644
index 0000000..5723bb8
--- /dev/null
+++ b/src/main/java/com/ifish/config/MyUserDetailService.java
@@ -0,0 +1,57 @@
+/*
+ * 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.config;
+
+import com.ifish.bean.Tbl_Security_User;
+import com.ifish.helper.UserHelper;
+import java.util.ArrayList;
+import java.util.List;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.authority.SimpleGrantedAuthority;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+
+/**
+ *
+ * @author Administrator
+ */
+public class MyUserDetailService implements UserDetailsService {
+
+ private final UserHelper userHelper;
+
+ public MyUserDetailService(UserHelper u) {
+ this.userHelper = u;
+ }
+
+ @Override
+ public UserDetails loadUserByUsername(String userName) throws UsernameNotFoundException {
+
+ Tbl_Security_User user = userHelper.getTbl_Security_User(userName);
+
+ if (user == null) {
+ throw new UsernameNotFoundException("用户不存在!");
+ }
+
+ List authorities = new ArrayList();
+ authorities.add(new SimpleGrantedAuthority("ROLE_" + user.getRole()));
+ boolean enabled = true;
+ boolean accountNonExpired = true;
+ boolean credentialsNonExpired = true;
+ boolean accountNonLocked = true;
+
+ UserInfo userdetails = new UserInfo();
+ userdetails.setId(user.getId());
+ userdetails.setUsername(user.getUsername());
+ userdetails.setEmail(user.getEmail());
+ userdetails.setRole(user.getRole());
+ userdetails.setRoleName(user.getRolename());
+ userdetails.setCode(user.getCode());
+ return userdetails;
+
+ }
+
+}
diff --git a/src/main/java/com/ifish/config/SecuredConfig.java b/src/main/java/com/ifish/config/SecuredConfig.java
index 02389dc..d4614db 100644
--- a/src/main/java/com/ifish/config/SecuredConfig.java
+++ b/src/main/java/com/ifish/config/SecuredConfig.java
@@ -7,13 +7,72 @@ package com.ifish.config;
import com.ifish.helper.UserHelper;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.web.filter.CharacterEncodingFilter;
+import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
/**
*
* @author Administrator
*/
+@Configuration
+@EnableWebSecurity
public class SecuredConfig extends WebSecurityConfigurerAdapter {
+
@Autowired
private UserHelper userHelper;
+
+ @Override
+ protected void configure(HttpSecurity http) throws Exception {
+ //The CharacterEncodingFilter must be started before SecurityFilter. I moved it to security configuration:
+ CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter();
+ encodingFilter.setEncoding("UTF-8");
+ encodingFilter.setForceEncoding(true);
+ //做csrf验证
+ //http.addFilterBefore(encodingFilter, CsrfFilter.class).csrf().requireCsrfProtectionMatcher(mycsrfRequestMatcher());
+
+ //取消csrf验证
+ //http.csrf().disable();
+ //免登陆
+ //http.rememberMe().rememberMeServices(rememberMeServinces());
+ http.authorizeRequests() //对下面几个url进行授权
+ //.antMatchers("/news/*","/school/*").hasAnyRole("1","4") //UserBean的utype为1或4才能访问'/news/*','/school/*'
+ //.antMatchers("/score/*").hasRole("4") //同上,utype为4的才能访问
+ //.antMatchers("/**").authenticated() //authenticated()只有登陆验证过用户才可以访问hasRole()只有特定权限,这里是Utype用户才可以访问
+ .antMatchers("/admin/**").hasAnyRole("4")
+ .and() //相当于方法结束符,and结束的几个方法是并行的,没有顺序之分,最后一个方法不需要and结束
+ .formLogin()//配置FBA。登陆,若有role权限,formLogin不能少
+ .loginProcessingUrl("/login")//登陆后是否跳转前一个URL,参数为登陆的POST地址
+ .loginPage("/") //登陆页面
+ .defaultSuccessUrl("/", false)
+ .failureUrl("/")
+ //.failureUrl("/login?error") //登陆失败跳转页面
+ .usernameParameter("username")
+ .passwordParameter("password")
+ .and()
+ .logout() //退出
+ .logoutSuccessUrl("/login?logout")
+ .and()
+ .sessionManagement()
+ .invalidSessionUrl("/")//过期回首页 目前不确定这样对不对 需要继续观察
+ //.and()
+ // .rememberMe().key("gkweb") //记住密码,cookie的name为remember-me,key的值相当于token
+ // .tokenValiditySeconds(1209600) //cookie有效期,时间为秒
+ .and().exceptionHandling().accessDeniedPage("/403") //请求异常,请求403
+ ;
+ }
+
+ @Override
+ protected void configure(AuthenticationManagerBuilder auth) throws Exception {
+ auth.userDetailsService(new MyUserDetailService(userHelper));
+// auth.inMemoryAuthentication()
+// .withUser("1").password("1").roles("4").and()
+// .withUser("2").password("2").roles("USER", "ADMIN").and()
+// .withUser("3").password("3").roles("ADMIN");
+
+ }
}
diff --git a/src/main/java/com/ifish/config/UserInfo.java b/src/main/java/com/ifish/config/UserInfo.java
new file mode 100644
index 0000000..648899e
--- /dev/null
+++ b/src/main/java/com/ifish/config/UserInfo.java
@@ -0,0 +1,303 @@
+/*
+ * 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.config;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import org.springframework.security.core.CredentialsContainer;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.util.Assert;
+
+/**
+ *
+ * @author Administrator
+ */
+public class UserInfo implements UserDetails, CredentialsContainer {
+
+ private static final long serialVersionUID = 5997839307263494359L;
+
+ // ~ Instance fields
+ // ================================================================================================
+ private String password;//用户密码
+
+ private String email;// 用户的邮箱地址
+
+ private int id;//用户ID
+
+ private String role;//用户类型
+
+ private String roleName;
+
+ private String code;
+
+ private String username;//email或者Account等综合的
+
+ private Set authorities;
+
+ private boolean accountNonExpired;
+
+ private boolean accountNonLocked;
+
+ private boolean credentialsNonExpired;
+
+ private boolean enabled;
+
+ /**
+ * @return the password
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ * @param password the password to set
+ */
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ /**
+ * @return the email
+ */
+ public String getEmail() {
+ return email;
+ }
+
+ /**
+ * @param email the email to set
+ */
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ /**
+ * @return the id
+ */
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the role
+ */
+ public String getRole() {
+ return role;
+ }
+
+ /**
+ * @param role the role to set
+ */
+ public void setRole(String role) {
+ this.role = role;
+ }
+
+ /**
+ * @return the roleName
+ */
+ public String getRoleName() {
+ return roleName;
+ }
+
+ /**
+ * @param roleName the roleName to set
+ */
+ public void setRoleName(String roleName) {
+ this.roleName = roleName;
+ }
+
+ /**
+ * @return the code
+ */
+ public String getCode() {
+ return code;
+ }
+
+ /**
+ * @param code the code to set
+ */
+ public void setCode(String code) {
+ this.code = code;
+ }
+
+ /**
+ * @return the username
+ */
+ public String getUsername() {
+ return username;
+ }
+
+ /**
+ * @param username the username to set
+ */
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ /**
+ * @return the authorities
+ */
+ public Set getAuthorities() {
+ return authorities;
+ }
+
+ /**
+ * @param authorities the authorities to set
+ */
+ public void setAuthorities(Set authorities) {
+ this.authorities = authorities;
+ }
+
+ /**
+ * @return the accountNonExpired
+ */
+ public boolean isAccountNonExpired() {
+ return accountNonExpired;
+ }
+
+ /**
+ * @param accountNonExpired the accountNonExpired to set
+ */
+ public void setAccountNonExpired(boolean accountNonExpired) {
+ this.accountNonExpired = accountNonExpired;
+ }
+
+ /**
+ * @return the accountNonLocked
+ */
+ public boolean isAccountNonLocked() {
+ return accountNonLocked;
+ }
+
+ /**
+ * @param accountNonLocked the accountNonLocked to set
+ */
+ public void setAccountNonLocked(boolean accountNonLocked) {
+ this.accountNonLocked = accountNonLocked;
+ }
+
+ /**
+ * @return the credentialsNonExpired
+ */
+ public boolean isCredentialsNonExpired() {
+ return credentialsNonExpired;
+ }
+
+ /**
+ * @param credentialsNonExpired the credentialsNonExpired to set
+ */
+ public void setCredentialsNonExpired(boolean credentialsNonExpired) {
+ this.credentialsNonExpired = credentialsNonExpired;
+ }
+
+ /**
+ * @return the enabled
+ */
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ /**
+ * @param enabled the enabled to set
+ */
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ private static SortedSet sortAuthorities(
+ Collection extends GrantedAuthority> authorities) {
+ Assert.notNull(authorities, "Cannot pass a null GrantedAuthority collection");
+ // Ensure array iteration order is predictable (as per
+ // UserDetails.getAuthorities() contract and SEC-717)
+ SortedSet sortedAuthorities = new TreeSet(new AuthorityComparator());
+
+ for (GrantedAuthority grantedAuthority : authorities) {
+ Assert.notNull(grantedAuthority, "GrantedAuthority list cannot contain any null elements");
+ sortedAuthorities.add(grantedAuthority);
+ }
+
+ return sortedAuthorities;
+ }
+
+ @Override
+ public void eraseCredentials() {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ private static class AuthorityComparator implements
+ Comparator, Serializable {
+
+ public int compare(GrantedAuthority g1, GrantedAuthority g2) {
+ // Neither should ever be null as each entry is checked before
+ // adding it to the set.
+ // If the authority is null, it is a custom authority and should
+ // precede others.
+ if (g2.getAuthority() == null) {
+ return -1;
+ }
+
+ if (g1.getAuthority() == null) {
+ return 1;
+ }
+
+ return g1.getAuthority().compareTo(g2.getAuthority());
+ }
+ }
+
+ @Override
+ public boolean equals(Object rhs) {
+ if (rhs instanceof UserInfo) {
+ return getUsername().equals(((UserInfo) rhs).getUsername());
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return getUsername().hashCode();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(super.toString()).append(": ");
+ sb.append("Username: ").append(this.getUsername()).append("; ");
+ sb.append("Password: [PROTECTED]; ");
+ sb.append("Enabled: ").append(this.isEnabled()).append("; ");
+ sb.append("AccountNonExpired: ").append(this.isAccountNonExpired()).append("; ");
+ sb.append("credentialsNonExpired: ").append(this.isCredentialsNonExpired()).append("; ");
+ sb.append("AccountNonLocked: ").append(this.isAccountNonLocked()).append("; ");
+
+ if (!authorities.isEmpty()) {
+ sb.append("Granted Authorities: ");
+
+ boolean first = true;
+ for (GrantedAuthority auth : getAuthorities()) {
+ if (!first) {
+ sb.append(",");
+ }
+ first = false;
+
+ sb.append(auth);
+ }
+ } else {
+ sb.append("Not granted any authorities");
+ }
+ return sb.toString();
+ }
+}
diff --git a/src/main/java/com/ifish/config/WebAppInitializer.java b/src/main/java/com/ifish/config/WebAppInitializer.java
index c963f53..1951134 100644
--- a/src/main/java/com/ifish/config/WebAppInitializer.java
+++ b/src/main/java/com/ifish/config/WebAppInitializer.java
@@ -28,7 +28,7 @@ public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServlet
@Override
protected String[] getServletMappings() {
- return new String[]{"/api/*"};
+ return new String[]{"/"};
}
@Override
diff --git a/src/main/java/com/ifish/controller/Index.java b/src/main/java/com/ifish/controller/Index.java
index 63cfb4a..6408124 100644
--- a/src/main/java/com/ifish/controller/Index.java
+++ b/src/main/java/com/ifish/controller/Index.java
@@ -1,7 +1,12 @@
+package com.ifish.controller;
+import java.util.Calendar;
+import javax.servlet.http.HttpServletRequest;
+import org.apache.commons.lang3.StringUtils;
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.servlet.ModelAndView;
/*
@@ -16,8 +21,36 @@ import org.springframework.web.servlet.ModelAndView;
@Controller
public class Index {
- @RequestMapping(value = "", method = RequestMethod.GET)
- public ModelAndView Index() {
+ @RequestMapping(value = "/login", method = RequestMethod.GET)
+ public ModelAndView login(
+ @RequestParam(value = "error", required = false) String error,
+ @RequestParam(value = "logout", required = false) String logout,
+ String ReturnUrl, HttpServletRequest request) {
+
+ ModelAndView mv = new ModelAndView();
+ if (error != null) {
+ if (StringUtils.isNotBlank(error)) {
+ mv.addObject("error", error);
+ } else {
+ mv.addObject("error", "用户名密码不对!");
+ }
+
+ }
+
+ if (logout != null) {
+ mv.addObject("msg", "退出成功.");
+ if (StringUtils.isNotBlank(ReturnUrl)) {
+ mv.setViewName("redirect:/");
+ return mv;
+ }
+ }
+ mv.setViewName("index");
+ return mv;
+
+ }
+
+ @RequestMapping(value = "/test", method = RequestMethod.GET)
+ public Object test() {
ModelAndView mv = new ModelAndView();
mv.setViewName("index");
return mv;
diff --git a/src/main/java/com/ifish/helper/RedisKeyHelper.java b/src/main/java/com/ifish/helper/RedisKeyHelper.java
index 0429082..11da984 100644
--- a/src/main/java/com/ifish/helper/RedisKeyHelper.java
+++ b/src/main/java/com/ifish/helper/RedisKeyHelper.java
@@ -69,6 +69,17 @@ public class RedisKeyHelper implements RedisKeyHelperI {
return RedisKey.USER_ID_KEY + userId;
}
+ /**
+ * 根据userName获取Tbl_Security_User管理用户的redis缓存key键值
+ *
+ * @param userName
+ * @return
+ */
+ @Override
+ public String getTbl_Security_UserRedisKeyByUserName(String userName) {
+ return RedisKey.SECURITY_USER + userName;
+ }
+
/**
* 根据mac地址获取Tbl_Device的redis缓存key键值
*
diff --git a/src/main/java/com/ifish/helper/RedisKeyHelperI.java b/src/main/java/com/ifish/helper/RedisKeyHelperI.java
index 04c2967..eb738fe 100644
--- a/src/main/java/com/ifish/helper/RedisKeyHelperI.java
+++ b/src/main/java/com/ifish/helper/RedisKeyHelperI.java
@@ -49,6 +49,14 @@ public interface RedisKeyHelperI {
*/
public String getTbl_UserRedisKeyByEmail(String email);
+ /**
+ * 根据userName获取Tbl_Security_User管理用户的redis缓存key键值
+ *
+ * @param userName
+ * @return
+ */
+ public String getTbl_Security_UserRedisKeyByUserName(String userName);
+
/**
* 根据mac地址获取Tbl_Device的redis缓存key键值
*
diff --git a/src/main/java/com/ifish/helper/UserHelperI.java b/src/main/java/com/ifish/helper/UserHelperI.java
index d85cf17..4a63fca 100644
--- a/src/main/java/com/ifish/helper/UserHelperI.java
+++ b/src/main/java/com/ifish/helper/UserHelperI.java
@@ -6,18 +6,44 @@
package com.ifish.helper;
import com.ifish.bean.Tbl_Security_User;
+import com.ifish.mapper.Tbl_User_Mapper;
+import com.ifish.util.IfishUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
/**
*
* @author Administrator
*/
+@Component
public class UserHelperI implements UserHelper {
-
+
+ @Autowired
+ private RedisHelperI redisHelperI;
+ @Autowired
+ private RedisKeyHelperI redisKeyHelperI;
+ @Autowired
+ private Tbl_User_Mapper tbl_User_Mapper;
+
@Override
public Tbl_Security_User getTbl_Security_User(String usernameSring) {
-
-
+ Tbl_Security_User tbl_Security_User = null;
+ try {
+ String key = redisKeyHelperI.getTbl_Security_UserRedisKeyByUserName(usernameSring);
+ String redisString = redisHelperI.getRedis(key);
+ if (StringUtils.isNotBlank(redisString)) {
+ tbl_Security_User = (Tbl_Security_User) IfishUtil.JsonToBean(redisString, Tbl_Security_User.class);
+ } else {
+ tbl_Security_User = tbl_User_Mapper.getSecurity_UserByUserName(usernameSring);
+ if (tbl_Security_User != null && tbl_Security_User.getId() > 0) {
+ redisHelperI.setRedis(key, IfishUtil.ObjectToJson(tbl_Security_User));
+ }
+ }
+ } catch (Exception e) {
+ }
+ return tbl_Security_User;
}
-
+
}
diff --git a/src/main/java/com/ifish/mapper/Tbl_Device_Mapper.java b/src/main/java/com/ifish/mapper/Tbl_Device_Mapper.java
new file mode 100644
index 0000000..975a74e
--- /dev/null
+++ b/src/main/java/com/ifish/mapper/Tbl_Device_Mapper.java
@@ -0,0 +1,209 @@
+/*
+ * 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_Activa_Code;
+import com.ifish.bean.Tbl_Device;
+import com.ifish.bean.Tbl_Device_Statistics;
+import com.ifish.bean.Tbl_Device_User;
+import java.util.List;
+import org.apache.ibatis.annotations.Delete;
+import org.apache.ibatis.annotations.InsertProvider;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.SelectKey;
+import org.apache.ibatis.annotations.Update;
+import org.apache.ibatis.annotations.UpdateProvider;
+
+/**
+ *
+ * @author Administrator
+ */
+public interface Tbl_Device_Mapper {
+
+ /**
+ * 根据设备ID获取设备详情
+ *
+ * @param deviceid
+ * @return
+ */
+ @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);
+
+ /**
+ * 根据摄像头ID获取设备详情
+ *
+ * @param deviceid
+ * @return
+ */
+ @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);
+
+ /**
+ * 根据设备ID获取设备详情
+ *
+ * @param deviceid
+ * @return
+ */
+ @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);
+
+ /**
+ * 根据用户ID获取用户绑定设备集合
+ *
+ * @param userid
+ * @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}")
+ List getDeviceUsersByUserId(@Param("userid") Integer userid);
+
+ /**
+ * 根据设备ID和用户ID获取设备与其他用户的关系
+ *
+ * @param userid
+ * @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}")
+ List getOtherDeviceUsersByOtherUserIdAndDeviceId(@Param("userid") Integer userid, @Param("deviceid") Integer deviceId);
+
+ /**
+ * 根据设备ID和用户ID获取设备与用户的关系
+ *
+ * @param userid
+ * @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}")
+ Tbl_Device_User getDeviceUsersByUserIdAndDeviceId(@Param("userid") Integer userid, @Param("deviceid") Integer deviceId);
+
+ /**
+ * 根据设备ID查询此设备关联的所有用户
+ *
+ * @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}")
+ List getDeviceUsersByDeviceId(@Param("deviceid") Integer deviceId);
+
+ /**
+ * 修改用户和设备关系表数据
+ *
+ * @param device_User
+ * @return
+ */
+ @UpdateProvider(method = "updateTblDeviceUser", type = Tbl_Device_MapperSql.class)
+ int updateTblDeviceUser(@Param("deviceUser") Tbl_Device_User device_User);
+
+ /**
+ * 删除设备和用户的关系
+ *
+ * @param id
+ * @return
+ */
+ @Delete("DELETE from tbl_device_user where id = #{id}")
+ int deleteDeviceUserById(@Param("id") Integer id);
+
+ /**
+ * 根据设备ID查询设备统计信息
+ *
+ * @param deviceid
+ * @return
+ */
+ @Select("SELECT id,device_id,mac_address,login_count,login_time,first_activate,create_time,is_charge,sdk_version,sdk_time,create_date,is_upgrade,upgrade_version,"
+ + "upgrade_time,authorize_time,create_code,MCU_count,module_count,router_count,server_count,server_try_count,software_version,hardware_type,factory_code,brand_code FROM tbl_device_statistics WHERE device_id=#{deviceid}")
+ Tbl_Device_Statistics getDevStatisticsByDeviceId(@Param("deviceid") Integer deviceid);
+
+ /**
+ * 根据设备ID查询设备统计信息
+ *
+ * @param deviceid
+ * @return
+ */
+ @Select("SELECT id,device_id,mac_address,login_count,login_time,first_activate,create_time,is_charge,sdk_version,sdk_time,create_date,is_upgrade,upgrade_version,"
+ + "upgrade_time,authorize_time,create_code,MCU_count,module_count,router_count,server_count,server_try_count,software_version,hardware_type,factory_code,brand_code FROM tbl_device_statistics WHERE mac_address=#{mac}")
+ Tbl_Device_Statistics getDevStatisticsByMacAddress(@Param("mac") String macAddress);
+
+ /**
+ * 插入一条设备统计信息
+ *
+ * @param device_Statistics
+ * @return
+ */
+ @InsertProvider(type = Tbl_Device_MapperSql.class, method = "insertDeviceStatistics")
+ @SelectKey(statement = "select @@IDENTITY as id", keyProperty = "deviceStatistics.id", keyColumn = "id", before = false, resultType = int.class)
+ Integer insertDeviceStatistics(@Param("deviceStatistics") Tbl_Device_Statistics device_Statistics);
+
+ /**
+ * 修改设备统计信息表
+ *
+ * @param device_Statistics
+ * @return
+ */
+ @UpdateProvider(type = Tbl_Device_MapperSql.class, method = "updateDeviceStatistics")
+ Integer updateDeviceStatistics(@Param("deviceStatistics") Tbl_Device_Statistics device_Statistics);
+
+ /**
+ * 插入一条设备信息
+ *
+ * @param device
+ * @return
+ */
+ @InsertProvider(type = Tbl_Device_MapperSql.class, method = "insertDevice")
+ @SelectKey(statement = "select @@IDENTITY as device_id", keyProperty = "device.deviceId", keyColumn = "device_id", before = false, resultType = int.class)
+ Integer insertDevice(@Param("device") Tbl_Device device);
+
+ /**
+ * 插入一套设备与用户关系数据
+ *
+ * @param deviceUser
+ * @return
+ */
+ @InsertProvider(type = Tbl_Device_MapperSql.class, method = "insertDeviceUser")
+ @SelectKey(statement = "select @@IDENTITY as id", keyProperty = "deviceUser.id", keyColumn = "id", before = false, resultType = int.class)
+ Integer insertDeviceUser(@Param("deviceUser") Tbl_Device_User deviceUser);
+
+ /**
+ * 根据ID删除设备信息数据(摄像头)
+ *
+ * @param id
+ * @return
+ */
+ @Delete("DELETE from tbl_device where id = #{id}")
+ int deleteDeviceById(@Param("id") Integer id);
+
+ /**
+ * 根据激活码查询激活码对象
+ *
+ * @param activeCode
+ * @return
+ */
+ @Select("SELECT active_code,batch_code,is_used,create_time FROM tbl_activa_code WHERE active_code = #{code}")
+ Tbl_Activa_Code getActiva_CodeByCode(@Param("code") String activeCode);
+
+ /**
+ * 修改设备信息
+ *
+ * @param device
+ * @return
+ */
+ @UpdateProvider(type = Tbl_Device_MapperSql.class, method = "updateTbl_Device")
+ Integer updateTbl_Device(@Param("device") Tbl_Device device);
+
+ /**
+ * 修改摄像头激活码信息为已使用
+ *
+ * @param activa_Code
+ * @return
+ */
+ @Update("UPDATE tbl_activa_code set is_used='1' WHERE active_code = #{code}")
+ Integer updateTblActivaCodeIsUse(@Param("code") String activa_Code);
+
+}
diff --git a/src/main/java/com/ifish/mapper/Tbl_Device_MapperSql.java b/src/main/java/com/ifish/mapper/Tbl_Device_MapperSql.java
new file mode 100644
index 0000000..8e60486
--- /dev/null
+++ b/src/main/java/com/ifish/mapper/Tbl_Device_MapperSql.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.mapper;
+
+import com.ifish.bean.Tbl_Device;
+import com.ifish.bean.Tbl_Device_Statistics;
+import com.ifish.bean.Tbl_Device_User;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ *
+ * @author Administrator
+ */
+public class Tbl_Device_MapperSql {
+
+ /**
+ * 修改设备和用户的表
+ *
+ * @param device_User
+ * @return
+ */
+ public String updateTblDeviceUser(@Param("deviceUser") Tbl_Device_User device_User) {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append("UPDATE tbl_device_user SET ");
+
+ if (device_User.getUserId() != null && device_User.getUserId() > 0) {
+ sb.append("user_id = #{deviceUser.userId}, ");
+ }
+ if (device_User.getDeviceId() != null && device_User.getDeviceId() > 0) {
+ sb.append("device_id = #{deviceUser.deviceId}, ");
+ }
+ if (StringUtils.isNotBlank(device_User.getIsMaster())) {
+ sb.append("is_master = #{deviceUser.isMaster}, ");
+ }
+ if (StringUtils.isNotBlank(device_User.getShowName())) {
+ sb.append("show_name = #{deviceUser.showName}, ");
+ }
+ if (device_User.getCreateTime() != null && StringUtils.isNotBlank(device_User.getCreateTime().toString())) {
+ sb.append("create_time = #{deviceUser.createTime}, ");
+ }
+ if (StringUtils.isNotBlank(device_User.getCustomIconName())) {
+ sb.append("custom_icon_name = #{deviceUser.customIconName}, ");
+ }
+ if (StringUtils.isNotBlank(device_User.getCustomShowName())) {
+ sb.append("custom_show_name = #{deviceUser.customShowName}, ");
+ }
+ if (StringUtils.isNotBlank(device_User.getIsLook())) {
+ sb.append("is_look = #{deviceUser.isLook}, ");
+ }
+ if (StringUtils.isNotBlank(device_User.getIsLive())) {
+ sb.append("is_live = #{deviceUser.isLive}, ");
+ }
+ sb.append("update_time = now() ");
+ sb.append(" WHERE id = #{deviceUser.id}");
+ return sb.toString();
+ }
+
+ /**
+ * 插入一条设备统计信息表
+ *
+ * @param device_Statistics
+ * @return
+ */
+ public String insertDeviceStatistics(@Param("deviceStatistics") Tbl_Device_Statistics device_Statistics) {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append("INSERT tbl_device_statistics(device_id,mac_address,login_count,login_time,first_activate,create_time,is_charge,sdk_version,sdk_time,create_date,authorize_time,create_code,hardware_type,factory_code,brand_code)");
+ sb.append("values(#{deviceStatistics.deviceId},#{deviceStatistics.macAddress},#{deviceStatistics.loginCount},#{deviceStatistics.loginTime},#{deviceStatistics.firstActivate},#{deviceStatistics.createTime},");
+ sb.append("#{deviceStatistics.isCharge},#{deviceStatistics.sdkVersion},#{deviceStatistics.sdkTime},#{deviceStatistics.createDate},#{deviceStatistics.authorizeTime},#{deviceStatistics.createCode},");
+ sb.append("#{deviceStatistics.hardwareType},#{deviceStatistics.factoryCode},#{deviceStatistics.brandCode})");
+ return sb.toString();
+ }
+
+ /**
+ * 修改设备统计信息表
+ *
+ * @param device_Statistics
+ * @return
+ */
+ public String updateDeviceStatistics(@Param("deviceStatistics") Tbl_Device_Statistics device_Statistics) {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append("UPDATE tbl_device_statistics SET ");
+
+ if (device_Statistics.getDeviceId() != null && device_Statistics.getDeviceId() > 0) {
+ sb.append("device_id = #{deviceStatistics.deviceId}, ");
+ }
+ if (StringUtils.isNotBlank(device_Statistics.getMacAddress())) {
+ sb.append("mac_address = #{deviceStatistics.macAddress}, ");
+ }
+ if (device_Statistics.getLoginCount() != null && device_Statistics.getLoginCount() > 0) {
+ sb.append("login_count = #{deviceStatistics.loginCount}, ");
+ }
+ if (device_Statistics.getLoginTime() != null && StringUtils.isNotBlank(device_Statistics.getLoginTime().toString())) {
+ sb.append("login_time= #{deviceStatistics.loginTime}, ");
+ }
+ if (device_Statistics.getFirstActivate() != null && StringUtils.isNotBlank(device_Statistics.getFirstActivate().toString())) {
+ sb.append("first_activate= #{deviceStatistics.firstActivate}, ");
+ }
+ if (device_Statistics.getCreateTime() != null && StringUtils.isNotBlank(device_Statistics.getCreateTime().toString())) {
+ sb.append("create_time= #{deviceStatistics.createTime}, ");
+ }
+ if (StringUtils.isNotBlank(device_Statistics.getIsCharge())) {
+ sb.append("is_charge = #{deviceStatistics.isCharge}, ");
+ }
+ if (StringUtils.isNotBlank(device_Statistics.getSdkVersion())) {
+ sb.append("sdk_version = #{deviceStatistics.sdkVersion}, ");
+ }
+ if (device_Statistics.getSdkTime() != null && StringUtils.isNotBlank(device_Statistics.getSdkTime().toString())) {
+ sb.append("sdk_time= #{deviceStatistics.sdkTime}, ");
+ }
+ if (device_Statistics.getCreateDate() != null && StringUtils.isNotBlank(device_Statistics.getCreateDate().toString())) {
+ sb.append("create_date= #{deviceStatistics.createDate}, ");
+ }
+ if (StringUtils.isNotBlank(device_Statistics.getIsUpgrade())) {
+ sb.append("is_upgrade = #{deviceStatistics.isUpgrade}, ");
+ }
+ if (StringUtils.isNotBlank(device_Statistics.getUpgradeVersion())) {
+ sb.append("upgrade_version = #{deviceStatistics.upgradeVersion}, ");
+ }
+ if (device_Statistics.getUpgradeTime() != null && StringUtils.isNotBlank(device_Statistics.getUpgradeTime().toString())) {
+ sb.append("upgrade_time= #{deviceStatistics.upgradeTime}, ");
+ }
+ if (device_Statistics.getAuthorizeTime() != null && StringUtils.isNotBlank(device_Statistics.getAuthorizeTime().toString())) {
+ sb.append("authorize_time= #{deviceStatistics.authorizeTime}, ");
+ }
+ if (StringUtils.isNotBlank(device_Statistics.getCreateCode())) {
+ sb.append("create_code = #{deviceStatistics.createCode}, ");
+ }
+ if (device_Statistics.getMcuCount() != null && device_Statistics.getMcuCount() > 0) {
+ sb.append("mcu_count = #{deviceStatistics.mcuCount}, ");
+ }
+ if (device_Statistics.getModuleCount() != null && device_Statistics.getModuleCount() > 0) {
+ sb.append("module_count = #{deviceStatistics.moduleCount}, ");
+ }
+ if (device_Statistics.getRouterCount() != null && device_Statistics.getRouterCount() > 0) {
+ sb.append("router_count = #{deviceStatistics.routerCount}, ");
+ }
+ if (device_Statistics.getServerCount() != null && device_Statistics.getServerCount() > 0) {
+ sb.append("server_count = #{deviceStatistics.serverCount}, ");
+ }
+ if (device_Statistics.getServerTryCount() != null && device_Statistics.getServerTryCount() > 0) {
+ sb.append("server_try_count = #{deviceStatistics.serverTryCount}, ");
+ }
+ if (StringUtils.isNotBlank(device_Statistics.getSoftwareVersion())) {
+ sb.append("software_version = #{deviceStatistics.softwareVersion}, ");
+ }
+ if (StringUtils.isNotBlank(device_Statistics.getHardwareType())) {
+ sb.append("hardware_type = #{deviceStatistics.hardwareType}, ");
+ }
+ if (StringUtils.isNotBlank(device_Statistics.getFactoryCode())) {
+ sb.append("factory_code = #{deviceStatistics.factoryCode}, ");
+ }
+ if (StringUtils.isNotBlank(device_Statistics.getBrandCode())) {
+ sb.append("brand_code = #{deviceStatistics.brandCode}, ");
+ }
+ if (sb.lastIndexOf(",") == sb.length() - 2) {
+ sb.deleteCharAt(sb.length() - 2);
+ }
+ sb.append(" WHERE id = #{deviceStatistics.id}");
+ return sb.toString();
+ }
+
+ /**
+ * 插入一条设备信息
+ *
+ * @param device
+ * @return
+ */
+ public String insertDevice(@Param("device") Tbl_Device device) {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append("INSERT INTO tbl_device(server_ip,device_ip,is_camera,mac_address,login_time,is_blacklist,hardware_type,on_off,today_remind,water_remind,remind_date,remind_cycle,factory_code,brand_code,");
+ sb.append("create_time,active_code,active_time,update_time,camera_id) VALUES(#{device.serverIp},#{device.deviceIp},#{device.isCamera},#{device.macAddress},#{device.loginTime},#{device.isBlacklist},#{device.hardwareType},#{device.onOff},");
+ sb.append("#{device.todayRemind},#{device.waterRemind},#{device.remindDate},#{device.remindCycle},#{device.factoryCode},#{device.brandCode},#{device.createTime},#{device.activeCode},#{device.activeTime},#{device.updateTime},#{device.cameraId})");
+
+ return sb.toString();
+ }
+
+ /**
+ * 插入设备和用户信息
+ *
+ * @param deviceUser
+ * @return
+ */
+ public String insertDeviceUser(@Param("deviceUser") Tbl_Device_User deviceUser) {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append("INSERT INTO tbl_device_user (user_id,device_id,is_master,show_name,create_time,update_time,custom_icon_name,custom_show_name,is_look,is_live) VALUES(");
+ sb.append("#{deviceUser.userId},#{deviceUser.deviceId},#{deviceUser.isMaster},#{deviceUser.showName},#{deviceUser.createTime},#{deviceUser.updateTime},#{deviceUser.customIconName},#{deviceUser.customShowName},#{deviceUser.isLook},#{deviceUser.isLive})");
+
+ return sb.toString();
+ }
+
+ /**
+ * 修改设备信息
+ *
+ * @param device
+ * @return
+ */
+ public String updateTbl_Device(@Param("device") Tbl_Device device) {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append("UPDATE tbl_device SET ");
+ if (StringUtils.isNotBlank(device.getServerIp())) {
+ sb.append("server_ip = #{device.serverIp}, ");
+ }
+ if (StringUtils.isNotBlank(device.getDeviceIp())) {
+ sb.append("device_ip = #{device.deviceIp}, ");
+ }
+ if (StringUtils.isNotBlank(device.getIsCamera())) {
+ sb.append("is_camera = #{device.isCamera}, ");
+ }
+ if (StringUtils.isNotBlank(device.getMacAddress())) {
+ sb.append("mac_address = #{device.macAddress}, ");
+ }
+ if (device.getLoginTime() != null && StringUtils.isNotBlank(device.getLoginTime().toString())) {
+ sb.append("login_time = #{device.loginTime}, ");
+ }
+ if (device.getRemindDate() != null && StringUtils.isNotBlank(device.getRemindDate().toString())) {
+ sb.append("remind_date = #{device.loginTime}, ");
+ }
+ if (StringUtils.isNotBlank(device.getIsBlacklist())) {
+ sb.append("is_blacklist = #{device.isBlacklist}, ");
+ }
+ if (StringUtils.isNotBlank(device.getHardwareType())) {
+ sb.append("hardware_type = #{device.hardwareType}, ");
+ }
+ if (StringUtils.isNotBlank(device.getOnOff())) {
+ sb.append("on_off = #{device.onOff}, ");
+ }
+ if (StringUtils.isNotBlank(device.getTodayRemind())) {
+ sb.append("today_remind = #{device.todayRemind}, ");
+ }
+ if (StringUtils.isNotBlank(device.getWaterRemind())) {
+ sb.append("water_remind = #{device.waterRemind}, ");
+ }
+ if (device.getRemindCycle() != null && device.getRemindCycle() > 0) {
+ sb.append("remind_cycle = #{device.remindCycle}, ");
+ }
+ if (StringUtils.isNotBlank(device.getFactoryCode())) {
+ sb.append("factory_code = #{device.factoryCode}, ");
+ }
+ if (StringUtils.isNotBlank(device.getBrandCode())) {
+ sb.append("brand_code = #{device.brandCode}, ");
+ }
+ if (StringUtils.isNotBlank(device.getCameraId())) {
+ sb.append("camera_id = #{device.cameraId}, ");
+ }
+ if (device.getCreateTime() != null && StringUtils.isNotBlank(device.getCreateTime().toString())) {
+ sb.append("create_time = #{device.createTime}, ");
+ }
+ if (device.getActiveTime() != null && StringUtils.isNotBlank(device.getActiveTime().toString())) {
+ sb.append("active_time = #{device.activeTime}, ");
+ }
+
+ if (StringUtils.isNotBlank(device.getActiveCode())) {
+ sb.append("active_code = #{device.activeCode}, ");
+ }
+ sb.append("update_time = now() ");
+ sb.append(" WHERE device_id = #{device.deviceId}");
+ return sb.toString();
+ }
+}
diff --git a/src/main/java/com/ifish/mapper/Tbl_Hardware_Type_Mapper.java b/src/main/java/com/ifish/mapper/Tbl_Hardware_Type_Mapper.java
new file mode 100644
index 0000000..47f7bd2
--- /dev/null
+++ b/src/main/java/com/ifish/mapper/Tbl_Hardware_Type_Mapper.java
@@ -0,0 +1,38 @@
+/*
+ * 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_HardWare_Type;
+import com.ifish.bean.Tbl_Vender;
+import java.util.Map;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+/**
+ *
+ * @author Administrator
+ */
+public interface Tbl_Hardware_Type_Mapper {
+
+ /**
+ * 根据设备类型Code获取厂家设备类型详情
+ *
+ * @param type
+ * @return
+ */
+ @Select("select hardware_type,hardware_name,control_amount,timer_amount,is_work_model,is_custom_icon,all_icon_name,all_show_name,default_icon_name,default_show_name,"
+ + "icon_link,is_lightness,is_sark_lamp,hardware_desc,update_time,create_time from tbl_hardware_type where hardware_type=#{type}")
+ Tbl_HardWare_Type getHardwareTypeByTypeCode(@Param("type") String type);
+
+ /**
+ * 根据code获取厂家信息
+ *
+ * @param code
+ * @return
+ */
+ @Select("select brand_code,brand_name,brand_introduce,brand_logo from tbl_vender_list where brand_code=#{code}")
+ Tbl_Vender getVenderListByBrandCode(@Param("code") String code);
+}
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
new file mode 100644
index 0000000..440ff78
--- /dev/null
+++ b/src/main/java/com/ifish/mapper/Tbl_Live_Room_Mapper.java
@@ -0,0 +1,209 @@
+/*
+ * 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.LiveRoomPageInfo;
+import com.ifish.bean.Tbl_Live_Message;
+import com.ifish.bean.Tbl_Live_Room;
+import com.ifish.bean.Tbl_Live_Watch;
+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.SelectKey;
+import org.apache.ibatis.annotations.Update;
+import org.apache.ibatis.annotations.UpdateProvider;
+
+/**
+ *
+ * @author Administrator
+ */
+public interface Tbl_Live_Room_Mapper {
+
+ /**
+ * 建立一个直播间
+ */
+ @Insert("INSERT INTO tbl_live_room (user_id,camera_id,room_name,room_desc,room_status,popularity_value,create_time,room_Img) VALUES("
+ + "#{liveroom.userId},#{liveroom.cameraId},#{liveroom.roomName},#{liveroom.roomDesc},#{liveroom.roomStatus},#{liveroom.popularityValue},now(),#{liveroom.roomImg})")
+ @SelectKey(statement = "select @@IDENTITY as room_id", keyProperty = "liveroom.roomId", keyColumn = "room_id", before = false, resultType = int.class)
+ Integer insertLiveRoom(@Param("liveroom") Tbl_Live_Room liveRoom);
+
+ /**
+ * 插入一条直播间评论
+ *
+ * @param live_Message
+ * @return
+ */
+ @Insert("INSERT INTO TBL_LIVE_MESSAGE (room_id,user_id,as_user_id,message_content,create_time) VALUES (#{livemessage.roomId},#{livemessage.userId},#{livemessage.asUserId},#{livemessage.messageContent},#{livemessage.createTime})")
+ @SelectKey(statement = "select @@IDENTITY as message_id", keyProperty = "livemessage.messageId", keyColumn = "message_id", before = false, resultType = int.class)
+ Integer insertLiveMessage(@Param("livemessage") Tbl_Live_Message live_Message);
+
+ /**
+ * 查询直播间总赞数
+ *
+ * @param roomID
+ * @return
+ */
+ @Select("select count(*) from tbl_live_room_zan where room_id=#{roomid} ")
+ Integer getLiveRoomZanCountByRoomId(@Param("roomid") Integer roomID);
+
+ /**
+ * 查询某个用户是否点赞了某个直播间
+ *
+ * @param roomID
+ * @param userID
+ * @return
+ */
+ @Select("SELECT COUNT(1) FROM TBL_LIVE_ROOM_ZAN WHERE ROOM_ID = #{roomid} AND USER_ID = #{userid}")
+ Integer IsZan(@Param("roomid") Integer roomID, @Param("userid") Integer userID);
+
+ /**
+ * 取消点赞
+ *
+ * @param roomID
+ * @param userID
+ * @return
+ */
+ @Delete("DELETE FROM TBL_LIVE_ROOM_ZAN WHERE ROOM_ID = #{roomid} AND USER_ID = #{userid}")
+ Integer cancelZan(@Param("roomid") Integer roomID, @Param("userid") Integer userID);
+
+ /**
+ * 执行点赞
+ *
+ * @param roomID
+ * @param userID
+ * @return
+ */
+ @Insert("INSERT INTO TBL_LIVE_ROOM_ZAN(ROOM_ID,USER_ID,CREATE_TIME) VALUES (#{roomid},#{userid},NOW())")
+ Integer ImplementZan(@Param("roomid") Integer roomID, @Param("userid") Integer userID);
+
+ /**
+ * 根据房间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 ROOM_ID = #{roomid}")
+ Tbl_Live_Room getTbl_Live_RoomById(@Param("roomid") Integer roomid);
+
+ /**
+ * 根据开播时间来查询直播间
+ *
+ * @param pageSize
+ * @param FirstResult
+ * @return
+ */
+ @Select(" select a.roomId,a.userId,a.userType,a.nickName,a.userImg,a.loginTime,a.createTime,a.cameraId,a.roomName,a.roomDesc,a.popularityValue,a.roomImg,a.numberDays,a.zanNum,count(*) as pinglunNum from ("
+ + " SELECT l.room_id AS roomId,u.user_id AS userId,u.user_type AS userType,u.nick_name AS nickName,u.user_img AS userImg,u.login_time AS loginTime,l.create_time AS createTime,"
+ + " td.camera_id AS cameraId,l.room_name AS roomName,l.room_desc AS roomDesc,l.popularity_value AS popularityValue,l.room_Img AS roomImg,"
+ + " (TO_DAYS(NOW())-TO_DAYS(l.create_time)) AS numberDays,l.zanNum,b.message_id"
+ + " from tbl_user u"
+ + " LEFT JOIN tbl_device_user c ON u.user_id=c.user_id "
+ + " LEFT JOIN tbl_device td ON c.device_id = td.device_id"
+ + " LEFT JOIN tbl_live_room l ON u.user_id=l.user_id and l.camera_id = td.camera_id"
+ + " LEFT JOIN tbl_live_message b ON l.room_id = b.room_id"
+ + " where c.is_live='1' AND l.room_status='1' ) as a"
+ + " GROUP BY a.roomId,a.userId,a.userType,a.nickName,a.userImg,a.loginTime,a.createTime,a.cameraId,a.roomName,a.roomDesc,a.popularityValue,a.roomImg,a.numberDays,a.zanNum"
+ + " ORDER BY a.createTime DESC LIMIT ${first},${pagesize}")
+ List getLiveRoomListByCreateTime(@Param("pagesize") Integer pageSize, @Param("first") Integer FirstResult);
+
+ /**
+ * 根据开播时间来查询直播间
+ *
+ * @param pageSize
+ * @param FirstResult
+ * @return
+ */
+ @Select(" select a.roomId,a.userId,a.userType,a.nickName,a.userImg,a.loginTime,a.createTime,a.cameraId,a.roomName,a.roomDesc,a.popularityValue,a.roomImg,a.numberDays,a.zanNum,count(*) as pinglunNum from ("
+ + " SELECT l.room_id AS roomId,u.user_id AS userId,u.user_type AS userType,u.nick_name AS nickName,u.user_img AS userImg,u.login_time AS loginTime,l.create_time AS createTime,"
+ + " td.camera_id AS cameraId,l.room_name AS roomName,l.room_desc AS roomDesc,l.popularity_value AS popularityValue,l.room_Img AS roomImg,"
+ + " (TO_DAYS(NOW())-TO_DAYS(l.create_time)) AS numberDays,l.zanNum,b.message_id"
+ + " from tbl_user u"
+ + " LEFT JOIN tbl_device_user c ON u.user_id=c.user_id "
+ + " LEFT JOIN tbl_device td ON c.device_id = td.device_id"
+ + " LEFT JOIN tbl_live_room l ON u.user_id=l.user_id and l.camera_id = td.camera_id"
+ + " LEFT JOIN tbl_live_message b ON l.room_id = b.room_id"
+ + " where c.is_live='1' AND l.room_status='1' ) as a"
+ + " GROUP BY a.roomId,a.userId,a.userType,a.nickName,a.userImg,a.loginTime,a.createTime,a.cameraId,a.roomName,a.roomDesc,a.popularityValue,a.roomImg,a.numberDays,a.zanNum"
+ + " ORDER BY a.popularityValue DESC LIMIT ${first},${pagesize}")
+ List getLiveRoomListByRenqi(@Param("pagesize") Integer pageSize, @Param("first") Integer FirstResult);
+
+ /**
+ * 查询所有直播间数量
+ *
+ * @return
+ */
+ @Select("SELECT COUNT(1)"
+ + " from tbl_user u"
+ + " LEFT JOIN tbl_device_user c ON u.user_id=c.user_id "
+ + " LEFT JOIN tbl_device td ON c.device_id = td.device_id"
+ + " LEFT JOIN tbl_live_room l ON u.user_id=l.user_id and l.camera_id = td.camera_id"
+ + " where c.is_live='1' AND l.room_status='1'")
+ Integer getLiveRoomListCount();
+
+ /**
+ * 修改直播间信息
+ *
+ * @param live_Room
+ * @return
+ */
+ @UpdateProvider(type = Tbl_Live_Room_MapperSql.class, method = "updateLiveRoom")
+ Integer updateLiveRoom(@Param("live") Tbl_Live_Room live_Room);
+
+ /**
+ * 修改人气值
+ *
+ * @param live_Room
+ * @return
+ */
+ @Update("UPDATE TBL_LIVE_ROOM SET popularity_value = #{live.popularityValue} WHERE room_id = #{live.roomId}")
+ Integer updateLiveRoomPopularityValue(@Param("live") Tbl_Live_Room live_Room);
+
+ /**
+ * 根据直播间ID获取此直播间评论列表
+ *
+ * @param roomid
+ * @return
+ */
+ @Select("select l.message_id as messageId,l.room_id as roomId,l.user_id as userId,l.as_user_id as asUserId,"
+ + "uu.nick_name as asUserName,u.user_img as userImg,u.nick_name as userName,l.message_content as messageContent,l.create_time as createTime "
+ + "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} ")
+ List