|
|
@@ -0,0 +1,262 @@
|
|
|
+package com.ssj.sys.controller;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.ui.Model;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import com.ssj.bean.common.framework.core.domain.Response;
|
|
|
+import com.ssj.bean.sys.imlibuser.TbClassTeacherTemp;
|
|
|
+import com.ssj.bean.sys.poster.domain.PosterActivity;
|
|
|
+import com.ssj.bean.sys.poster.domain.PosterJoin;
|
|
|
+import com.ssj.bean.sys.poster.domain.PosterTemplate;
|
|
|
+import com.ssj.framework.basic.common.bean.SplitPage;
|
|
|
+import com.ssj.framework.core.common.controller.BaseController;
|
|
|
+import com.ssj.service.sys.poster.service.PosterActivityService;
|
|
|
+import com.ssj.service.sys.poster.service.PosterJoinService;
|
|
|
+import com.ssj.service.sys.poster.service.PosterTemplateService;
|
|
|
+
|
|
|
+@Controller
|
|
|
+@RequestMapping("/sys/poster")
|
|
|
+public class PosterController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PosterActivityService posterActivityService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PosterJoinService posterJoinService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PosterTemplateService posterTemplateService;
|
|
|
+
|
|
|
+
|
|
|
+ //查询活动列表
|
|
|
+ @RequestMapping("/activity/list")
|
|
|
+ public String activityList(Model model,
|
|
|
+ @RequestParam(required = false, defaultValue = "100") int pageSize,
|
|
|
+ @RequestParam(required = false, defaultValue = "1") int pageNo)throws Exception {
|
|
|
+
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
+ params.put("name", request.getParameter("name")==null?"":request.getParameter("name"));
|
|
|
+ SplitPage sp = new SplitPage();
|
|
|
+ sp.setAction(request.getRequestURI());
|
|
|
+ sp.setPageNo(pageNo);
|
|
|
+ sp.setPageSize(pageSize);
|
|
|
+ sp.setParams(params);
|
|
|
+ Page<Map<String, Object>> page = posterActivityService.findActivityByPage(params, initPage(pageNo, pageSize));
|
|
|
+ sp.setRowCnt((int) page.getTotalElements());
|
|
|
+ model.addAttribute("list", page.getContent());
|
|
|
+ model.addAttribute("listNavigatHtml", sp.getSysPaginHtml());
|
|
|
+ model.addAttribute("page", sp);
|
|
|
+ model.addAttribute("search", params);
|
|
|
+ return "sys/poster/activity_list";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //编辑活动页面
|
|
|
+ @RequestMapping("/activity/edit")
|
|
|
+ public String activityEdit(Model model,String id)throws Exception {
|
|
|
+ PosterActivity posterActivity=new PosterActivity();
|
|
|
+ if(StringUtils.isNotEmpty(id)) {
|
|
|
+ posterActivity=posterActivityService.getById(id);
|
|
|
+ }
|
|
|
+ List<PosterTemplate> templates=posterTemplateService.findPosterTemplateByList();
|
|
|
+ model.addAttribute("posterActivity",posterActivity);
|
|
|
+ model.addAttribute("templates",templates);
|
|
|
+ return "sys/poster/activity_edit";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //保存活动信息
|
|
|
+ @RequestMapping("/activity/save")
|
|
|
+ @ResponseBody
|
|
|
+ public Response activitySave(Model model,String id,String templateId,String name)throws Exception {
|
|
|
+ Response response = new Response();
|
|
|
+ if(StringUtils.isEmpty(id)){
|
|
|
+ PosterActivity posterActivity=new PosterActivity();
|
|
|
+ posterActivity.setName(name);
|
|
|
+ posterActivity.setTemplateId(templateId);
|
|
|
+ posterActivity.setStatus(1);
|
|
|
+ posterActivity.setCreateTime(new Date());
|
|
|
+ posterActivityService.save(posterActivity);
|
|
|
+ }else{
|
|
|
+ PosterActivity posterActivity=posterActivityService.getById(id);
|
|
|
+ if(posterActivity!=null) {
|
|
|
+ posterActivity.setName(name);
|
|
|
+ posterActivityService.save(posterActivity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ response.success("成功");
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //删除活动信息
|
|
|
+ @RequestMapping("/activity/del")
|
|
|
+ @ResponseBody
|
|
|
+ public Response activityDel(Model model,String id)throws Exception {
|
|
|
+ Response response = new Response();
|
|
|
+ if(StringUtils.isNotEmpty(id)){
|
|
|
+ PosterActivity posterActivity=posterActivityService.getById(id);
|
|
|
+ if(posterActivity!=null) {
|
|
|
+ posterActivity.setStatus(0);
|
|
|
+ posterActivityService.save(posterActivity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ response.success("成功");
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //查询机构列表
|
|
|
+ @RequestMapping("/join/list")
|
|
|
+ public String joinList(Model model,
|
|
|
+ @RequestParam(required = false, defaultValue = "100") int pageSize,
|
|
|
+ @RequestParam(required = false, defaultValue = "1") int pageNo)throws Exception {
|
|
|
+
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
+ params.put("name", request.getParameter("name")==null?"":request.getParameter("name"));
|
|
|
+ params.put("id", request.getParameter("id")==null?"":request.getParameter("id"));
|
|
|
+ SplitPage sp = new SplitPage();
|
|
|
+ sp.setAction(request.getRequestURI());
|
|
|
+ sp.setPageNo(pageNo);
|
|
|
+ sp.setPageSize(pageSize);
|
|
|
+ sp.setParams(params);
|
|
|
+ Page<Map<String, Object>> page = posterJoinService.findJoinByPage(params, initPage(pageNo, pageSize));
|
|
|
+ sp.setRowCnt((int) page.getTotalElements());
|
|
|
+ model.addAttribute("list", page.getContent());
|
|
|
+ model.addAttribute("listNavigatHtml", sp.getSysPaginHtml());
|
|
|
+ model.addAttribute("page", sp);
|
|
|
+ model.addAttribute("search", params);
|
|
|
+ return "sys/poster/join_list";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //编辑活动页面
|
|
|
+ @RequestMapping("/join/edit")
|
|
|
+ public String joinEdit(Model model,String id,String aid)throws Exception {
|
|
|
+ PosterActivity posterActivity=posterActivityService.getById(aid);
|
|
|
+ PosterTemplate posterTemplate=posterTemplateService.getById(posterActivity.getTemplateId());
|
|
|
+ PosterJoin posterJoin=new PosterJoin();
|
|
|
+ if(StringUtils.isNotEmpty(id)) {
|
|
|
+ posterJoin=posterJoinService.getById(id);
|
|
|
+ }
|
|
|
+ List<PosterTemplate> templates=posterTemplateService.findPosterTemplateByList();
|
|
|
+ model.addAttribute("posterTemplate",posterTemplate);
|
|
|
+ model.addAttribute("posterJoin",posterJoin);
|
|
|
+ model.addAttribute("posterActivity",posterActivity);
|
|
|
+ model.addAttribute("templates",templates);
|
|
|
+ return "sys/poster/join_edit";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //保存机构信息,并生成海报。
|
|
|
+ @RequestMapping("/join/save")
|
|
|
+ @ResponseBody
|
|
|
+ public Response joinSave(Model model,String id,String activityId,String name,String phone,String address,String logoImg,String qrcodeImg1,String qrcodeImg2,String posterImg)throws Exception {
|
|
|
+ Response response = new Response();
|
|
|
+ if(StringUtils.isEmpty(id)){
|
|
|
+ PosterJoin posterJoin=new PosterJoin();
|
|
|
+ posterJoin.setActivityId(activityId);
|
|
|
+ posterJoin.setLogoImg(logoImg);
|
|
|
+ posterJoin.setName(name);
|
|
|
+ posterJoin.setPhone(phone);
|
|
|
+ posterJoin.setPosterImg(posterImg);
|
|
|
+ posterJoin.setQrcodeImg1(qrcodeImg1);
|
|
|
+ posterJoin.setQrcodeImg2(qrcodeImg2);
|
|
|
+ posterJoin.setAddress(address);
|
|
|
+ posterJoin.setStatus(1);
|
|
|
+ posterJoin.setCreateTime(new Date());
|
|
|
+ posterJoinService.save(posterJoin);
|
|
|
+
|
|
|
+ posterJoinService.generatePosterImg(posterJoin);
|
|
|
+
|
|
|
+ }else{
|
|
|
+ PosterJoin posterJoin=posterJoinService.getById(id);
|
|
|
+ if(posterJoin!=null) {
|
|
|
+ posterJoin.setLogoImg(logoImg);
|
|
|
+ posterJoin.setName(name);
|
|
|
+ posterJoin.setPhone(phone);
|
|
|
+ posterJoin.setPosterImg(posterImg);
|
|
|
+ posterJoin.setQrcodeImg1(qrcodeImg1);
|
|
|
+ posterJoin.setQrcodeImg2(qrcodeImg2);
|
|
|
+ posterJoin.setAddress(address);
|
|
|
+ posterJoinService.save(posterJoin);
|
|
|
+
|
|
|
+ posterJoinService.generatePosterImg(posterJoin);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ response.success("成功");
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //删除活动信息
|
|
|
+ @RequestMapping("/join/del")
|
|
|
+ @ResponseBody
|
|
|
+ public Response joinDel(Model model,String id)throws Exception {
|
|
|
+ Response response = new Response();
|
|
|
+ if(StringUtils.isNotEmpty(id)){
|
|
|
+ PosterJoin posterJoin=posterJoinService.getById(id);
|
|
|
+ if(posterJoin!=null) {
|
|
|
+ posterJoin.setStatus(0);
|
|
|
+ posterJoinService.save(posterJoin);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ response.success("成功");
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //导入机构信息
|
|
|
+ @RequestMapping(value="/join/import")
|
|
|
+ @ResponseBody
|
|
|
+ public Response teacherImport(Model model,String id,@RequestParam("file") MultipartFile file) {
|
|
|
+ Response response = new Response();
|
|
|
+ try {
|
|
|
+ List<Map<String,String>> datas=ImLibUserController.analysisExFile(file);
|
|
|
+ if(datas!=null && datas.size()>0){
|
|
|
+ List<PosterJoin> posterJoins=new ArrayList<PosterJoin>();
|
|
|
+ PosterJoin posterJoin=null;
|
|
|
+ for (Map<String,String> map : datas) {
|
|
|
+ posterJoin=new PosterJoin();
|
|
|
+ posterJoin.setName(map.get("data_0"));
|
|
|
+ posterJoin.setPhone(map.get("data_1"));
|
|
|
+ posterJoin.setActivityId(id);
|
|
|
+ posterJoin.setCreateTime(new Date());
|
|
|
+ posterJoin.setStatus(1);
|
|
|
+ posterJoins.add(posterJoin);
|
|
|
+ }
|
|
|
+ if(posterJoins.size()>0) {
|
|
|
+ posterJoinService.save(posterJoins);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ response.success("导入成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("导入机构异常", e);
|
|
|
+ response.failure("导入机构异常:"+e.getMessage());
|
|
|
+ }
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|