ソースを参照

byh24/11/9完成登录和用户管理

byh 6 日 前
コミット
98b00e6952

+ 22 - 0
src/lsjb/bo/adVO/AdVO.java

@@ -0,0 +1,22 @@
+package lsjb.bo.adVO;
+
+public class AdVO {
+    private String adname;
+    private String adpass;
+
+    public String getAdname() {
+        return adname;
+    }
+
+    public void setAdname(String adname) {
+        this.adname = adname;
+    }
+
+    public String getAdpass() {
+        return adpass;
+    }
+
+    public void setAdpass(String adpass) {
+        this.adpass = adpass;
+    }
+}

+ 36 - 0
src/lsjb/bo/yonghuVO/YongHuVo.java

@@ -13,6 +13,10 @@ public class YongHuVo {
     private String dianhua;
     private String newusername;//update时用来存新的用户名
 
+    //用来固定时间范围   用Tiemstamp类型不知道为什么不对
+    private String fromdate;
+    private String todate;
+
     public Integer getId() {
         return id;
     }
@@ -84,4 +88,36 @@ public class YongHuVo {
     public void setNewusername(String newusername) {
         this.newusername = newusername;
     }
+
+//    public Timestamp getFromdate() {
+//        return fromdate;
+//    }
+//
+//    public void setFromdate(Timestamp fromdate) {
+//        this.fromdate = fromdate;
+//    }
+//
+//    public Timestamp getTodate() {
+//        return todate;
+//    }
+//
+//    public void setTodate(Timestamp todate) {
+//        this.todate = todate;
+//    }
+
+    public String getFromdate() {
+        return fromdate;
+    }
+
+    public void setFromdate(String fromdate) {
+        this.fromdate = fromdate;
+    }
+
+    public String getTodate() {
+        return todate;
+    }
+
+    public void setTodate(String todate) {
+        this.todate = todate;
+    }
 }

+ 20 - 0
src/lsjb/controller/adController/AdController.java

@@ -0,0 +1,20 @@
+package lsjb.controller.adController;
+
+import lsjb.bo.adVO.AdVO;
+import lsjb.service.adService.AdService;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@RestController
+@RequestMapping("ad")
+public class AdController {
+    @Resource
+    AdService adService;
+    @RequestMapping("queryAd")
+    public List queryAd(AdVO vo){
+        return adService.queryAd(vo);
+    }
+}

+ 11 - 0
src/lsjb/mapper/adMapper/AdInterface.java

@@ -0,0 +1,11 @@
+package lsjb.mapper.adMapper;
+
+import lsjb.bo.adVO.AdVO;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+@Component
+public interface AdInterface {
+    public List queryAd(AdVO vo);
+}

+ 23 - 0
src/lsjb/mapper/adMapper/ad.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="lsjb.mapper.adMapper.AdInterface">
+    <!--    记得改id名-->
+    <parameterMap id="advo" type="lsjb.bo.adVO.AdVO"></parameterMap>
+    <resultMap id="adrvo" type="lsjb.bo.adVO.AdVO"></resultMap>
+
+    <select id="queryAd" parameterMap="advo" resultMap="adrvo">
+        select adname,adpass from g2_table_administrator
+        <where>
+            <if test="adname != null and adname != '' ">
+                and adname = #{adname}
+            </if>
+            <if test="adpass != null and adpass != '' ">
+                and adpass = #{adpass}
+            </if>
+        </where>
+    </select>
+
+
+</mapper>

+ 5 - 2
src/lsjb/mapper/yonghuMapper/yonghu.xml

@@ -50,13 +50,16 @@
             <if test="username != null and username != '' ">
                 and username = #{username}
             </if>
-            <if test="dianhua != null and username != '' ">
+            <if test="dianhua != null and dianhua != '' ">
                 and dianhua = #{dianhua}
             </if>
             <if test="zhuangtai != null">
                 and zhuangtai = #{zhuangtai}
             </if>
-            <if test="chuangjiantime != null and username != '' ">
+            <if test="fromdate != null and todate != null ">
+                and chuangjiantime between #{fromdate} and #{todate}
+            </if>
+            <if test="chuangjiantime != null ">
                 and chuangjiantime = #{chuangjiantime}
             </if>
         </where>

+ 9 - 0
src/lsjb/service/adService/AdService.java

@@ -0,0 +1,9 @@
+package lsjb.service.adService;
+
+import lsjb.bo.adVO.AdVO;
+
+import java.util.List;
+
+public interface AdService {
+    public List queryAd(AdVO vo);
+}

+ 19 - 0
src/lsjb/service/adService/AdServiceImpl.java

@@ -0,0 +1,19 @@
+package lsjb.service.adService;
+
+import lsjb.bo.adVO.AdVO;
+import lsjb.mapper.adMapper.AdInterface;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Service
+public class AdServiceImpl implements AdService {
+    @Resource
+    AdInterface adInterface;
+
+    @Override
+    public List queryAd(AdVO vo) {
+        return adInterface.queryAd(vo);
+    }
+}

+ 85 - 0
src/lsjb/spring/adSpring.xml

@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xmlns:mvc="http://www.springframework.org/schema/mvc"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+       http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://www.springframework.org/schema/context
+       http://www.springframework.org/schema/context/spring-context.xsd
+       http://www.springframework.org/schema/mvc
+       http://www.springframework.org/schema/mvc/spring-mvc.xsd
+">
+
+
+    <!--json整合     需要导入 jackson-annotations-*.jar,jackson-core-.jar,jackson-databind-.jar -->
+    <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" />
+    <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
+        <property name="messageConverters">
+            <list>
+                <bean class="org.springframework.http.converter.StringHttpMessageConverter">
+                    <property name="supportedMediaTypes">
+                        <list>
+                            <value>text/html; charset=UTF-8</value>
+                            <value>application/json;charset=UTF-8</value>
+                        </list>
+                    </property>
+                </bean>
+                <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
+                    <property name="supportedMediaTypes">
+                        <list>
+                            <value>text/html; charset=UTF-8</value>
+                            <value>application/json;charset=UTF-8</value>
+                        </list>
+                    </property>
+                </bean>
+            </list>
+        </property>
+    </bean>
+
+
+
+    <!--    扫描包下所有类,为添加了@Service、@Component、@Controller、@Repository修饰的类创建对象并存入IOC容器-->
+    <!--    管理员-->
+    <context:component-scan base-package="lsjb.controller.adController"></context:component-scan>
+    <context:component-scan base-package="lsjb.service.adService"></context:component-scan>
+
+
+
+    <mvc:default-servlet-handler></mvc:default-servlet-handler>
+    <mvc:annotation-driven></mvc:annotation-driven>
+
+
+    <bean id="gydxdb" class="org.apache.commons.dbcp2.BasicDataSource">
+        <property name="driverClassName" value="com.mysql.cj.jdbc.Driver"></property>
+        <property name="url" value="jdbc:mysql://47.92.102.27:53306/gydx"></property>
+        <property name="username" value="gydx"></property>
+        <property name="password" value="gydx123456"></property>
+    </bean>
+
+    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
+        <property name="dataSource" ref="gydxdb"></property>
+        <property name="mapperLocations" value="classpath:lsjb/mapper/adMapper/ad.xml">
+
+        </property>
+
+        <!--        显示SQL-->
+        <property name="configuration">
+            <bean class="org.apache.ibatis.session.Configuration">
+                <property name="logImpl" value="org.apache.ibatis.logging.stdout.StdOutImpl" />
+            </bean>
+        </property>
+    </bean>
+
+    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
+        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
+        <property name="basePackage" value="lsjb.mapper.adMapper"></property>
+    </bean>
+
+    <bean id="transactionManger" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
+        <property name="dataSource" ref="gydxdb"></property>
+    </bean>
+
+
+
+</beans>

+ 18 - 1
web/WEB-INF/web.xml

@@ -41,6 +41,7 @@
         <url-pattern>*.yonghu</url-pattern>
     </servlet-mapping>
 
+<!--竞价信息-->
     <servlet>
         <servlet-name>jingjiaxinximvc</servlet-name>
         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
@@ -52,12 +53,28 @@
 
         <load-on-startup>1</load-on-startup>
     </servlet>
-
     <servlet-mapping>
         <servlet-name>jingjiaxinximvc</servlet-name>
         <url-pattern>*.jingjiaxinxi</url-pattern>
     </servlet-mapping>
 
+<!--管理员-->
+    <servlet>
+        <servlet-name>admvc</servlet-name>
+        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
+
+        <init-param>
+            <param-name>contextConfigLocation</param-name>
+            <param-value>classpath:lsjb/spring/adSpring.xml</param-value>
+        </init-param>
+
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>admvc</servlet-name>
+        <url-pattern>*.ad</url-pattern>
+    </servlet-mapping>