Skip to content

Commit

Permalink
Signed-off-by: qx <[email protected]>
Browse files Browse the repository at this point in the history
  • Loading branch information
qx committed Apr 19, 2011
1 parent af060e4 commit a089322
Show file tree
Hide file tree
Showing 17 changed files with 308 additions and 83 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 4 additions & 4 deletions WebRoot/WEB-INF/classes/struts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -720,10 +720,10 @@
<result name="addfinish">/WEB-INF/page/equip_success.jsp</result>
</action>
</package>
<package name="skills" namespace="/server_controller" extends="struts-default">
<action name="skills_*" class="skillsServer" method="{1}">
<result name="addpage">/WEB-INF/page/skills.jsp</result>
<result name="addfinish">/WEB-INF/page/skills_success.jsp</result>
<package name="mission" namespace="/server_controller" extends="struts-default">
<action name="mission_*" class="missionServer" method="{1}">
<result name="addpage">/WEB-INF/page/mission.jsp</result>
<result name="addfinish">/WEB-INF/page/mission_success.jsp</result>
</action>
</package>

Expand Down
18 changes: 18 additions & 0 deletions WebRoot/WEB-INF/page/mission.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>技能添加界面</title>
</head>
<body>
<form action="/server_controller/mission_addfinish" method="post" >
<input type="text" name="mission_id">:mission_id(任务名)</input></br>
<input type="text" name="mission_level">:mission_level(任务等级)</input></br>
<input type="text" name="mission_exp">:mission_exp(经验值)</input></br>
<!-- <input type="text" name="mission_visible">:mission_visible(0,禁用,1启用.默认启用)</input></br> -->
<input type="submit" name="提交"/>
</form>
</body>
</html>
File renamed without changes.
19 changes: 0 additions & 19 deletions WebRoot/WEB-INF/page/skills.jsp

This file was deleted.

1 change: 1 addition & 0 deletions src/com/fullwish/action/service/EquipServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public String addfinish() throws IOException {
tools.setTools_level(toolsLevel);// 设置装备等级
tools.setTools_pic(toolsPic);// 设置装备(路径)
tools.setTools_spe(toolsSpe);// 设置装备是否特殊
tools.setTools_visible(true);// 设置装备是否启用
toolsService.save(tools);
// System.out.println(tools_path);
System.out.println(tools_attack);
Expand Down
82 changes: 82 additions & 0 deletions src/com/fullwish/action/service/MissionServer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**
*
*/
package com.fullwish.action.service;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;

import com.fullwish.bean.entity.Mission;
import com.fullwish.service.mission.MissionService;
import com.opensymphony.xwork2.ActionSupport;

/**
* @author fullwish
*
*/
@Controller
public class MissionServer extends ActionSupport {
/**
*
*/
private static final long serialVersionUID = -6310224311290570208L;

private String mission_id;

private String mission_level;

private String mission_exp;

@Resource(name = "missionServiceImpl")
MissionService missionService;

// ·ÃÎÊ·¾¶ 192.168.2.3:8080/server_controller/skills_add
public String add() {
System.out.println("MissionServer add method start");
System.out.println(mission_level);
System.out.println(mission_exp);
System.out.println("MissionServer add method over");
return "addpage";
}

// ·ÃÎÊ·¾¶ 192.168.2.3:8080/server_controller/skills_addfinish
public String addfinish() {
System.out.println("MissionServer addfinish method start");
// ´´½¨mission
Mission mission = new Mission();
String missionId = mission_id;
int missionExp = Integer.parseInt(mission_exp);
int missionLevel = Integer.parseInt(mission_level);
Boolean mission_visible = true;

mission.setMission_exp(missionExp);
mission.setMission_id(missionId);
mission.setMission_level(missionLevel);
mission.setMission_visible(mission_visible);

missionService.save(mission);

System.out.println(mission_id);
System.out.println(mission_level);
System.out.println(mission_exp);
System.out.println("MissionServer addfinish method over");
return "addfinish";
}

public void setMission_exp(String mission_exp) {
this.mission_exp = mission_exp;
}

public void setMission_level(String mission_level) {
this.mission_level = mission_level;
}

public String getMission_id() {
return mission_id;
}

public void setMission_id(String mission_id) {
this.mission_id = mission_id;
}
}
56 changes: 0 additions & 56 deletions src/com/fullwish/action/service/SkillsServer.java

This file was deleted.

47 changes: 47 additions & 0 deletions src/com/fullwish/service/mission/MissionService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.fullwish.service.mission;

import java.io.Serializable;

import com.fullwish.bean.entity.Mission;
import com.fullwish.service.base.DAO;

public interface MissionService extends DAO<Mission> {

/**
* 启用指定装备
*
* @param mission_id
*/
public void enable(Serializable... mission_id);

/**
* 判断装备是否存在
*
* @param mission_id
* @return
*/
public boolean exsit(String mission_id);

/**
* 判断用户名及密码是否正确
*
* @param user_email
* @param user_password
* @return
*/
// public boolean checkUser(String user_email, String user_password);
/**
* 用户信息(user_country,user_career,user_nickname)
*
* @param user_email
* 用户名
* @param user_country
* 用户国家
* @param user_career
* 用户职业
* @param user_nickname
* 用户昵称
*/
// public void updateEquipInfo(String user_email, String user_country,
// String user_career, String user_nickname);
}
105 changes: 105 additions & 0 deletions src/com/fullwish/serviceImpl/mission/MissionServiceImpl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package com.fullwish.serviceImpl.mission;

import java.io.Serializable;

import javax.persistence.Query;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.fullwish.bean.entity.Mission;
import com.fullwish.service.base.DaoSupport;
import com.fullwish.service.mission.MissionService;

@Service
@Transactional
public class MissionServiceImpl extends DaoSupport<Mission> implements
MissionService {
// public void updatePassword(String tools_id, String newpassword){
// em.createQuery("update tools o set o.password=?1 where o.tools_id=?2")
// .setParameter(1, MD5.MD5Encode(newpassword)).setParameter(2,
// tools_id).executeUpdate();
// }

@Override
public void save(Mission entity) {
// entity.setMission_password(MD5.MD5Encode(entity.getMission_password()));
super.save(entity);
}

@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
public boolean exsit(String mission_id) {
long count = (Long) em.createQuery(
"select count(o) from Mission o where o.Mission_id=?1")
.setParameter(1, mission_id).getSingleResult();
return count > 0;
}

/*
* public boolean checkMission(String user_email, String user_password) {
* long count = (Long) em .createQuery( "select count(o) from Mission o
* where o.user_email=?1 and o.user_password=?2") // user±íÒª´óд
* .setParameter(1, user_email).setParameter(2,
* MD5.MD5Encode(user_password)).getSingleResult(); //
* System.out.println("check over"); return count > 0; }
*/

/*
* public boolean checkMission(String username, String password){ long count =
* (Long)em.createQuery("select count(o) from Buyer o where o.username=?1
* and o.password=?2") .setParameter(1, username).setParameter(2,
* MD5.MD5Encode(password)).getSingleResult(); return count>0; }
*/

@Override
public void delete(Serializable... entityIds) {
visible(false, entityIds);
}

@Override
public long getCount() {
return (Long) em.createQuery(
"select count(o) from Mission o where o.mission_visible=?1")
.setParameter(1, true).getSingleResult();
}

private void visible(boolean visible, Serializable... tools_ids) {
if (tools_ids != null && tools_ids.length > 0) {
StringBuffer jpql = new StringBuffer();
for (int i = 0; i < tools_ids.length; i++) {
jpql.append('?').append(i + 2).append(',');
}
jpql.deleteCharAt(jpql.length() - 1);
Query query = em
.createQuery("update Mission b set b.mission_visible=?1 where b.mission_id in("
+ jpql.toString() + ")");
query.setParameter(1, visible);
for (int i = 0; i < tools_ids.length; i++) {
query.setParameter(i + 2, tools_ids[i]);
}
query.executeUpdate();
}
}

public void enable(Serializable... mission_ids) {
visible(true, mission_ids);
}

/*
* (non-Javadoc)
*
* @see com.fullwish.service.tools.MissionService#updateMissionInfo(java.lang.String,
* java.lang.String, java.lang.String, java.lang.String)
*/
/*
* public void updateMissionInfo(String user_email, String user_country,
* String user_career, String user_nickname) { // update tools o set
* o.user_action=2,o.user_attack=3 // where o.user_email="[email protected]";
* em .createQuery( "update Mission o set o.user_country=?1,
* o.user_career=?2, o.user_nickname=?3 where o.user_email=?4")
* .setParameter(1, user_country).setParameter(2, user_career)
* .setParameter(3, user_nickname).setParameter(4, user_email)
* .executeUpdate(); }
*/
}
Loading

0 comments on commit a089322

Please sign in to comment.