Files
IfishSystemEnglish/src/main/java/com/ifish/helper/VenderHelper.java
T

270 lines
12 KiB
Java

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.ifish.helper;
import com.ifish.bean.Tbl_Vender_List;
import com.ifish.mapper.Tbl_Vender_List_Mapper;
import com.ifish.util.IfishUtil;
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.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
/**
*
* @author Administrator
*/
@Component
public class VenderHelper implements VenderHelperI {
@Autowired
private Tbl_Vender_List_Mapper tbl_Vender_List_Mapper;
@Autowired
private FastDFSClientI fastDFSClientI;
@Autowired
private RedisKeyHelperI redisKeyHelperI;
/**
* 鱼缸厂列表
*
* @return
*/
public ModelAndView getlist() {
ModelAndView mv = new ModelAndView();
mv.setViewName("venderlist");
mv.addObject("title", "鱼缸厂列表");
mv.addObject("myjs", "<!-- Other plugins ( load only nessesary plugins for every page) -->\n"
+ " <script src=\"static/assets/plugins/core/moment/moment.min.js\"></script>\n"
+ " <script src=\"static/assets/plugins/charts/sparklines/jquery.sparkline.js\"></script>\n"
+ " <script src=\"static/assets/plugins/charts/pie-chart/jquery.easy-pie-chart.js\"></script>\n"
+ " <script src=\"static/assets/plugins/forms/icheck/jquery.icheck.js\"></script>\n"
+ " <script src=\"static/assets/plugins/forms/tags/jquery.tagsinput.min.js\"></script>\n"
+ " <script src=\"static/assets/plugins/forms/tinymce/tinymce.min.js\"></script>\n"
+ " <script src=\"static/assets/plugins/tables/jquery.dataTables.js\"></script>\n"
+ "<link href=\"static/assets/plugins/tables/jquery.dataTables.css\" rel=\"stylesheet\">"
+ "<link href=\"static/assets/plugins/tables/dataTables.bootstrap.css\" rel=\"stylesheet\">"
+ " <script src=\"static/assets/plugins/tables/dataTables.bootstrap.js\"></script>\n"
+ " <script src=\"static/assets/plugins/misc/highlight/highlight.pack.js\"></script>\n"
+ " <script src=\"static/assets/plugins/misc/countTo/jquery.countTo.js\"></script>\n"
+ " <script src=\"static/assets/js/jquery.sprFlat.js\"></script>\n"
+ " <script src=\"static/switchery/switchery.min.js\"></script>\n"
+ "<link href=\"static/switchery/switchery.min.css\" rel=\"stylesheet\">"
+ " <script src=\"static/assets/js/app.js\"></script>");
return mv;
}
/**
* 鱼缸厂列表数据
*
* @return
*/
@Override
public Object getlistData(String draw, Integer start, Integer length, String appShow, String sortField, String sortMode, String brandName) {
if (StringUtils.isBlank(sortMode)) {
sortMode = "ASC";
}
if (StringUtils.isBlank(sortField)) {
sortField = "brand_code";
}
List<Map> list = tbl_Vender_List_Mapper.getlistData(start, length, appShow, sortField, sortMode, brandName);
for (Map map : list) {
String dateTime = IfishUtil.format((Date) map.get("createTime"));
map.put("createTime", dateTime);
}
int allCount = tbl_Vender_List_Mapper.getlistDataAllCount();
int count = tbl_Vender_List_Mapper.getlistDataCount(appShow, brandName);
Map map = new HashMap();
map.put("data", list);
map.put("draw", draw);
map.put("recordsTotal", allCount);
map.put("recordsFiltered", count);
return map;
}
/**
* 根据鱼缸厂code获取详情页
*
* @param brandCode
* @return
*/
@Override
public ModelAndView getvender(String brandCode) {
ModelAndView mv = new ModelAndView();
if (StringUtils.isBlank(brandCode)) {
mv.setViewName("redirect:venderlist");
return mv;
}
Tbl_Vender_List vender = tbl_Vender_List_Mapper.getTbl_Vender_ListByBrandCode(brandCode);
if (vender == null) {
mv.setViewName("redirect:venderlist");
return mv;
} else {
mv.addObject("vender", vender);
}
mv.setViewName("venderdetail");
mv.addObject("title", "鱼缸厂详情");
mv.addObject("pagetitle", "鱼缸厂详情");
mv.addObject("myjs", "<!-- Other plugins ( load only nessesary plugins for every page) -->\n"
+ " <script src=\"static/assets/plugins/core/moment/moment.min.js\"></script>\n"
+ " <script src=\"static/assets/plugins/charts/sparklines/jquery.sparkline.js\"></script>\n"
+ " <script src=\"static/assets/plugins/charts/pie-chart/jquery.easy-pie-chart.js\"></script>\n"
+ " <script src=\"static/assets/plugins/forms/icheck/jquery.icheck.js\"></script>\n"
+ " <script src=\"static/assets/plugins/forms/tags/jquery.tagsinput.min.js\"></script>\n"
+ " <script src=\"static/assets/plugins/forms/tinymce/tinymce.min.js\"></script>\n"
+ " <script src=\"static/assets/plugins/tables/jquery.dataTables.js\"></script>\n"
+ "<link href=\"static/assets/plugins/tables/jquery.dataTables.css\" rel=\"stylesheet\">"
+ "<link href=\"static/assets/plugins/tables/dataTables.bootstrap.css\" rel=\"stylesheet\">"
+ " <script src=\"static/assets/plugins/tables/dataTables.bootstrap.js\"></script>\n"
+ " <script src=\"static/assets/plugins/misc/highlight/highlight.pack.js\"></script>\n"
+ " <script src=\"static/assets/plugins/misc/countTo/jquery.countTo.js\"></script>\n"
+ " <script src=\"static/assets/js/jquery.sprFlat.js\"></script>\n"
+ " <script src=\"static/switchery/switchery.min.js\"></script>\n"
+ "<link href=\"static/switchery/switchery.min.css\" rel=\"stylesheet\">"
+ " <script src=\"static/assets/js/app.js\"></script>");
return mv;
}
/**
* 修改,插入 鱼缸厂信息
*
* @param brandLogoImg
* @param tbl_Vender_List
* @return
*/
@Override
public Object updateVender(MultipartFile brandLogoImg, Tbl_Vender_List tbl_Vender_List) {
try {
if (StringUtils.isNotBlank(tbl_Vender_List.getBrandName())) {
String brandName = new String(tbl_Vender_List.getBrandName().getBytes("iso-8859-1"), "UTF-8");
tbl_Vender_List.setBrandName(brandName);
}
if (StringUtils.isNotBlank(tbl_Vender_List.getContactAddress())) {
String contactAddress = new String(tbl_Vender_List.getContactAddress().getBytes("iso-8859-1"), "UTF-8");
tbl_Vender_List.setContactAddress(contactAddress);
}
Tbl_Vender_List oldTbl_Vender_List = tbl_Vender_List_Mapper.getTbl_Vender_ListByBrandCode(tbl_Vender_List.getBrandCode());
if (oldTbl_Vender_List == null) {
//插入
if (brandLogoImg != null) {
String path = fastDFSClientI.uploadFileToFastDFS(brandLogoImg);
tbl_Vender_List.setBrandLogo(path);
} else {
return "请上传正确的Logo图片";
}
int i = tbl_Vender_List_Mapper.insertVender(tbl_Vender_List);
if (i > 0) {
return "添加成功";
} else {
return "添加失败";
}
} else {
//修改
if (brandLogoImg != null) {
String path = fastDFSClientI.uploadFileToFastDFS(brandLogoImg);
tbl_Vender_List.setBrandLogo(path);
}
int i = tbl_Vender_List_Mapper.updateVender(tbl_Vender_List);
if (i > 0) {
redisKeyHelperI.deleteTbl_Vender_List_RedisKey();
return "修改成功";
} else {
return "修改失败";
}
}
} catch (Exception e) {
}
return "失败";
}
/**
* 新增鱼缸厂页面
*
* @return
*/
@Override
public ModelAndView addVender() {
ModelAndView mv = new ModelAndView();
mv.setViewName("venderdetail");
mv.addObject("title", "添加鱼缸厂");
mv.addObject("pagetitle", "添加鱼缸厂");
mv.addObject("myjs", "<!-- Other plugins ( load only nessesary plugins for every page) -->\n"
+ " <script src=\"static/assets/plugins/core/moment/moment.min.js\"></script>\n"
+ " <script src=\"static/assets/plugins/charts/sparklines/jquery.sparkline.js\"></script>\n"
+ " <script src=\"static/assets/plugins/charts/pie-chart/jquery.easy-pie-chart.js\"></script>\n"
+ " <script src=\"static/assets/plugins/forms/icheck/jquery.icheck.js\"></script>\n"
+ " <script src=\"static/assets/plugins/forms/tags/jquery.tagsinput.min.js\"></script>\n"
+ " <script src=\"static/assets/plugins/forms/tinymce/tinymce.min.js\"></script>\n"
+ " <script src=\"static/assets/plugins/tables/jquery.dataTables.js\"></script>\n"
+ "<link href=\"static/assets/plugins/tables/jquery.dataTables.css\" rel=\"stylesheet\">"
+ "<link href=\"static/assets/plugins/tables/dataTables.bootstrap.css\" rel=\"stylesheet\">"
+ " <script src=\"static/assets/plugins/tables/dataTables.bootstrap.js\"></script>\n"
+ " <script src=\"static/assets/plugins/misc/highlight/highlight.pack.js\"></script>\n"
+ " <script src=\"static/assets/plugins/misc/countTo/jquery.countTo.js\"></script>\n"
+ " <script src=\"static/assets/js/jquery.sprFlat.js\"></script>\n"
+ " <script src=\"static/switchery/switchery.min.js\"></script>\n"
+ "<link href=\"static/switchery/switchery.min.css\" rel=\"stylesheet\">"
+ " <script src=\"static/assets/js/app.js\"></script>");
return mv;
}
/**
* 根据鱼缸厂code删除鱼缸厂信息
*
* @param code
* @return
*/
@Override
public Object deleteVender(String code) {
Tbl_Vender_List tbl_Vender_List = tbl_Vender_List_Mapper.getTbl_Vender_ListByBrandCode(code);
if (tbl_Vender_List != null) {
int i = tbl_Vender_List_Mapper.deleteVender(code);
if (i > 0) {
redisKeyHelperI.deleteTbl_Vender_List_RedisKey();
return "删除成功";
}
} else {
return "删除失败!没有找到鱼缸厂信息!";
}
return "删除失败!";
}
/**
* 修改鱼缸厂在APP端是否展示
*
* @param code
* @param appshow
* @return
*/
@Override
public Object updateAppShow(String code, String appshow) {
try {
Tbl_Vender_List tbl_Vender_List = new Tbl_Vender_List();
tbl_Vender_List.setAppShow(appshow);
tbl_Vender_List.setBrandCode(code);
int i = tbl_Vender_List_Mapper.updateVender(tbl_Vender_List);
redisKeyHelperI.deleteTbl_Vender_List_RedisKey();
if (i > 0) {
return "修改成功";
} else {
return "修改失败";
}
} catch (Exception e) {
}
return "修改失败";
}
}