| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.reflect.TypeToken;
|
| | | import com.yeshi.fanli.entity.bus.activity.ActivityUser;
|
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivity;
|
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivityInviteInfo;
|
| | |
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("admin/new/api/v1/activity")
|
| | |
| | | recommendActivity.setInviteInfo(info);
|
| | | }
|
| | |
|
| | | if (recommendActivity !=null) {
|
| | | ActivityUser activityUser = recommendActivity.getActivityUser();
|
| | | if (activityUser != null) {
|
| | | ActivityUser resultUser = activityService.selectActivityUserByPrimaryKey(activityUser.getId());
|
| | | if (resultUser != null) {
|
| | | recommendActivity.setActivityUser(resultUser);
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | if (StringUtil.isNullOrEmpty(callback)) {
|
| | | out.print(JsonUtil.loadTrueResult(recommendActivity));
|
| | | } else {
|
| | |
| | | activityService.deleteRecommendActivity(rsids);
|
| | | out.print(JsonUtil.loadTrueResult("删除成功"));
|
| | | }
|
| | | // deleteRecommendActivity
|
| | | |
| | | |
| | | /**
|
| | | * |
| | | * @param pageIndex
|
| | | * 页数
|
| | | * @param key
|
| | | * 查询条件
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "query")
|
| | | public void query(String callback, Integer pageIndex, Integer pageSize, String key, PrintWriter out) {
|
| | | |
| | | if (pageIndex == null || pageIndex < 1) {
|
| | | pageIndex = 1;
|
| | | }
|
| | |
|
| | | if (pageSize == null || pageSize < 1) {
|
| | | pageSize = Constant.PAGE_SIZE;
|
| | | }
|
| | | |
| | | try {
|
| | | |
| | | List<RecommendActivity> list = null;
|
| | | if (StringUtil.isNullOrEmpty(key)) {
|
| | | list = activityService.getRecommendActivityList(pageIndex, Constant.PAGE_SIZE);
|
| | | } else {
|
| | | list = activityService.queryRecommendActivityList(key, pageIndex, Constant.PAGE_SIZE);
|
| | | }
|
| | | |
| | | if (list == null || list.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
|
| | | return;
|
| | | }
|
| | | |
| | | int count = (int) activityService.getRecommendActivityCount();
|
| | |
|
| | | int totalPage = count % Constant.PAGE_SIZE == 0 ? count / Constant.PAGE_SIZE : count / Constant.PAGE_SIZE + 1;
|
| | | PageEntity pe = new PageEntity(pageIndex, Constant.PAGE_SIZE, count, totalPage);
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", pe);
|
| | | data.put("result_list", list);
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | |
| | | @RequestMapping(value = "saveModify")
|
| | | public void saveModify(String callback, RecommendActivity recommendActivity, PrintWriter out) {
|
| | | try {
|
| | |
|
| | | Long id = recommendActivity.getId();
|
| | | if (id == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("ID不能为空"));
|
| | | return;
|
| | | }
|
| | | |
| | | RecommendActivity resultObj = activityService.selectByPrimaryKey(id);
|
| | | if (resultObj == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作数据已不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | activityService.updateByPrimaryKeySelective(recommendActivity);
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("修改成功"));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | |
|
| | | |
| | | @RequestMapping(value = "delete")
|
| | | public void delete(String callback, String idArray, PrintWriter out) {
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(idArray)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择操作的数据"));
|
| | | return;
|
| | | }
|
| | | |
| | | try {
|
| | | Gson gson = new Gson();
|
| | | long[] hsids = gson.fromJson(idArray, new TypeToken<long[]>() {}.getType());
|
| | | |
| | | if (hsids == null || hsids.length == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检测到删除的数据"));
|
| | | return;
|
| | | }
|
| | | |
| | | activityService.deleteRecommendActivity(hsids);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("删除成功"));
|
| | | |
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("删除失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | }
|