1、要写一个下面图片的后台的实现。
(1)ApplyTeamController.java
package com.enjoy.golf.controller; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestHeader; 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.servlet.ModelAndView; import com.enjoy.golf.po.golf.response.BaseResponse; import com.enjoy.golf.service.ApplyTeamService; import com.enjoy.golf.service.UploadService; @Controller @RequestMapping("applyteam") public class ApplyTeamController { @Resource UploadService uploadService; @Resource ApplyTeamService applyteamService; @RequestMapping(value="/insertApplyTeam", method=RequestMethod.POST) public @ResponseBody BaseResponse insertApplyTeam( @RequestParam(defaultValue="")String name, @RequestParam(defaultValue="0") long phone, @RequestParam(defaultValue="") String birthday, @RequestParam(defaultValue="0") int hcp, @RequestParam(defaultValue="") String dress_size, @RequestParam(defaultValue="") String gloves_size, @RequestParam(defaultValue="") String shoe_size, @RequestParam(defaultValue="0") int ball_age, @RequestParam(defaultValue="") String industry, @RequestParam(defaultValue="") String openfire ){ BaseResponse resp =new BaseResponse(); String slogan_title="123"; applyteamService.insertApplyTeam(name,phone,birthday,hcp,dress_size,gloves_size,shoe_size,ball_age,industry); int num=applyteamService.selApplyTeam(openfire).size(); /* //成功加入球队 if(num==1){ resp.setCode("1"); resp.setMsg("创建成功"); //没有球队 }else if(num==0){ resp.setCode("0"); resp.setMsg("创建失败"); //有多个球队 }else{ resp.setCode("2"); resp.setMsg("创建成功"); } return resp; }*/ @RequestMapping(value="updateApplyTeam", method=RequestMethod.GET) public ModelAndView updateApplyTeam(HttpServletRequest request, @RequestHeader("User-Agent")String ua, String code, String state, String openfire, ModelAndView mav){ mav=new ModelAndView("team/team_management/updateApplyTeam"); mav.addObject("openfire", request.getParameter("openfire")); return mav; } }
(2)ApplyTeamDao.java
package com.enjoy.golf.dao; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.springframework.stereotype.Repository; /** * @title: ApplyTeam * @category: TODO ApplyTeamDao * @author:YTY */ @Repository public class ApplyTeamDao extends BaseDao { public void insertApplyTeam(String name, long phone, String birthday, int hcp, String dress_size, String gloves_size, String shoe_size, int ball_age, String industry) { Map<String, Object> map = new HashMap<String, Object>(); map.put("name", name); map.put("phone", phone); map.put("birthday", birthday); map.put("hcp", hcp); map.put("dress_size", dress_size); map.put("gloves_size", gloves_size); map.put("shoe_size", shoe_size); map.put("ball_age", ball_age); map.put("industry", industry); this.getSqlMapClientTemplate().insert("insertApplyTeam", map); } @SuppressWarnings("unchecked") public List<Map<String, Object>> selApplyTeam(String openfire) { return (List<Map<String,Object>>)this.getSqlMapClientTemplate().queryForList("selApplyTeam", openfire); } }
(3)ApplyTeam.java
package com.enjoy.golf.po.golf.response.mine; public class ApplyTeam { private int id; private String name; private long phone; private String birthday; private int hcp; private String dress_size; private String gloves_size; private String shoe_size; private int ball_age; private String industry; private int club_team_id; private int state; public ApplyTeam(){} public ApplyTeam(String name, long phone, String birthday, int hcp, String dress_size, String gloves_size, String shoe_size, int ball_age, String industry) { this.name = name; this.phone = phone; this.birthday = birthday; this.hcp = hcp; this.dress_size = dress_size; this.gloves_size = gloves_size; this.shoe_size = shoe_size; this.ball_age = ball_age; this.industry = industry; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public long getPhone() { return phone; } public void setPhone(long phone) { this.phone = phone; } public String getBirthday() { return birthday; } public void setBirthday(String birthday) { this.birthday = birthday; } public int getHcp() { return hcp; } public void setHcp(int hcp) { this.hcp = hcp; } public String getDress_size() { return dress_size; } public void setDress_size(String dress_size) { this.dress_size = dress_size; } public String getGloves_size() { return gloves_size; } public void setGloves_size(String gloves_size) { this.gloves_size = gloves_size; } public String getShoe_size() { return shoe_size; } public void setShoe_size(String shoe_size) { this.shoe_size = shoe_size; } public int getBall_age() { return ball_age; } public void setBall_age(int ball_age) { this.ball_age = ball_age; } public String getIndustry() { return industry; } public void setIndustry(String industry) { this.industry = industry; } public int getClub_team_id() { return club_team_id; } public void setClub_team_id(int club_team_id) { this.club_team_id = club_team_id; } public int getState() { return state; } public void setState(int state) { this.state = state; } @Override public String toString() { return "ApplyTeam [id="+id+",name=" + name + ", phone=" + phone + ", birthday=" + birthday + ", hcp=" + hcp + ", dress_size=" + dress_size + ", gloves_size=" + gloves_size + ", shoe_size=" + shoe_size + ", ball_age=" + ball_age + ", industry=" + industry + ", club_team_id=" + club_team_id + ", state=" + state + "]"; } }
(4)ApplyTeamService.java
package com.enjoy.golf.service; import java.util.List; import java.util.Map; import javax.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.enjoy.golf.dao.ApplyTeamDao; /** * @title: ApplyTeamService * @category: TODO 申请加入球队_Service * @author: YTY */ @Service public class ApplyTeamService { @Resource ApplyTeamDao applyteamDao; @Transactional(readOnly=false) //申请加入球队 public void insertApplyTeam(String name, long phone, String birthday, int hcp, String dress_size, String gloves_size, String shoe_size, int ball_age, String industry){ applyteamDao.insertApplyTeam(name, phone, birthday, hcp, dress_size,gloves_size,shoe_size,ball_age,industry); } //查询已经加入的球队 public List<Map<String,Object>> selApplyTeam(String openfire){ return applyteamDao.selApplyTeam(openfire); } }
(5)jdbc.properties
jdbc.driver.class=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://121.199.3.30:3306/golf?useUnicode=true&characterEncoding=utf8&autoReconnect=true&rewriteBatchedStatements=TRUE jdbc.username=root jdbc.password=1234567890
(6)sqlmapconfig.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-config-2.dtd"> <sqlMapConfig> <settings maxSessions="1024" maxRequests="2048" maxTransactions="512" cacheModelsEnabled="true" enhancementEnabled="true" lazyLoadingEnabled="false" errorTracingEnabled="true" useStatementNamespaces="false" /> <sqlMap resource="mysql/user/ibatis_ablum.xml" /> <sqlMap resource="mysql/user/ibatis_address.xml" /> <sqlMap resource="mysql/user/ibatis_roster.xml" /> <sqlMap resource="mysql/user/ibatis_user_info.xml" /> <sqlMap resource="mysql/match/ibatis_match_info.xml"/> <sqlMap resource="mysql/match/ibatis_match_live.xml"/> <sqlMap resource="mysql/match/ibatis_match_field.xml"/> <sqlMap resource="mysql/match/ibatis_match_player.xml"/> <sqlMap resource="mysql/match/ibatis_match_result.xml"/> <sqlMap resource="mysql/match/ibatis_match_apply.xml"/> <sqlMap resource="mysql/procity/ibatis_pro_city.xml" /> <sqlMap resource="mysql/wechat/ibatis_wechat.xml" /> <sqlMap resource="mysql/wechat/ibatis_wechat_scan.xml" /> <sqlMap resource="mysql/wechat/ibatis_wechat_suite.xml" /> <sqlMap resource="mysql/wechat/ibatis_wechat_corp.xml" /> <sqlMap resource="mysql/wechat/ibatis_wechat_suite_corp.xml" /> <sqlMap resource="mysql/wechat/ibatis_wechat_corp_agent.xml" /> <sqlMap resource="mysql/wechat/ibatis_wechat_corp_chat.xml" /> <sqlMap resource="mysql/carrie/ibatis_carrie_info.xml" /> <sqlMap resource="mysql/drawing/ibatis_drawing_info.xml" /> <sqlMap resource="mysql/point/ibatis_point_money_info.xml" /> <sqlMap resource="mysql/course/ibatis_course_info.xml" /> <sqlMap resource="mysql/course/manager/ibatis_manager_info.xml" /> <sqlMap resource="mysql/course/ibatis_course_hole.xml" /> <sqlMap resource="mysql/course/ibatis_course_name.xml" /> <sqlMap resource="mysql/course/t_tee_hole.xml" /> <sqlMap resource="mysql/group/ibatis_ofgroup.xml" /> <sqlMap resource="mysql/group/ibatis_ofproperty.xml" /> <sqlMap resource="mysql/group/ibatis_ofGroupUser.xml" /> <!-- GXZ --> <sqlMap resource="mysql/exchangemarket/ibatis_exchange_market.xml" /> <sqlMap resource="mysql/account/ibatis_account_info.xml" /> <sqlMap resource="mysql/chat/ibatis_dialog.xml" /> <sqlMap resource="mysql/chat/ibatis_history_chat.xml" /> <!-- Manager --> <sqlMap resource="mysql/manager/ibatis_manager_info.xml" /> <!-- YZ --> <sqlMap resource="mysql/course/ibatis_course_integral_rule.xml" /> <sqlMap resource="mysql/exchangemarket/ibatis_exchange_tee_time.xml" /> <!-- 订场管理 --> <sqlMap resource="mysql/realnameauthentication/ibatis_realnameauthentication.xml" /> <!-- 梯台价格管理 --> <sqlMap resource="mysql/course/ibatis_terraces.xml" /> <!-- 企业号请假相关 --> <sqlMap resource="mysql/company/ibatis_holiday.xml" /> <!-- 企业号关联微信属性 --> <sqlMap resource="mysql/company/ibatis_company_attr.xml" /> <!-- 企业号通讯录相关--> <sqlMap resource="mysql/company/ibatis_company_department.xml" /> <!-- 企业号人员信息相关--> <sqlMap resource="mysql/company/ibatis_company_user.xml" /> <!-- 企业号部门和人员信息关联相关--> <sqlMap resource="mysql/company/ibatis_department_user.xml" /> <!-- 企业号排班 --> <sqlMap resource="mysql/scheduling/ibatis_scheduling.xml" /> <!-- 公众号设置菜单 --> <sqlMap resource="mysql/menu/manager/ibatis_menu_manager.xml" /> <!-- 活动相关 --> <sqlMap resource="mysql/activity/ibatis_activity.xml" /> <sqlMap resource="mysql/activity/ibatis_imgUrl.xml" /> <!-- 长短地址 --> <sqlMap resource="mysql/shorturl/ibatis_short_url.xml"/> <!-- 微信支付 --> <sqlMap resource="mysql/wechat/ibatis_wechat_order.xml"/> <!--企业号球场与套件对应信息表--> <sqlMap resource="mysql/wechat/ibatis_wechat_suite_info.xml"/> <!--球场对应微信企业号应用信息表--> <sqlMap resource="mysql/wechat/ibatis_wechat_application.xml"/> <!-- 联赛 --> <sqlMap resource="mysql/league/ibatis_league.xml"/> <sqlMap resource="mysql/league/ibatis_league_live_hole.xml"/> <sqlMap resource="mysql/league/ibatis_league_match_info.xml"/> <sqlMap resource="mysql/league/ibatis_league_match_player.xml"/> <sqlMap resource="mysql/league/ibatis_league_stroke_rank.xml"/> <sqlMap resource="mysql/league/ibatis_league_field.xml"/> <sqlMap resource="mysql/league/ibatis_league_round.xml"/> <sqlMap resource="mysql/league/ibatis_leagueActivity_manager.xml"/> <sqlMap resource="mysql/league/ibatis_league_user_organization.xml"/> <!--团体联赛对阵--> <sqlMap resource="mysql/league/ibatis_league_against.xml"/> <sqlMap resource="mysql/league/ibatis_league_caddie.xml"/> <sqlMap resource="mysql/carrie/ibatis_carrie_player.xml"/> <sqlMap resource="mysql/course/ibatis_course_user_identity.xml"/> <sqlMap resource="mysql/course/ibatis_tee_time.xml"/> <!--联赛中球队和创建人关联信息表--> <sqlMap resource="mysql/team/ibatis_team_info.xml"/> <!--球队和联赛的关联表--> <sqlMap resource="mysql/team/ibatis_league_team.xml"/> <sqlMap resource="mysql/league/ibatis_league_user.xml"/> <!--问题相关--> <sqlMap resource="mysql/question/ibatis_question_answer.xml"/> <sqlMap resource="mysql/question/ibatis_question_sponsor.xml"/> <sqlMap resource="mysql/question/ibatis_question.xml"/> <sqlMap resource="mysql/league/ibatis_league_stroke_rank_ignore.xml"/> <sqlMap resource="mysql/notification/ibatis_notify_group.xml" /> <!--app相关--> <sqlMap resource="mysql/app/ibatis_app_log.xml" /> <sqlMap resource="mysql/app/ibatis_app_tickling.xml" /> <sqlMap resource="mysql/app/ibatis_app_setting.xml" /> <sqlMap resource="mysql/app/ibatis_app_radar.xml" /> <sqlMap resource="mysql/app/ibatis_app_notice.xml" /> <sqlMap resource="mysql/app/ibatis_app_view.xml" /> <!-- 队伍管理 --> <sqlMap resource="mysql/team/ibatis_team.xml" /> <sqlMap resource="mysql/team/ibatis_applyteam.xml" /> </sqlMapConfig>
(7)ibatis_applyteam.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd"> <sqlMap> <cacheModel id="teamInofCache" type="memory" readOnly="true" serialize="false"> <flushInterval hours="24" /> <!-- <flushOnExecute statement=""/> --> </cacheModel> <insert id="insertApplyTeam" parameterClass="java.util.HashMap"> <![CDATA[ INSERT INTO t_club_team_user_info (name,phone,birthday,hcp,dress_size,gloves_size,shoe_size,ball_age,industry) VALUES (#name#,#phone#,#birthday#,#hcp#,#dress_size#,#gloves_size#,#shoe_size#,#ball_age#,#industry#) ]]> </insert> <select id="selApplyTeam" resultClass="java.util.HashMap"> <![CDATA[ SELECT * FROM t_club_team_user_info WHERE openfire=#openfire# AND state!=9 ]]> </select> </sqlMap>
(8)root-context.xml
<?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:aop="http://www.springframework.org/schema/aop" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd" default-autowire="byName"> <context:property-placeholder location="classpath:mysql/jdbc.properties" /> <aop:aspectj-autoproxy proxy-target-class="true" /> <context:component-scan base-package="com.enjoy.golf" /> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="${jdbc.driver.class}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> </bean> <!-- 支持注释的事务声明 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" /> <tx:annotation-driven transaction-manager="transactionManager" /> <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean" p:dataSource-ref="dataSource" p:configLocation="classpath:mysql/sql-map-config.xml" /> <!-- *********************配置定时任务 开始********************* --> <!-- 线程执行器配置,用于任务注册 --> <bean id="executor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor"> <property name="corePoolSize" value="10" /> <property name="maxPoolSize" value="100" /> <property name="queueCapacity" value="500" /> </bean> <!--定义调用那个类--> <bean id="quartzJob1" class="com.enjoy.golf.service.ActivityService"></bean> <!--调度业务 : 定义调用对象和调用对象的方法 --> <bean id="jobtask1" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <!-- 调用的类 --> <property name="targetObject" ref="quartzJob1" /> <!-- 调用类中的方法 --> <property name="targetMethod" value="sendActivityStartRemindQuartz" /> </bean> <!-- 定义触发时间 --> <bean id="doTime1" class="org.springframework.scheduling.quartz.CronTriggerBean"> <property name="jobDetail" ref="jobtask1" /> <!-- 每隔2秒执行一次 --> <property name="cronExpression" value="0 0 20 * * ?" /> </bean> <!--设置调度 总管理类 如果将lazy-init='false'那么容器启动就会执行调度程序 --> <bean id="startQuertz" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <list> <ref bean="doTime1" /> <!-- 如果有多个quartz那么可以在这里引用 <ref bean="doTime2" /> --> </list> </property> <property name="taskExecutor" ref="executor" /> </bean> <!-- *********************配置定时任务 结束********************* --> </beans>
(9)log4j.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> <!-- Appenders --> <!-- org.apache.log4j.ConsoleAppender 控制台 --> <appender name="console" class="org.apache.log4j.ConsoleAppender"> <param name="Target" value="System.out" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%-5p: %c - %m%n" /> </layout> </appender> <!-- /enjoy/logs/ --> <!-- /Users/liuzy/Downloads/log/ --> <!-- org.apache.log4j.DailyRollingFileAppender 每天产生一个日志文件 --> <appender name="dalyRollingFile" class="org.apache.log4j.DailyRollingFileAppender"> <param name="Threshold" value="info"></param><!-- 指定日志信息的最低输出级别,默认为DEBUG。 --> <param name="ImmediateFlush" value="true"></param><!-- ImmediateFlush=true:表示所有消息都会被立即输出,设为false则不输出,默认值是true。 --> <param name="File" value="/enjoy/logs/golfsergerDev" /> <!-- /enjoy/logs/golfserger 设置日志输出文件名 --> <param name="Append" value="true" /><!-- true表示消息增加到指定文件中,false则将消息覆盖指定的文件内容,默认值是true。 --> <param name="DatePattern" value="'_'yyyy-MM-dd'.log'" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="[%d{MMdd HH:mm:ss SSS\} %-5p] [%t] %c{3\} - %m%n" /> </layout> </appender> <!-- Application Loggers --> <logger name="com.enjoy.golf"> <level value="warn" /> </logger> <!-- 3rdparty Loggers --> <logger name="org.springframework.core"> <level value="wran" /> </logger> <logger name="org.springframework.beans"> <level value="warn" /> </logger> <logger name="org.springframework.context"> <level value="warn" /> </logger> <logger name="org.springframework.web"> <level value="warn" /> </logger> <!-- <category name="java.sql"> <priority value="debuy" /> </category> --> <!-- Root Logger --> <root> <priority value="warn" /> <appender-ref ref="console" /> <appender-ref ref="dalyRollingFile" /> </root> </log4j:configuration>