Commit a379d7bd authored by dongshize's avatar dongshize

五联商场公众号 初始化项目

parents
Pipeline #41 failed with stages
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
.settings
.classpath
.project
target
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
</parent>
<groupId>com.market</groupId>
<artifactId>weChat-market</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdk.version>1.8</jdk.version>
<spring.version>4.3.10.RELEASE</spring.version>
<springboot.version>1.5.6.RELEASE</springboot.version>
<mybatis.version>3.4.5</mybatis.version>
<mybatis.page>5.1.2</mybatis.page>
<mybatis.spring.version>1.3.1</mybatis.spring.version>
<mysql.driver.version>5.1.44</mysql.driver.version>
<tomcat.version>8.0.47</tomcat.version>
<commons-lang3.version>3.6</commons-lang3.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>${tomcat.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-el</artifactId>
<version>${tomcat.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<version>${tomcat.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.driver.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.4</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${mybatis.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>${mybatis.spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.mangofactory</groupId>
<artifactId>swagger-springmvc</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.44</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.5</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.2</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
</dependencies>
<!-- 插件配置 -->
<build>
<plugins>
<!-- compiler插件, 设定JDK版本 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerVersion>${jdk.version}</compilerVersion>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<!-- resource插件, 设定编码 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<!-- clean插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
</plugin>
<!-- jar相关插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<excludes>
<exclude>static/**</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
<finalName>${project.artifactId}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>
\ No newline at end of file
package com.weChatmarket;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ImportResource;
@SpringBootApplication
@ImportResource({ "classpath*:META-INF/spring/*.xml" })
public class appStart {
public static void main(String[] args) {
SpringApplication.run(appStart.class, args);
}
}
package com.weChatmarket.configer;
import java.util.List;
import javax.servlet.MultipartConfigElement;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import com.weChatmarket.page.PageTableArgumentResolver;
@Configuration
public class SpringMVCConfiger extends WebMvcConfigurerAdapter{
@Value("${uploadFile.location}")
private String location;// 上传文件保存的本地目录,使用@Value获取全局配置文件中配置的属性值,如 D:/wx/uploadFiles/
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/image/**").addResourceLocations("file:"+location);
}
@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurerAdapter() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedMethods("*");
registry.addMapping("/**").allowedOrigins("*");
}
};
}
/**
* datatable分页解析
*
* @return
*/
@Bean
public PageTableArgumentResolver tableHandlerMethodArgumentResolver() {
return new PageTableArgumentResolver();
}
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
argumentResolvers.add(tableHandlerMethodArgumentResolver());
}
/**
* 文件上传配置
*
* @return
*/
@Bean
public MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
// 单个数据大小
factory.setMaxFileSize("10240KB"); // KB,MB
/// 总上传数据大小
factory.setMaxRequestSize("102400KB");
return factory.createMultipartConfig();
}
}
package com.weChatmarket.configer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.ControllerAdvice;
import com.mangofactory.swagger.configuration.SpringSwaggerConfig;
import com.mangofactory.swagger.models.dto.ApiInfo;
import com.mangofactory.swagger.plugin.EnableSwagger;
import com.mangofactory.swagger.plugin.SwaggerSpringMvcPlugin;
@Configuration
@EnableSwagger
public class SwaggerConfig {
private SpringSwaggerConfig springSwaggerConfig;
@Autowired
public void setSpringSwaggerConfig(SpringSwaggerConfig springSwaggerConfig) {
this.springSwaggerConfig = springSwaggerConfig;
}
@SuppressWarnings("unchecked")
@Bean
public SwaggerSpringMvcPlugin customImplementation() {
return new SwaggerSpringMvcPlugin(this.springSwaggerConfig).apiInfo(apiInfo()).includePatterns(".*?")
.excludeAnnotations(ControllerAdvice.class);
}
private ApiInfo apiInfo() {
ApiInfo apiInfo = new ApiInfo("微信公众号API接口管理", "各个controller下对应相应业务接口", "weChat market", "weChat market",
null, null);
return apiInfo;
}
}
\ No newline at end of file
package com.weChatmarket.contens;
import java.io.Serializable;
/**
* 抽象的返回结果
*/
public class BaseResult<T> implements Serializable {
/**
*
*/
private static final long serialVersionUID = 7277594240016924327L;
/**
* 错误码
*/
private int code = ResultCodeEnum.HTTP_OK.getCode();
/**
* 错误信息
*/
private String msg = ResultCodeEnum.HTTP_OK.getMsg();
/**
* 返回的数据信息
*/
private T data;
public BaseResult(int code, String msg) {
super();
this.code = code;
this.msg = msg;
}
public BaseResult(ResultCodeEnum resultCode) {
super();
this.code = resultCode.getCode();
this.msg = resultCode.getMsg();
}
public BaseResult() {
super();
}
public BaseResult(boolean ret, int code) {
super();
this.code = code;
}
public int getCode() {
return code;
}
public BaseResult<T> setCode(int code) {
this.code = code;
return this;
}
public String getMsg() {
return msg;
}
public BaseResult<T> setMsg(String msg) {
this.msg = msg;
return this;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}
\ No newline at end of file
package com.weChatmarket.contens;
public enum ResultCodeEnum {
HTTP_OK(200, "成功"),
HTTP_LOGIN(201, "用户没有登陆"),
HTTP_PARAMS_ERROR(400, "输入参数错误"),
HTTP_USER_INEXISTENCE(401,"用户不存在"),
HTTP_ORIGINAL_PASSWORD_ERROR(402,"原密码错误"),
HTTP_FORBIDDEN(403,"没有权限"),
HTTP_ERROR(500, "系统异常");
int code;
String msg;
private ResultCodeEnum(int code, String msg) {
this.code = code;
this.msg = msg;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
package com.weChatmarket.controller;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.tomcat.util.http.fileupload.servlet.ServletFileUpload;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import com.weChatmarket.contens.BaseResult;
import com.weChatmarket.contens.ResultCodeEnum;
import com.weChatmarket.service.WxShopInforService;
import com.weChatmarket.service.WxShopItemService;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
@RestController
@Api(value = "图片上传")
@RequestMapping(value = "/file")
public class FileUploadController {
private static Logger logger = LoggerFactory.getLogger(FileUploadController.class);
@Value("${uploadFile.resourceHandler}")
private String resourceHandler; // 请求 url 中的资源映射,不推荐写死在代码中,最好提供可配置,如 /uploadFiles/**
@Value("${uploadFile.location}")
private String location; // 上传文件保存的本地目录,使用@Value获取全局配置文件中配置的属性值,如 D:/wx/uploadFiles/
@Value("${userLogin}")
private String userLogin; // 用户名
@Resource
private WxShopInforService wxShopInforService;
@Resource
private WxShopItemService wxShopItemService;
private final static long MAX_FILE_BYTES = 1024 * 1024 * 10L;
@RequestMapping(value = "/upload", method = { RequestMethod.POST })
@ApiOperation(value = "文件上传", notes = "文件上传", response = String.class)
public BaseResult<Object> upload(HttpServletRequest request) {
BaseResult<Object> br = new BaseResult<>();
// 校验是否登入
HttpSession session = request.getSession(false);
if (null == session || !userLogin.equals(session.getAttribute("user"))) {
br.setCode(ResultCodeEnum.HTTP_LOGIN.getCode());
br.setMsg("请先登入后,在进行操作");
return br;
}
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
String fileServerPath = "";
String name = "";
if (isMultipart) {
InputStream stream = null;
FileOutputStream fs = null;
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
List<MultipartFile> fileList = multipartRequest.getFiles("pic");
for (MultipartFile multipartFile : fileList) {
if (multipartFile.isEmpty()) {
br.setCode(ResultCodeEnum.HTTP_ERROR.getCode());
br.setMsg("上传图片为空,请重新上传!");
return br;
}
if (multipartFile.getSize() > MAX_FILE_BYTES) {
br.setCode(ResultCodeEnum.HTTP_ERROR.getCode());
br.setMsg("图片大小超过10MB!,请修改后重新上传!");
return br;
}
name = multipartFile.getOriginalFilename();
if (name.length() > 40) {
br.setCode(ResultCodeEnum.HTTP_ERROR.getCode());
br.setMsg("文件名过长,超过40个字符!请修改后重新上传!");
return br;
}
try {
String basePath = request.getScheme() + "://" +
// TODO
"192.168.1.59:"
// request.getServerName() + ":"
+ request.getServerPort() + request.getContextPath();
String fileName = System.currentTimeMillis() + multipartFile.getOriginalFilename().substring(
multipartFile.getOriginalFilename().indexOf("."),
multipartFile.getOriginalFilename().length());
fileServerPath = basePath + resourceHandler.substring(0, resourceHandler.lastIndexOf("/") + 1)
+ fileName;
File saveFile = new File(location, String.valueOf(fileName));
stream = multipartFile.getInputStream();
fs = new FileOutputStream(saveFile);
byte[] buffer = new byte[1024 * 1024];
int byteread = 0;
while ((byteread = stream.read(buffer)) != -1) {
fs.write(buffer, 0, byteread);
}
fs.flush();
fs.close();
stream.close();
} catch (Exception e) {
e.printStackTrace();
try {
if (fs != null) {
fs.close();
}
if (stream != null) {
stream.close();
}
} catch (Exception exc) {
exc.printStackTrace();
}
}
}
}
Map<String, Object> data = new HashMap<String, Object>();
data.put("id", fileServerPath);
data.put("name", name);
br.setData(data);
return br;
}
// @RequestMapping(value = "/cleanPhoto", method = { RequestMethod.POST })
// @ApiOperation(value = "清理照片", notes = "清理照片", response = String.class)
// public BaseResult<Object> cleanPhoto(HttpServletRequest request) {
// BaseResult<Object> br = new BaseResult<>();
// ArrayList<String> deleteFileList = new ArrayList<>();
// File parentFile = new File(location);
// File[] files = parentFile.listFiles();
// // 收集商铺中所有在使用的照片
// ArrayList<String> useFileList = new ArrayList<>();
// List<WxShopInfor> listWxShopInfor =
// wxShopInforService.findByNamedParamList(null);
// String basePath = request.getScheme() + "://" + request.getServerName() + ":"
// + request.getServerPort()
// + request.getContextPath();
// String fileServerPath = basePath + resourceHandler.substring(0,
// resourceHandler.lastIndexOf("/") + 1);
// for (WxShopInfor single : listWxShopInfor) {
// // 店铺主图
// if (!StringUtils.isEmpty(single.getShopMap())) {
// useFileList.add(single.getShopMap().replace(fileServerPath, "").trim());
// }
// // 店铺现象图
// if (!StringUtils.isEmpty(single.getShopImage())) {
// String shopImage = single.getShopImage();
// if (!StringUtils.isEmpty(shopImage)) {
// String[] shopImageTeam = shopImage.split(",");
// for (int i = 0; i < shopImageTeam.length; i++) {
// if (!StringUtils.isEmpty(shopImageTeam[i])) {
// useFileList.add(shopImageTeam[i].replace(fileServerPath, "").trim());
// }
// }
// }
// }
// }
// // 店铺商品明细图
// List<WxShopItem> listwxShopItem =
// wxShopItemService.findByNamedParamList(null);
// for (WxShopItem single : listwxShopItem) {
// if (!StringUtils.isEmpty(single.getPhotoId())) {
// useFileList.add(single.getPhotoId().replace(fileServerPath, "").trim());
// }
// }
//
// for (File file : files) {
// if (!file.isDirectory()) {
// // 上传的文件不在商铺中, 就删除
// Long sum = useFileList.stream().filter(name ->
// name.trim().equals(file.getName().trim())).count();
// if (sum == 0) {
// if (file.delete()) {
// logger.info(new Date() + "删除照片" + file.getName());
// deleteFileList.add(file.getName());
// }
// }
// }
// }
// br.setData(deleteFileList);
// return br;
// }
}
\ No newline at end of file
package com.weChatmarket.controller;
import java.io.PrintWriter;
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.HashMap;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Value;
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.RestController;
import com.weChatmarket.contens.BaseResult;
import com.weChatmarket.contens.ResultCodeEnum;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
@RestController
@Api(value = "用户登入")
@RequestMapping(value = "/user")
public class UserController {
@Value("${userLogin}")
private String userLogin; // 用户名
@Value("${passWord}")
private String passWord; // 密码
@RequestMapping(value = "/logIn", method = { RequestMethod.POST })
@ApiOperation(value = "用户登入", notes = "用户登入", response = String.class)
public BaseResult<Object> logIn(HttpServletRequest request,
HttpServletResponse response,
@ApiParam(value = "用户名") @RequestParam String user,
@ApiParam(value = "密码") @RequestParam String pass) {
BaseResult<Object> result = new BaseResult<>();
if (user.equals(userLogin) && pass.equals(passWord)) {
HttpSession session =request.getSession(true);
session.setAttribute("user", userLogin);
String sessionId = session.getId();
Cookie ckSessionId = new Cookie("weChat-market",sessionId);
ckSessionId.setMaxAge(1*1*24*60*60);
response.addCookie(ckSessionId); //保存登录sessionId到COOKIE
HashMap<String, Object> data = new HashMap<>();
data.put("user", userLogin);
result.setData(data);
} else {
result.setCode(ResultCodeEnum.HTTP_PARAMS_ERROR.getCode());
result.setMsg("用户名或密码有误");
}
return result;
}
@RequestMapping(value = "/logOut", method = { RequestMethod.POST })
@ApiOperation(value = "用户退出", notes = "用户退出", response = String.class)
public BaseResult<Object> logIn(HttpServletRequest request) {
BaseResult<Object> result = new BaseResult<>();
request.getSession().removeAttribute("user");
return result;
}
//
@RequestMapping(value = "/wx", method = { RequestMethod.GET })
@ApiOperation(value = "根据id查找", notes = "根据id查找", response = String.class)
public void test(HttpServletRequest request, HttpServletResponse response) {
// 获取参数配置
String signature = request.getParameter("signature");
// 获取时间托
String timestamp = request.getParameter("timestamp");
String nonce = request.getParameter("nonce");
// 获取echostr 字符
String echostr = request.getParameter("echostr");
// 获取token 此token跟需跟微信公众号的token一致;
String token = "zmkmdsz";
String str = "";
try {
// 判断是否为空
if (null != signature) {
// 声明一个存储数据字符数组
String[] ArrTmp = { token, timestamp, nonce };
Arrays.sort(ArrTmp);
StringBuffer sb = new StringBuffer();
for (int i = 0; i < ArrTmp.length; i++) {
sb.append(ArrTmp[i]);
}
// 获取消息对象
MessageDigest md = MessageDigest.getInstance("SHA-1");
// 声明一个字节流数组;
byte[] bytes = md.digest(new String(sb).getBytes());
// 声明一个字符流
StringBuffer buf = new StringBuffer();
for (int i = 0; i < bytes.length; i++) {
if (((int) bytes[i] & 0xff) < 0x10) {
buf.append("0");
}
buf.append(Long.toString((int) bytes[i] & 0xff, 16));
}
if (signature.equals(buf.toString())) {
str = echostr;
}
}
PrintWriter out = response.getWriter();
// 输出
out.print(str);
// 刷新
out.flush();
// 关闭流
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
package com.weChatmarket.controller;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Value;
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.RestController;
import com.weChatmarket.contens.BaseResult;
import com.weChatmarket.contens.ResultCodeEnum;
import com.weChatmarket.service.WxShopInforService;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
@RestController
@Api(value = "商铺信息维护", description = "商铺信息维护")
@RequestMapping(value = "/wxShopInfor")
public class WxShopInforController {
@Value("${userLogin}")
private String userLogin; // 用户名
@Resource
private WxShopInforService wxShopInforService;
@RequestMapping(value = "/pageList", method = { RequestMethod.POST })
@ApiOperation(value = "web端商城查询", notes = "web端商城查询", response = String.class)
public BaseResult<Object> pageList(
@ApiParam(value = "页码") @RequestParam(required = false, defaultValue = "1") Integer pageNum,
@ApiParam(value = "每页数量") @RequestParam(required = false, defaultValue = "10") Integer pageSize,
@ApiParam(value = "商铺名称或门牌号") @RequestParam(required = false) String searchValue) {
BaseResult<Object> result = new BaseResult<>();
result.setData(wxShopInforService.findPage(pageNum, pageSize, searchValue));
return result;
}
@RequestMapping(value = "/findWxShopInforById", method = { RequestMethod.POST })
@ApiOperation(value = "web端获取单个商城", notes = "web端获取单个商城", response = String.class)
public BaseResult<Object> findWxShopInforById(@ApiParam(value = "主键") @RequestParam(required = true) Long id) {
BaseResult<Object> result = new BaseResult<>();
result.setData(wxShopInforService.findWxShopInforDtoById(id));
return result;
}
@RequestMapping(value = "/wxPageList", method = { RequestMethod.POST })
@ApiOperation(value = "微信端商铺查询", notes = "微信端商铺查询", response = String.class)
public BaseResult<Object> wxPageList(
@ApiParam(value = "商铺名称或门牌号") @RequestParam(required = false) String searchValue,
@ApiParam(value = "商铺的种类") @RequestParam(required = false) Long typeId,
@ApiParam(value = "商铺的标签") @RequestParam(required = false) String label) {
BaseResult<Object> result = new BaseResult<>();
result.setData(wxShopInforService.wxPageList(searchValue, typeId, label));
return result;
}
@RequestMapping(value = "/wxFindById", method = { RequestMethod.POST})
@ApiOperation(value = "微信端获取单个商城", notes = "微信端获取单个商城", response = String.class)
public BaseResult<Object> wxFindById(@ApiParam(value = "主键") @RequestParam(required = true) Long id) {
BaseResult<Object> result = new BaseResult<>();
result.setData(wxShopInforService.wxFindById(id));
return result;
}
@RequestMapping(value = "/addOrUpdate", method = { RequestMethod.POST })
@ApiOperation(value = "商铺新增或修改", notes = "商铺新增或修改", response = String.class)
public BaseResult<Object> addOrUpdate(HttpServletRequest request,
@ApiParam(value = "主键ID") @RequestParam(required = true) Long id,
@ApiParam(value = "商铺名称") @RequestParam(required = false) String name,
@ApiParam(value = "门牌号") @RequestParam(required = false) String code,
@ApiParam(value = "商铺种类id") @RequestParam(required = false) Long typeId,
@ApiParam(value = "商铺标签ids") @RequestParam(required = false) List<String> labelIds,
@ApiParam(value = "电话号码") @RequestParam(required = false) String telephone,
@ApiParam(value = "店铺简介") @RequestParam(required = false) String introduce,
@ApiParam(value = "微信联系方式") @RequestParam(required = false) String wechat,
@ApiParam(value = "店铺主图") @RequestParam(required = false) String shopMap,
@ApiParam(value = "店铺主图图片名称") @RequestParam(required = false) String shopMapName,
@ApiParam(value = "置顶") @RequestParam(required = false) Integer top) {
BaseResult<Object> result = new BaseResult<>();
HttpSession session = request.getSession(false);
if (null == session || !userLogin.equals(session.getAttribute("user"))) {
result.setCode(ResultCodeEnum.HTTP_LOGIN.getCode());
result.setMsg("请先登入后,在进行操作");
return result;
}
boolean exist = wxShopInforService.checkWxShopInfor(id, code);
if (exist) {
// 存在就不允许创建,并返回错误信息
result.setCode(ResultCodeEnum.HTTP_PARAMS_ERROR.getCode());
result.setMsg("内容已经存在");
} else {
wxShopInforService.addOrUpdateWxShopInfor(id, name, code, typeId, labelIds, telephone, introduce, wechat,
shopMap,shopMapName, top);
}
return result;
}
@RequestMapping(value = "/delete", method = { RequestMethod.POST })
@ApiOperation(value = "商铺删除", notes = "商铺删除", response = String.class)
public BaseResult<Object> delete(HttpServletRequest request,
@ApiParam(value = "主键") @RequestParam(required = true) Long id) {
BaseResult<Object> result = new BaseResult<>();
HttpSession session = request.getSession(false);
if (null == session || !userLogin.equals(session.getAttribute("user"))) {
result.setCode(ResultCodeEnum.HTTP_LOGIN.getCode());
result.setMsg("请先登入后,在进行操作");
return result;
}
wxShopInforService.updateStatusById(id);
return result;
}
}
package com.weChatmarket.controller;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Value;
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.RestController;
import com.weChatmarket.contens.BaseResult;
import com.weChatmarket.contens.ResultCodeEnum;
import com.weChatmarket.domain.WxShopItem;
import com.weChatmarket.page.BasePage;
import com.weChatmarket.service.WxShopItemService;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
@RestController
@Api(value = "商品图文维护", description = "商品图文维护")
@RequestMapping(value = "/wxShopItem")
public class WxShopItemController {
@Value("${userLogin}")
private String userLogin; // 用户名
@Resource
private WxShopItemService wxShopItemService;
@RequestMapping(value = "/pageList", method = { RequestMethod.POST })
@ApiOperation(value = "web端商铺商品详情查询", notes = "web端商铺商品详情查询", response = String.class)
public BaseResult<BasePage<WxShopItem>> pageList(
@ApiParam(value = "页码") @RequestParam(required = false, defaultValue = "1") Integer pageNum,
@ApiParam(value = "每页数量") @RequestParam(required = false, defaultValue = "20") Integer pageSize,
@ApiParam(value = "商场主键ID") @RequestParam(required = false) Long pId) {
BaseResult<BasePage<WxShopItem>> result = new BaseResult<>();
result.setData(wxShopItemService.findPage(pageNum, pageSize, pId));
return result;
}
@RequestMapping(value = "/findWxShopItemById", method = { RequestMethod.POST })
@ApiOperation(value = "web端获取单个商铺商品详情", notes = "web端获取单个商铺商品详情", response = String.class)
public BaseResult<Object> findWxShopItemById(@ApiParam(value = "主键") @RequestParam(required = true) Long id) {
BaseResult<Object> result = new BaseResult<>();
result.setData(wxShopItemService.findById(id));
return result;
}
@RequestMapping(value = "/findWxShopItemByPid", method = { RequestMethod.POST })
@ApiOperation(value = "获取单个商品详情", notes = "获取单个商品图文", response = String.class)
public BaseResult<Object> findWxShopItemByPid(@ApiParam(value = "父类主键") @RequestParam(required = true) Long pId) {
BaseResult<Object> result = new BaseResult<>();
WxShopItem wxShopItem = new WxShopItem();
wxShopItem.setPId(pId);
wxShopItem.setStatus(1);
result.setData(wxShopItemService.findByNamedParamList(wxShopItem));
return result;
}
@RequestMapping(value = "/addOrUpdate", method = { RequestMethod.POST })
@ApiOperation(value = "商铺商品详情维护", notes = "商铺商品详情维护", response = String.class)
public BaseResult<Object> addOrUpdate(HttpServletRequest request,
@ApiParam(value = "主键ID") @RequestParam(required = false) Long id,
@ApiParam(value = "商铺主键id") @RequestParam(required = false) Long pId,
@ApiParam(value = "商品标题") @RequestParam(required = true) String title,
@ApiParam(value = "商品内容") @RequestParam(required = true) String content,
@ApiParam(value = "商品照片") @RequestParam(required = true) String photoId,
@ApiParam(value = "商品照片名称") @RequestParam(required = true) String photoName) {
BaseResult<Object> result = new BaseResult<>();
HttpSession session = request.getSession(false);
if (null == session || !userLogin.equals(session.getAttribute("user"))) {
result.setCode(ResultCodeEnum.HTTP_LOGIN.getCode());
result.setMsg("请先登入后,在进行操作");
return result;
}
wxShopItemService.addOrUpdateWxShopItem(id, pId, title,content,photoId,photoName);
return result;
}
@RequestMapping(value = "/delete", method = { RequestMethod.POST })
@ApiOperation(value = "商铺商品详情删除", notes = "商铺商品详情删除", response = String.class)
public BaseResult<Object> delete(HttpServletRequest request,
@ApiParam(value = "主键") @RequestParam(required = true) Long id) {
BaseResult<Object> result = new BaseResult<>();
HttpSession session = request.getSession(false);
if (null == session || !userLogin.equals(session.getAttribute("user"))) {
result.setCode(ResultCodeEnum.HTTP_LOGIN.getCode());
result.setMsg("请先登入后,在进行操作");
return result;
}
wxShopItemService.updateStatusById(id);
return result;
}
}
package com.weChatmarket.controller;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Value;
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.RestController;
import com.weChatmarket.contens.BaseResult;
import com.weChatmarket.contens.ResultCodeEnum;
import com.weChatmarket.domain.WxShopType;
import com.weChatmarket.page.BasePage;
import com.weChatmarket.service.WxShopTypeService;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;
@RestController
@Api(value = "商城类别维护", description = "商城类别维护")
@RequestMapping(value = "/WxShopType")
public class WxShopTypeController {
@Value("${userLogin}")
private String userLogin; // 用户名
@Resource
private WxShopTypeService wxShopTypeService;
@RequestMapping(value = "/typePageList", method = { RequestMethod.POST })
@ApiOperation(value = "web商城经营的类别查询", notes = "web商城经营的类别查询", response = String.class)
public BaseResult<BasePage<WxShopType>> typePageList(
@ApiParam(value = "页码") @RequestParam(required = false, defaultValue = "1") Integer pageNum,
@ApiParam(value = "每页数量") @RequestParam(required = false, defaultValue = "10") Integer pageSize) {
BaseResult<BasePage<WxShopType>> result = new BaseResult<>();
result.setData(wxShopTypeService.typePageList(pageNum, pageSize));
return result;
}
@RequestMapping(value = "/typeList", method = { RequestMethod.POST })
@ApiOperation(value = "web商城经营的类别", notes = "web商城经营的类别", response = String.class)
public BaseResult<Object> typeList(@ApiParam(value = "种类名称") @RequestParam(required = false) String typename) {
BaseResult<Object> result = new BaseResult<>();
result.setData(wxShopTypeService.typeList(typename));
return result;
}
@RequestMapping(value = "/lablePageList", method = { RequestMethod.POST })
@ApiOperation(value = "web商城经营的标签查询", notes = "web商城经营的标签查询", response = String.class)
public BaseResult<BasePage<WxShopType>> lablePageList(
@ApiParam(value = "页码") @RequestParam(required = false, defaultValue = "1") Integer pageNum,
@ApiParam(value = "每页数量") @RequestParam(required = false, defaultValue = "10") Integer pageSize,
@ApiParam(value = "父类主键pId") @RequestParam(required = true) Long pId) {
BaseResult<BasePage<WxShopType>> result = new BaseResult<>();
result.setData(wxShopTypeService.lablePageList(pageNum, pageSize, pId));
return result;
}
@RequestMapping(value = "/lableList", method = { RequestMethod.POST })
@ApiOperation(value = "web商城经营的标签查询", notes = "web商城经营的标签查询", response = String.class)
public BaseResult<Object> lableList(@ApiParam(value = "父类主键pId") @RequestParam(required = true) Long pId) {
BaseResult<Object> result = new BaseResult<>();
result.setData(wxShopTypeService.lableList(pId));
return result;
}
@RequestMapping(value = "/wxTypeLableList", method = { RequestMethod.POST })
@ApiOperation(value = "微信端查看商城类别标签查询", notes = "微信端查看商城类别标签查询", response = String.class)
public BaseResult<Object> wxTypeLableList() {
BaseResult<Object> result = new BaseResult<>();
result.setData(wxShopTypeService.wxTypeLableList());
return result;
}
@RequestMapping(value = "/findWxShopTypeById", method = { RequestMethod.POST })
@ApiOperation(value = "获取单个商城类别或标签", notes = "获取单个商城类别或标签", response = String.class)
public BaseResult<Object> findWxShopTypeById(@ApiParam(value = "主键") @RequestParam(required = true) Long id) {
BaseResult<Object> result = new BaseResult<>();
result.setData(wxShopTypeService.findWxShopTypeById(id));
return result;
}
@RequestMapping(value = "/addOrUpdate", method = { RequestMethod.POST })
@ApiOperation(value = "商城类别|标签新增或修改", notes = "商城类别|标签新增或修改", response = String.class)
public BaseResult<Object> addOrUpdate(HttpServletRequest request,
@ApiParam(value = "主键id") @RequestParam(required = true) Long id,
@ApiParam(value = "父类主键pId") @RequestParam(required = true) Long pId,
@ApiParam(value = "类别|标签名称") @RequestParam(required = true) String typeName) {
BaseResult<Object> result = new BaseResult<>();
HttpSession session = request.getSession(false);
if (null == session || !userLogin.equals(session.getAttribute("user"))) {
result.setCode(ResultCodeEnum.HTTP_LOGIN.getCode());
result.setMsg("请先登入后,在进行操作");
return result;
}
boolean exist = wxShopTypeService.checkWxShopType(pId, typeName);
if (exist) {
// 存在就不允许创建,并返回错误信息
result.setCode(ResultCodeEnum.HTTP_PARAMS_ERROR.getCode());
result.setMsg("内容已经存在");
} else {
wxShopTypeService.addOrUpdateWxShopType(id, pId, typeName);
}
return result;
}
@RequestMapping(value = "/delete", method = { RequestMethod.POST })
@ApiOperation(value = "商城类别标签删除", notes = "商城类别标签删除", response = String.class)
public BaseResult<Object> delete(HttpServletRequest request,
@ApiParam(value = "主键") @RequestParam(required = true) Long id,
@ApiParam(value = "父类主键") @RequestParam(required = true) Long pId) {
BaseResult<Object> result = new BaseResult<>();
HttpSession session = request.getSession(false);
if (null == session || !userLogin.equals(session.getAttribute("user"))) {
result.setCode(ResultCodeEnum.HTTP_LOGIN.getCode());
result.setMsg("请先登入后,在进行操作");
return result;
}
wxShopTypeService.updateStatusById(id, pId);
return result;
}
}
package com.weChatmarket.dao;
import java.io.Serializable;
import java.util.List;
/**
* dao 接口基类。
*
*/
public interface BaseDao<T> {
/**
* 根据id查找
*
* @param id
* @return
*/
public T findById(Serializable id);
/**
* 创建
*
* @param obj
* @return
*/
public int create(T obj);
/**
* 更新
*
* @param obj
* @return
*/
public int update(T obj);
/**
* 根据id删除
*
* @param obj
* @return
*/
public int deleteById(Object obj);
/**
* 根据参数查找(单个)
*
* @param serializable
* @return
*/
public T findByNamedParam(Serializable serializable);
/**
* 根据参数查找(列表)
*
* @param serializable
* @return
*/
public List<T> findByNamedParamList(Serializable serializable);
}
package com.weChatmarket.dao;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.weChatmarket.domain.WxShopInfor;
import com.weChatmarket.dto.WxShopInforDto;
/**
* 微信商场店铺信息表 create by
*/
public interface WxShopInforDao extends BaseDao<WxShopInfor> {
public List<WxShopInforDto> findPage(@Param("searchValue") String searchValue, @Param("typeId") Long typeId);
public List<WxShopInfor> findByLabel(@Param("label") String label);
public void cleanTypeAndLabelByTypeId(@Param("typeId") Long typeId);
public void updateShopMapById(@Param("id") Long id);
public void updateShopImageById(@Param("id") Long id, @Param("shopImage") String shopImage);
}
\ No newline at end of file
package com.weChatmarket.dao;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.weChatmarket.domain.WxShopItem;
/**
* 商品详细信息表 create by dongshize
*/
public interface WxShopItemDao extends BaseDao<WxShopItem> {
public List<WxShopItem> findPage(@Param("pId") Long pId);
}
\ No newline at end of file
package com.weChatmarket.dao;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.weChatmarket.domain.WxShopType;
/**
* 商铺种类表 create by dongshize
*/
public interface WxShopTypeDao extends BaseDao<WxShopType> {
public void updateStatusById(@Param("id") Long id);
public void updateStatusByPid(@Param("pId") Long pId);
public List<WxShopType> findTypeList(@Param("typename") String typename);
}
\ No newline at end of file
package com.weChatmarket.domain;
import java.io.Serializable;
import java.util.Date;
import java.math.BigDecimal;
/**
* 微信商场店铺信息表
*
* @author create by dongshize
*/
public class WxShopInfor implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;// 主键
private String name;// 商铺名称
private String code;// 门牌号
private Long typeId;// 种类ID
private String label;// 标签ID
private String telephone;// 电话号码
private String introduce;// 店铺介绍
private String wechat;// 微信联系方式
private String shopMap;// 店铺主图
private String shopMapName;// 主图名字
private Integer status;// 店铺状态| 1,有效;2,无效
private Integer top;// 置顶| 1置顶,0默认顺序
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return this.id;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public void setCode(String code) {
this.code = code;
}
public String getCode() {
return this.code;
}
public void setTypeId(Long typeId) {
this.typeId = typeId;
}
public Long getTypeId() {
return this.typeId;
}
public void setLabel(String label) {
this.label = label;
}
public String getLabel() {
return this.label;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getTelephone() {
return this.telephone;
}
public void setIntroduce(String introduce) {
this.introduce = introduce;
}
public String getIntroduce() {
return this.introduce;
}
public void setWechat(String wechat) {
this.wechat = wechat;
}
public String getWechat() {
return this.wechat;
}
public void setShopMap(String shopMap) {
this.shopMap = shopMap;
}
public String getShopMap() {
return this.shopMap;
}
public void setShopMapName(String shopMapName) {
this.shopMapName = shopMapName;
}
public String getShopMapName() {
return this.shopMapName;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getStatus() {
return this.status;
}
public void setTop(Integer top) {
this.top = top;
}
public Integer getTop() {
return this.top;
}
}
package com.weChatmarket.domain;
import java.io.Serializable;
/**
* 商品详细信息表
*
* @author create by dongshize
*/
public class WxShopItem implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;// 主键
private Long pId;// 商品信息ID主键
private String photoId;// 照片id
private String photoName;//
private String title;// 标题
private String content;// 内容
private Integer status;// 状态1有效2无效
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return this.id;
}
public void setPId(Long pId) {
this.pId = pId;
}
public Long getPId() {
return this.pId;
}
public void setPhotoId(String photoId) {
this.photoId = photoId;
}
public String getPhotoId() {
return this.photoId;
}
public void setPhotoName(String photoName) {
this.photoName = photoName;
}
public String getPhotoName() {
return this.photoName;
}
public void setTitle(String title) {
this.title = title;
}
public String getTitle() {
return this.title;
}
public void setContent(String content) {
this.content = content;
}
public String getContent() {
return this.content;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getStatus() {
return this.status;
}
}
package com.weChatmarket.domain;
import java.io.Serializable;
/**
* 商铺种类表
*
* @author create by dongshize
*/
public class WxShopType implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;// 主键
private Long pId;// 父类ID
private String typename;// 名字
private Integer status;// 状态|1有效,2无效
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return this.id;
}
public void setPId(Long pId) {
this.pId = pId;
}
public Long getPId() {
return this.pId;
}
public void setTypename(String typename) {
this.typename = typename;
}
public String getTypename() {
return this.typename;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getStatus() {
return this.status;
}
}
package com.weChatmarket.dto;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import com.weChatmarket.domain.WxShopItem;
/**
* @author dongshize
*
*/
public class WxShopInforAppDto implements Serializable {
private static final long serialVersionUID = 1L;
private WxShopInforDto wxShopInforDto = new WxShopInforDto();
private List<WxShopItem> itemList = new ArrayList<>();
public WxShopInforDto getWxShopInforDto() {
return wxShopInforDto;
}
public void setWxShopInforDto(WxShopInforDto wxShopInforDto) {
this.wxShopInforDto = wxShopInforDto;
}
public List<WxShopItem> getItemList() {
return itemList;
}
public void setItemList(List<WxShopItem> itemList) {
this.itemList = itemList;
}
}
package com.weChatmarket.dto;
import java.io.Serializable;
/**
* 微信商场店铺信息表
*
* @author create by dongshize
*/
public class WxShopInforDto implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;// 主键
private String name;// 商铺名称
private String code;// 门牌号
private Long typeId;// 种类ID
private String typeName; // 种类名称
private String label;// 标签ID
private String labelName;// 标签名称
private String telephone;// 电话号码
private String introduce;// 店铺介绍
private String wechat;// 微信联系方式
private String shopMap;// 店铺主图
private String shopMapName;// 主图名字
private Integer status;// 店铺状态| 1,有效;2,无效
private Integer top;// 置顶| 1置顶,0默认顺序
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return this.id;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public void setCode(String code) {
this.code = code;
}
public String getCode() {
return this.code;
}
public void setTypeId(Long typeId) {
this.typeId = typeId;
}
public Long getTypeId() {
return this.typeId;
}
public void setLabel(String label) {
this.label = label;
}
public String getLabel() {
return this.label;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getTelephone() {
return this.telephone;
}
public void setIntroduce(String introduce) {
this.introduce = introduce;
}
public String getIntroduce() {
return this.introduce;
}
public void setWechat(String wechat) {
this.wechat = wechat;
}
public String getWechat() {
return this.wechat;
}
public void setShopMap(String shopMap) {
this.shopMap = shopMap;
}
public String getShopMap() {
return this.shopMap;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getStatus() {
return this.status;
}
public void setTop(Integer top) {
this.top = top;
}
public Integer getTop() {
return this.top;
}
public String getTypeName() {
return typeName;
}
public void setTypeName(String typeName) {
this.typeName = typeName;
}
public String getLabelName() {
return labelName;
}
public void setLabelName(String labelName) {
this.labelName = labelName;
}
public String getShopMapName() {
return shopMapName;
}
public void setShopMapName(String shopMapName) {
this.shopMapName = shopMapName;
}
}
package com.weChatmarket.dto;
import java.io.Serializable;
public class WxShopLableDto implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;// 主键
private Long pId;// 父类ID
private String text;// 名字
private Integer status;// 状态|1有效,2无效
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getpId() {
return pId;
}
public void setpId(Long pId) {
this.pId = pId;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
}
package com.weChatmarket.dto;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class WxShopTypeLableDto implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;// 主键
private Long pId;// 父类ID
private String text;// 名字
private Integer status;// 状态|1有效,2无效
private List<WxShopLableDto> children = new ArrayList<>();
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getpId() {
return pId;
}
public void setpId(Long pId) {
this.pId = pId;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public List<WxShopLableDto> getChildren() {
return children;
}
public void setChildren(List<WxShopLableDto> children) {
this.children = children;
}
}
package com.weChatmarket.page;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.github.pagehelper.Page;
/**
* 对Page<E>结果进行包装
* <p/>
* 新增分页的多项属性,主要参考:http://bbs.csdn.net/topics/360010907
*
* @author liuzh/abel533/isea533
* @version 3.3.0
* @since 3.2.2 项目地址 : http://git.oschina.net/free/Mybatis_PageHelper
*/
@SuppressWarnings({ "rawtypes" })
public class BasePage<T> implements Serializable {
private static final long serialVersionUID = 1L;
// 当前页
private int pageNum;
// 每页的数量
private int pageSize;
// 当前页的数量
private int size;
// 总记录数
private long total;
// 总页数
private int pages;
// 结果集
private List<T> list;
// 前一页
private int prePage;
// 下一页
private int nextPage;
// 是否为第一页
private boolean isFirstPage = false;
// 是否为最后一页
private boolean isLastPage = false;
// 是否有前一页
private boolean hasPreviousPage = false;
// 是否有下一页
private boolean hasNextPage = false;
public BasePage() {
}
/**
* 包装Page对象
*
* @param list
* page结果
* @param navigatePages
* 页码数量
*/
public BasePage(List<T> list) {
if (list instanceof Page) {
Page page = (Page) list;
this.pageNum = page.getPageNum();
this.pageSize = page.getPageSize();
this.pages = page.getPages();
this.list = new ArrayList<T>(list);
this.size = page.size();
this.total = page.getTotal();
} else if (list instanceof Collection) {
this.pageNum = 1;
this.pageSize = list.size();
this.pages = this.pageSize > 0 ? 1 : 0;
this.list = list;
this.size = list.size();
this.total = list.size();
}
if (list instanceof Collection) {
// 计算前后页,第一页,最后一页
calcPage();
// 判断页面边界
judgePageBoudary();
}
}
/**
* 计算前后页,第一页,最后一页
*/
public void calcPage() {
if (pageNum > 1) {
prePage = pageNum - 1;
}
if (pageNum < pages) {
nextPage = pageNum + 1;
}
}
/**
* 判定页面边界
*/
public void judgePageBoudary() {
isFirstPage = pageNum == 1;
isLastPage = pageNum == pages || pages == 0;
;
hasPreviousPage = pageNum > 1;
hasNextPage = pageNum < pages;
}
public int getPageNum() {
return pageNum;
}
public void setPageNum(int pageNum) {
this.pageNum = pageNum;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
public long getTotal() {
return total;
}
public void setTotal(long total) {
this.total = total;
}
public int getPages() {
return pages;
}
public void setPages(int pages) {
this.pages = pages;
}
public List<T> getList() {
return list;
}
public void setList(List<T> list) {
this.list = list;
}
public int getPrePage() {
return prePage;
}
public void setPrePage(int prePage) {
this.prePage = prePage;
}
public int getNextPage() {
return nextPage;
}
public void setNextPage(int nextPage) {
this.nextPage = nextPage;
}
public boolean isIsFirstPage() {
return isFirstPage;
}
public void setIsFirstPage(boolean isFirstPage) {
this.isFirstPage = isFirstPage;
}
public boolean isIsLastPage() {
return isLastPage;
}
public void setIsLastPage(boolean isLastPage) {
this.isLastPage = isLastPage;
}
public boolean isHasPreviousPage() {
return hasPreviousPage;
}
public void setHasPreviousPage(boolean hasPreviousPage) {
this.hasPreviousPage = hasPreviousPage;
}
public boolean isHasNextPage() {
return hasNextPage;
}
public void setHasNextPage(boolean hasNextPage) {
this.hasNextPage = hasNextPage;
}
@Override
public String toString() {
final StringBuffer sb = new StringBuffer("PageInfo{");
sb.append("pageNum=").append(pageNum);
sb.append(", pageSize=").append(pageSize);
sb.append(", size=").append(size);
sb.append(", total=").append(total);
sb.append(", pages=").append(pages);
sb.append(", list=").append(list);
sb.append(", prePage=").append(prePage);
sb.append(", nextPage=").append(nextPage);
sb.append(", isFirstPage=").append(isFirstPage);
sb.append(", isLastPage=").append(isLastPage);
sb.append(", hasPreviousPage=").append(hasPreviousPage);
sb.append(", hasNextPage=").append(hasNextPage);
sb.append(", navigatepageNums=");
sb.append('}');
return sb.toString();
}
}
package com.weChatmarket.page;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.MethodParameter;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.support.WebDataBinderFactory;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer;
import com.google.common.collect.Maps;
/**
* 分页、查询参数解析
*
* @author 小威老师
*
*/
public class PageTableArgumentResolver implements HandlerMethodArgumentResolver {
@Override
public boolean supportsParameter(MethodParameter parameter) {
Class<?> cla = parameter.getParameterType();
return cla.isAssignableFrom(PageTableRequest.class);
}
@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
HttpServletRequest request = webRequest.getNativeRequest(HttpServletRequest.class);
PageTableRequest tableRequest = new PageTableRequest();
Map<String, String[]> param = request.getParameterMap();
if (param.containsKey("start")) {
tableRequest.setOffset(Integer.parseInt(request.getParameter("start")));
}
if (param.containsKey("length")) {
tableRequest.setLimit(Integer.parseInt(request.getParameter("length")));
}
Map<String, Object> map = Maps.newHashMap();
tableRequest.setParams(map);
param.forEach((k, v) -> {
if (v.length == 1) {
map.put(k, v[0]);
} else {
map.put(k, Arrays.asList(v));
}
});
setOrderBy(tableRequest, map);
removeParam(tableRequest);
return tableRequest;
}
/**
* 去除datatables分页带的一些复杂参数
*
* @param tableRequest
*/
private void removeParam(PageTableRequest tableRequest) {
Map<String, Object> map = tableRequest.getParams();
if (!CollectionUtils.isEmpty(map)) {
Map<String, Object> param = new HashMap<>();
map.forEach((k, v) -> {
if (k.indexOf("[") < 0 && k.indexOf("]") < 0 && !"_".equals(k)) {
param.put(k, v);
}
});
tableRequest.setParams(param);
}
}
/**
* 从datatables分页请求数据中解析排序
*
* @param tableRequest
* @param map
*/
private void setOrderBy(PageTableRequest tableRequest, Map<String, Object> map) {
StringBuilder orderBy = new StringBuilder();
int size = map.size();
for (int i = 0; i < size; i++) {
String index = (String) map.get("order[" + i + "][column]");
if (StringUtils.isEmpty(index)) {
break;
}
String column = (String) map.get("columns[" + index + "][data]");
if (StringUtils.isBlank(column)) {
continue;
}
String sort = (String) map.get("order[" + i + "][dir]");
orderBy.append(column).append(" ").append(sort).append(", ");
}
if (orderBy.length() > 0) {
tableRequest.getParams().put("orderBy",
" order by " + StringUtils.substringBeforeLast(orderBy.toString(), ","));
}
}
}
package com.weChatmarket.page;
import java.util.ArrayList;
import java.util.List;
/**
* 分页查询处理器
*
* @author 小威老师
*
*/
public class PageTableHandler {
private CountHandler countHandler;
private ListHandler listHandler;
public PageTableHandler(CountHandler countHandler, ListHandler listHandler) {
super();
this.countHandler = countHandler;
this.listHandler = listHandler;
}
public PageTableResponse handle(PageTableRequest dtRequest) {
int count = 0;
List<?> list = null;
count = this.countHandler.count(dtRequest);
if (count > 0) {
list = this.listHandler.list(dtRequest);
}
if (list == null) {
list = new ArrayList<>();
}
return new PageTableResponse(count, count, list);
}
public interface ListHandler {
List<?> list(PageTableRequest request);
}
public interface CountHandler {
int count(PageTableRequest request);
}
}
\ No newline at end of file
package com.weChatmarket.page;
import java.io.Serializable;
import java.util.Map;
/**
* 分页查询参数
*
* @author 小威老师
*
*/
public class PageTableRequest implements Serializable {
private static final long serialVersionUID = 7328071045193618467L;
//后添加的用这个
private Integer offset;
//原系统用
private Integer sysOffset;
private Integer limit;
private Map<String, Object> params;
public Integer getSysOffset() {
return offset;
}
public void setSysOffset(Integer sysOffset) {
this.sysOffset = sysOffset;
}
public Integer getOffset() {
return offset/this.limit+1;
}
public void setOffset(Integer offset) {
this.offset =offset ;
}
public Integer getLimit() {
return limit;
}
public void setLimit(Integer limit) {
this.limit = limit;
}
public Map<String, Object> getParams() {
return params;
}
public void setParams(Map<String, Object> params) {
this.params = params;
}
}
package com.weChatmarket.page;
import java.io.Serializable;
import java.util.List;
/**
* 分页查询返回
*
* @author 小威老师
*
*/
public class PageTableResponse implements Serializable {
private static final long serialVersionUID = 620421858510718076L;
private Integer recordsTotal;
private Integer recordsFiltered;
private List<?> data;
public PageTableResponse(Integer recordsTotal, Integer recordsFiltered, List<?> data) {
super();
this.recordsTotal = recordsTotal;
this.recordsFiltered = recordsFiltered;
this.data = data;
}
public Integer getRecordsTotal() {
return recordsTotal;
}
public void setRecordsTotal(Integer recordsTotal) {
this.recordsTotal = recordsTotal;
}
public Integer getRecordsFiltered() {
return recordsFiltered;
}
public void setRecordsFiltered(Integer recordsFiltered) {
this.recordsFiltered = recordsFiltered;
}
public List<?> getData() {
return data;
}
public void setData(List<?> data) {
this.data = data;
}
}
\ No newline at end of file
package com.weChatmarket.service;
import java.io.Serializable;
import java.util.List;
import com.weChatmarket.dao.BaseDao;
public interface BaseService<T> {
/**
* 根据id查找
*
* @param id
* @return
*/
public T findById(Serializable id);
/**
* 创建
*
* @param obj
* @return
*/
public int create(T obj);
/**
* 更新
*
* @param obj
* @return
*/
public int update(T obj);
/**
* 根据id删除
*
* @param obj
* @return
*/
public int deleteById(Object obj);
/**
* 根据参数查找(单个)
*
* @param serializable
* @return
*/
public T findByNamedParam(Serializable serializable);
/**
* 根据参数查找(列表)
*
* @param serializable
* @return
*/
public List<T> findByNamedParamList(Serializable serializable);
/**
* 获得dao实例
*
* @return
*/
public abstract <D extends BaseDao<T>> D getDao();
}
\ No newline at end of file
package com.weChatmarket.service;
import java.util.List;
import com.weChatmarket.domain.WxShopInfor;
import com.weChatmarket.domain.WxShopType;
import com.weChatmarket.dto.WxShopInforAppDto;
import com.weChatmarket.dto.WxShopInforDto;
import com.weChatmarket.page.BasePage;
/**
* 微信商场店铺信息表 create by dongshize
*/
public interface WxShopInforService extends BaseService<WxShopInfor> {
public boolean checkWxShopInfor(Long id,String code);
public WxShopInfor makeWxShopInfor(Long id, String name, String code, Long typeId, List<String> labelIds, String telephone,
String introduce, String wechat, String shopMap,String shopMapName,Integer top, Integer status);
public void addOrUpdateWxShopInfor(Long id, String name, String code, Long typeId, List<String> labelIds,
String telephone, String introduce, String wechat, String shopMap,String shopMapName, Integer top);
public void updateStatusById(Long id);
public BasePage<WxShopInforDto> findPage(Integer pageNum, Integer pageSize, String searchValue);
public List<WxShopInforDto> wxPageList(String searchValue ,Long typeId ,String label);
public List<WxShopInfor> findByLabel(String label);
public void cleanTypeAndLabelByTypeId(Long typeId);
public WxShopInforDto findWxShopInforDtoById(Long id);
public WxShopInforAppDto wxFindById(Long id);
public WxShopInforDto makeWxShopInforDto(WxShopInfor wxShopInfor,List<WxShopType> shopTypeList);
public void editWxShopInforDto(WxShopInforDto wxShopInforDto,List<WxShopType> shopTypeList);
}
package com.weChatmarket.service;
import com.weChatmarket.domain.WxShopItem;
import com.weChatmarket.page.BasePage;
/**
* 商品详细信息表 create by dongshize
*/
public interface WxShopItemService extends BaseService<WxShopItem> {
public void addOrUpdateWxShopItem(Long id, Long pId, String title,String content,String photoId,String photoName);
public WxShopItem makeWxShopItem (Long id, Long pId, String title,String content,String photoId ,String photoName,Integer status);
public void updateStatusById(Long id);
public BasePage<WxShopItem> findPage(Integer pageNum, Integer pageSize, Long pId);
}
package com.weChatmarket.service;
import java.util.List;
import com.weChatmarket.domain.WxShopType;
import com.weChatmarket.dto.WxShopTypeLableDto;
import com.weChatmarket.page.BasePage;
/**
* 商铺种类表 create by dongshize
*/
public interface WxShopTypeService extends BaseService<WxShopType> {
public boolean checkWxShopType(Long pId, String typeName);
public void addOrUpdateWxShopType(Long id, Long pId, String typeName);
public WxShopType makeWxShopType(Long id, Long pId, String typeName, Integer status);
public BasePage<WxShopType> typePageList(Integer pageNum, Integer pageSize);
public WxShopType findWxShopTypeById(Long id);
public void updateStatusById(Long id, Long pId);
public BasePage<WxShopType> lablePageList(Integer pageNum, Integer pageSize,Long pId);
public List<WxShopType> lableList(Long pId);
public List<WxShopTypeLableDto> wxTypeLableList();
public List<WxShopType> typeList(String typename);
}
package com.weChatmarket.service.impl;
import java.io.Serializable;
import java.util.List;
import com.weChatmarket.service.BaseService;
public abstract class BaseServiceImpl<T> implements BaseService<T> {
@Override
public T findById(Serializable id) {
return getDao().findById(id);
}
@Override
public int create(T obj) {
return getDao().create(obj);
}
@Override
public int update(T obj) {
return getDao().update(obj);
}
@Override
public int deleteById(Object obj) {
return getDao().deleteById(obj);
}
@Override
public T findByNamedParam(Serializable serializable) {
return (T) getDao().findByNamedParam(serializable);
}
@Override
public List<T> findByNamedParamList(Serializable serializable) {
return getDao().findByNamedParamList(serializable);
}
}
package com.weChatmarket.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import com.github.pagehelper.PageHelper;
import com.weChatmarket.dao.WxShopItemDao;
import com.weChatmarket.domain.WxShopItem;
import com.weChatmarket.page.BasePage;
import com.weChatmarket.service.WxShopItemService;
/**
* 商品详细信息表 create by dongshize
*/
@Service("wxShopItemService")
public class WxShopItemServiceImpl extends BaseServiceImpl<WxShopItem> implements WxShopItemService {
@Autowired
private WxShopItemDao wxShopItemDao;
@SuppressWarnings("unchecked")
@Override
public WxShopItemDao getDao() {
return wxShopItemDao;
}
/**
* 商品信息的新增或更新
*
* @param id 商品主键
* @param pId 商铺的主鍵
* @param title 商品的标题
* @param content 商品的内容
* @param photoId 商品的图片
*/
@Override
public void addOrUpdateWxShopItem(Long id, Long pId, String title, String content, String photoId,String photoName) {
WxShopItem wxShopItem = this.makeWxShopItem(id, pId, title, content, photoId,photoName, 0);
if (id == 0) {
wxShopItemDao.create(wxShopItem);
} else {
wxShopItemDao.update(wxShopItem);
}
}
/**
* 商品信息的编辑
*
* @param id 商品主键
* @param pId 商铺的主鍵
* @param title 商品的标题
* @param content 商品的内容
* @param photoId 商品的图片
* @param status 商品的状态
*/
@Override
public WxShopItem makeWxShopItem(Long id, Long pId, String title, String content, String photoId,String photoName, Integer status) {
WxShopItem wxShopItem = new WxShopItem();
if (null != id && id > 0) { // 主键ID
wxShopItem.setId(id);
}
if (null != pId && pId > 0) {
wxShopItem.setPId(pId);
}
if (!StringUtils.isEmpty(title)) {
wxShopItem.setTitle(title);
}
if (!StringUtils.isEmpty(content)) {
wxShopItem.setContent(content);
}
if (!StringUtils.isEmpty(photoId)) {
wxShopItem.setPhotoId(photoId);
}
if (!StringUtils.isEmpty(photoName)) {
wxShopItem.setPhotoName(photoName);
}
if (null != status && status > 0) {
wxShopItem.setStatus(status);
}
return wxShopItem;
}
/**
* 商品的状态变更
*
* @param id 商品主键
*/
@Override
public void updateStatusById(Long id) {
WxShopItem wxShopItem = this.makeWxShopItem(id, Long.valueOf(0), null, null, null,null, 2);
wxShopItemDao.update(wxShopItem);
}
/**
* 商品信息的编辑
*
* @param id 商品主键
* @param pId 商铺的主鍵
* @param title 商品的标题
* @param content 商品的内容
* @param photoId 商品的图片
* @param status 商品的状态
*/
@Override
public BasePage<WxShopItem> findPage(Integer pageNum, Integer pageSize, Long pId) {
PageHelper.startPage(pageNum, pageSize);
List<WxShopItem> list = wxShopItemDao.findPage(pId);
return new BasePage<WxShopItem>(list);
}
}
package com.weChatmarket.service.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import com.github.pagehelper.PageHelper;
import com.weChatmarket.dao.WxShopTypeDao;
import com.weChatmarket.domain.WxShopInfor;
import com.weChatmarket.domain.WxShopType;
import com.weChatmarket.dto.WxShopLableDto;
import com.weChatmarket.dto.WxShopTypeLableDto;
import com.weChatmarket.page.BasePage;
import com.weChatmarket.service.WxShopInforService;
import com.weChatmarket.service.WxShopTypeService;
/**
* 商铺种类表 create by dongshize
*/
@Service("wxShopTypeService")
public class WxShopTypeServiceImpl extends BaseServiceImpl<WxShopType> implements WxShopTypeService {
@Autowired
private WxShopTypeDao wxShopTypeDao;
@Resource
private WxShopInforService wxShopInforService;
@SuppressWarnings("unchecked")
@Override
public WxShopTypeDao getDao() {
return wxShopTypeDao;
}
/**
* 校验种类或标签是否存在
*
* @param id 种类的主键
* @param typeName 种类的名称
*/
@Override
public boolean checkWxShopType(Long pId, String typeName) {
boolean result = true;
WxShopType wxShopType = this.makeWxShopType(Long.valueOf(0), Long.valueOf(pId), typeName, 1);
WxShopType wxShopTypeExist = wxShopTypeDao.findByNamedParam(wxShopType);
if (null == wxShopTypeExist) {
result = false;
}
return result;
}
/**
* 种类或标签的添加或更新
*
* @param id 种类主键
* @param pId 父类主键
* @param typeName 种类名称
*/
@Override
public void addOrUpdateWxShopType(Long id, Long pId, String typeName) {
WxShopType wxShopType = this.makeWxShopType(id, pId, typeName, 0);
if (id == 0) {
wxShopTypeDao.create(wxShopType);
} else {
wxShopTypeDao.update(wxShopType);
}
}
/**
* 种类或标签的编辑
*
* @param id 种类的主键
* @param pId 商铺主键
* @param typeName 种类名称
* @param status 种类的状态
*/
@Override
public WxShopType makeWxShopType(Long id, Long pId, String typeName, Integer status) {
WxShopType wxShopType = new WxShopType();
if (id > 0) { // 主键ID
wxShopType.setId(id);
}
if (null != pId && pId > -1) { // 父类的主键ID
wxShopType.setPId(pId);
}
if (!StringUtils.isEmpty(typeName)) {
wxShopType.setTypename(typeName);
}
if (null != status && status > 0) {
wxShopType.setStatus(status);
}
return wxShopType;
}
/**
* 种类或标签的取得
*
* @param id 种类的主键
*/
@Override
public WxShopType findWxShopTypeById(Long id) {
return wxShopTypeDao.findById(id);
}
/**
* 种类或标签的状态更新
*
* @param id 种类的主键
* @param pId 父类主键
*/
@Override
public void updateStatusById(Long id, Long pId) {
wxShopTypeDao.updateStatusById(id);
// 类别删除
if (null != pId && pId == 0) {
// 删除的是类别,类别下面对应的标签全部删除
wxShopTypeDao.updateStatusByPid(id);
// 商店中对应的类别也相应清空,并且标签也相应的清空
wxShopInforService.cleanTypeAndLabelByTypeId(id);
} else {
// 标签删除
// 商城里面对应的标签进行删除
List<WxShopInfor> wxShopInforList = wxShopInforService.findByLabel(String.valueOf(id));
for (WxShopInfor shopInf : wxShopInforList) {
String lables = shopInf.getLabel();
if (!StringUtils.isEmpty(lables)) {
String lableNew = "";
if (lables.contains(",")) {
String[] lableTeam = lables.split(",");
List<String> lableList = new ArrayList<>();
for (int i = 0; i < lableTeam.length; i++) {
if (!lableTeam[i].equals(String.valueOf(id))) {
lableList.add(lableTeam[i]);
}
}
lableNew = lableList.stream().collect(Collectors.joining(","));
shopInf.setLabel(lableNew);
// 更新数据
wxShopInforService.update(shopInf);
} else {
// 里面只有一个
if (String.valueOf(id).equals(lables)) {
// 设定新的label
shopInf.setLabel(lableNew);
// 更新数据
wxShopInforService.update(shopInf);
}
}
}
}
}
}
/**
* 所有标签查询-分页
*
* @param pageNum 页码
* @param pageSize 每页数量
* @param pId 父类主键
*/
@Override
public BasePage<WxShopType> lablePageList(Integer pageNum, Integer pageSize,Long pId) {
PageHelper.startPage(pageNum, pageSize);
WxShopType WxShopType = new WxShopType();
WxShopType.setPId(pId);
WxShopType.setStatus(1);
List<WxShopType> list = wxShopTypeDao.findByNamedParamList(WxShopType);
return new BasePage<WxShopType>(list);
}
/**
* 所有种类查询-分页
*
* @param pageNum 页码
* @param pageSize 每页数量
*/
@Override
public BasePage<WxShopType> typePageList(Integer pageNum, Integer pageSize) {
PageHelper.startPage(pageNum, pageSize);
List<WxShopType> list = wxShopTypeDao.findTypeList(null);
return new BasePage<WxShopType>(list);
}
/**
* 所有种类或标签查询
*/
@Override
public List<WxShopTypeLableDto> wxTypeLableList() {
List<WxShopTypeLableDto> list = new ArrayList<>();
WxShopTypeLableDto wxShopTypeLableDto = null;
// 父类
List<WxShopType> father = wxShopTypeDao.findTypeList(null);
for (WxShopType wxShopType : father) {
wxShopTypeLableDto = new WxShopTypeLableDto();
wxShopTypeLableDto.setId(wxShopType.getId());
wxShopTypeLableDto.setText(wxShopType.getTypename());
wxShopTypeLableDto.setpId(wxShopType.getPId());
wxShopTypeLableDto.setStatus(wxShopType.getStatus());
List<WxShopLableDto> children = new ArrayList<>();
// 子类
WxShopType WxShopTypeSon = new WxShopType();
WxShopTypeSon.setPId(wxShopType.getId());
WxShopTypeSon.setStatus(1);
List<WxShopType> lableList = wxShopTypeDao.findByNamedParamList(WxShopTypeSon);
for (WxShopType chShopType : lableList) {
WxShopLableDto wxShopLableDto = new WxShopLableDto();
wxShopLableDto.setId(chShopType.getId());
wxShopLableDto.setText(chShopType.getTypename());
wxShopLableDto.setpId(chShopType.getPId());
wxShopLableDto.setStatus(chShopType.getStatus());
children.add(wxShopLableDto);
}
wxShopTypeLableDto.setChildren(children);
list.add(wxShopTypeLableDto);
}
return list;
}
/**
* 所有种类查询
*
* @param typename 种类名称
*/
@Override
public List<WxShopType> typeList(String typename) {
List<WxShopType> list = wxShopTypeDao.findTypeList(typename);
return list;
}
/**
* 所有标签查询
*
* @param pId 父类主键
*/
@Override
public List<WxShopType> lableList(Long pId) {
WxShopType WxShopType = new WxShopType();
WxShopType.setPId(pId);
WxShopType.setStatus(1);
List<WxShopType> list = wxShopTypeDao.findByNamedParamList(WxShopType);
return list;
}
}
package com.weChatmarket.util;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.commons.io.IOUtils;
import org.springframework.web.multipart.MultipartFile;
public class FileUtil {
public static String uploadFile(MultipartFile file, String filePath) {
String fileId = "";
try {
Long currentTime = System.currentTimeMillis();
String fileName = file.getOriginalFilename();
fileId = currentTime + "-" + fileName;
String str = filePath + fileId;
File saveFile = new File(str);
OutputStream outputStream = new FileOutputStream(saveFile);
IOUtils.copy(file.getInputStream(), outputStream);
} catch (IOException e) {
e.printStackTrace();
}
return fileId;
}
}
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.weChatmarket.dao.WxShopInforDao">
<resultMap id="BaseResultMap" type="com.weChatmarket.domain.WxShopInfor">
<result column="id" property="id" jdbcType="BIGINT"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="code" property="code" jdbcType="VARCHAR"/>
<result column="typeId" property="typeId" jdbcType="BIGINT"/>
<result column="label" property="label" jdbcType="VARCHAR"/>
<result column="telephone" property="telephone" jdbcType="VARCHAR"/>
<result column="introduce" property="introduce" jdbcType="VARCHAR"/>
<result column="wechat" property="wechat" jdbcType="VARCHAR"/>
<result column="shopMap" property="shopMap" jdbcType="VARCHAR"/>
<result column="shopMapName" property="shopMapName" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="TINYINT"/>
<result column="top" property="top" jdbcType="TINYINT"/>
</resultMap>
<sql id="Base_Column_List">
id,name,code,typeId,label,telephone,introduce,wechat,shopMap,shopMapName,status,top
</sql>
<!--条件查询单个-->
<select id="findById" resultMap="BaseResultMap" >
select <include refid="Base_Column_List" /> from t_wx_shop_infor where id = #{id} limit 1
</select>
<!--插入一条-->
<insert id="create" parameterType="com.weChatmarket.domain.WxShopInfor" useGeneratedKeys="true" keyProperty="id">
insert into t_wx_shop_infor
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null and id != ''">id,</if>
<if test="name != null and name != ''">name,</if>
<if test="code != null and code != ''">code,</if>
<if test="typeId != null and typeId != ''">typeId,</if>
<if test="label != null and label != ''">label,</if>
<if test="telephone != null and telephone != ''">telephone,</if>
<if test="introduce != null and introduce != ''">introduce,</if>
<if test="wechat != null and wechat != ''">wechat,</if>
<if test="shopMap != null and shopMap != ''">shopMap,</if>
<if test="shopMapName != null and shopMapName != ''">shopMapName,</if>
<if test="status != null and status != ''">status,</if>
<if test="top != null and top != ''">top,</if>
</trim>
<trim prefix=" values (" suffix=")" suffixOverrides=",">
<if test="id != null and id != ''">#{id},</if>
<if test="name != null and name != ''">#{name},</if>
<if test="code != null and code != ''">#{code},</if>
<if test="typeId != null and typeId != ''">#{typeId},</if>
<if test="label != null and label != ''">#{label},</if>
<if test="telephone != null and telephone != ''">#{telephone},</if>
<if test="introduce != null and introduce != ''">#{introduce},</if>
<if test="wechat != null and wechat != ''">#{wechat},</if>
<if test="shopMap != null and shopMap != ''">#{shopMap},</if>
<if test="shopMapName != null and shopMapName != ''">#{shopMapName},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="top != null and top != ''">#{top},</if>
</trim>
</insert>
<!--更新一条-->
<update id="update">
update t_wx_shop_infor
<set>
<if test="id != null and id != ''">id = #{id},</if>
<if test="name != null and name != ''">name = #{name},</if>
<if test="code != null and code != ''">code = #{code},</if>
<if test="typeId != null and typeId != ''">typeId = #{typeId},</if>
<if test="label != null and label != ''">label = #{label},</if>
<if test="telephone != null and telephone != ''">telephone = #{telephone},</if>
<if test="introduce != null and introduce != ''">introduce = #{introduce},</if>
<if test="wechat != null and wechat != ''">wechat = #{wechat},</if>
<if test="shopMap != null and shopMap != ''">shopMap = #{shopMap},</if>
<if test="shopMapName != null and shopMapName != ''">shopMapName = #{shopMapName},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="top != null and top != ''">top = #{top},</if>
</set>
where id = #{id}
</update>
<!--删除一条-->
<update id="deleteById">
delete from t_wx_shop_infor where id = #{id}
</update>
<!--多条件查询单个-->
<select id="findByNamedParam" resultMap="BaseResultMap">
select <include refid="Base_Column_List" /> from t_wx_shop_infor
<trim prefix="where" prefixOverrides="and |or ">
<if test="id != null and id != ''">and id = #{id}</if>
<if test="name != null and name != ''">and name = #{name}</if>
<if test="code != null and code != ''">and code = #{code}</if>
<if test="typeId != null and typeId != ''">and typeId = #{typeId}</if>
<if test="label != null and label != ''">and label = #{label}</if>
<if test="telephone != null and telephone != ''">and telephone = #{telephone}</if>
<if test="introduce != null and introduce != ''">and introduce = #{introduce}</if>
<if test="wechat != null and wechat != ''">and wechat = #{wechat}</if>
<if test="shopMap != null and shopMap != ''">and shopMap = #{shopMap}</if>
<if test="shopMapName != null and shopMapName != ''">and shopMapName = #{shopMapName}</if>
<if test="status != null and status != ''">and status = #{status}</if>
<if test="top != null and top != ''">and top = #{top}</if>
</trim>
limit 1
</select>
<!--多条件条件查询列表-->
<select id="findByNamedParamList" resultMap="BaseResultMap">
select <include refid="Base_Column_List" /> from t_wx_shop_infor
<trim prefix="where" prefixOverrides="and |or ">
<if test="id != null and id != ''">and id = #{id}</if>
<if test="name != null and name != ''">and name = #{name}</if>
<if test="code != null and code != ''">and code = #{code}</if>
<if test="typeId != null and typeId != ''">and typeId = #{typeId}</if>
<if test="label != null and label != ''">and label = #{label}</if>
<if test="telephone != null and telephone != ''">and telephone = #{telephone}</if>
<if test="introduce != null and introduce != ''">and introduce = #{introduce}</if>
<if test="wechat != null and wechat != ''">and wechat = #{wechat}</if>
<if test="shopMap != null and shopMap != ''">and shopMap = #{shopMap}</if>
<if test="shopMapName != null and shopMapName != ''">and shopMapName = #{shopMapName}</if>
<if test="status != null and status != ''">and status = #{status}</if>
<if test="top != null and top != ''">and top = #{top}</if>
</trim>
order by id desc
</select>
</mapper>
\ No newline at end of file
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.weChatmarket.dao.WxShopItemDao">
<resultMap id="BaseResultMap" type="com.weChatmarket.domain.WxShopItem">
<result column="id" property="id" jdbcType="BIGINT"/>
<result column="p_id" property="pId" jdbcType="BIGINT"/>
<result column="photo_id" property="photoId" jdbcType="VARCHAR"/>
<result column="photoName" property="photoName" jdbcType="VARCHAR"/>
<result column="title" property="title" jdbcType="VARCHAR"/>
<result column="content" property="content" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="TINYINT"/>
</resultMap>
<sql id="Base_Column_List">
id,p_id,photo_id,photoName,title,content,status
</sql>
<!--条件查询单个-->
<select id="findById" resultMap="BaseResultMap" >
select <include refid="Base_Column_List" /> from t_wx_shop_item where id = #{id} limit 1
</select>
<!--插入一条-->
<insert id="create" parameterType="com.weChatmarket.domain.WxShopItem" useGeneratedKeys="true" keyProperty="id">
insert into t_wx_shop_item
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null and id != ''">id,</if>
<if test="pId != null and pId != ''">p_id,</if>
<if test="photoId != null and photoId != ''">photo_id,</if>
<if test="photoName != null and photoName != ''">photoName,</if>
<if test="title != null and title != ''">title,</if>
<if test="content != null and content != ''">content,</if>
<if test="status != null and status != ''">status,</if>
</trim>
<trim prefix=" values (" suffix=")" suffixOverrides=",">
<if test="id != null and id != ''">#{id},</if>
<if test="pId != null and pId != ''">#{pId},</if>
<if test="photoId != null and photoId != ''">#{photoId},</if>
<if test="photoName != null and photoName != ''">#{photoName},</if>
<if test="title != null and title != ''">#{title},</if>
<if test="content != null and content != ''">#{content},</if>
<if test="status != null and status != ''">#{status},</if>
</trim>
</insert>
<!--更新一条-->
<update id="update">
update t_wx_shop_item
<set>
<if test="id != null and id != ''">id = #{id},</if>
<if test="pId != null and pId != ''">p_id = #{pId},</if>
<if test="photoId != null and photoId != ''">photo_id = #{photoId},</if>
<if test="photoName != null and photoName != ''">photoName = #{photoName},</if>
<if test="title != null and title != ''">title = #{title},</if>
<if test="content != null and content != ''">content = #{content},</if>
<if test="status != null and status != ''">status = #{status},</if>
</set>
where id = #{id}
</update>
<!--删除一条-->
<update id="deleteById">
delete from t_wx_shop_item where id = #{id}
</update>
<!--多条件查询单个-->
<select id="findByNamedParam" resultMap="BaseResultMap">
select <include refid="Base_Column_List" /> from t_wx_shop_item
<trim prefix="where" prefixOverrides="and |or ">
<if test="id != null and id != ''">and id = #{id}</if>
<if test="pId != null and pId != ''">and p_id = #{pId}</if>
<if test="photoId != null and photoId != ''">and photo_id = #{photoId}</if>
<if test="photoName != null and photoName != ''">and photoName = #{photoName}</if>
<if test="title != null and title != ''">and title = #{title}</if>
<if test="content != null and content != ''">and content = #{content}</if>
<if test="status != null and status != ''">and status = #{status}</if>
</trim>
limit 1
</select>
<!--多条件条件查询列表-->
<select id="findByNamedParamList" resultMap="BaseResultMap">
select <include refid="Base_Column_List" /> from t_wx_shop_item
<trim prefix="where" prefixOverrides="and |or ">
<if test="id != null and id != ''">and id = #{id}</if>
<if test="pId != null and pId != ''">and p_id = #{pId}</if>
<if test="photoId != null and photoId != ''">and photo_id = #{photoId}</if>
<if test="photoName != null and photoName != ''">and photoName = #{photoName}</if>
<if test="title != null and title != ''">and title = #{title}</if>
<if test="content != null and content != ''">and content = #{content}</if>
<if test="status != null and status != ''">and status = #{status}</if>
</trim>
order by id desc
</select>
</mapper>
\ No newline at end of file
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.weChatmarket.dao.WxShopTypeDao">
<resultMap id="BaseResultMap" type="com.weChatmarket.domain.WxShopType">
<result column="id" property="id" jdbcType="BIGINT" />
<result column="p_id" property="pId" jdbcType="BIGINT" />
<result column="typename" property="typename" jdbcType="VARCHAR" />
<result column="status" property="status" jdbcType="TINYINT" />
</resultMap>
<sql id="Base_Column_List">
id,p_id,typename,status
</sql>
<!--条件查询单个 -->
<select id="findById" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_wx_shop_type where id = #{id} limit 1
</select>
<!--插入一条 -->
<insert id="create" parameterType="com.weChatmarket.domain.WxShopType"
useGeneratedKeys="true" keyProperty="id">
insert into t_wx_shop_type
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null and id != ''">id,</if>
<if test="pId != null and pId != ''">p_id,</if>
<if test="typename != null and typename != ''">typename,</if>
<if test="status != null and status != ''">status,</if>
</trim>
<trim prefix=" values (" suffix=")" suffixOverrides=",">
<if test="id != null and id != ''">#{id},</if>
<if test="pId != null and pId != ''">#{pId},</if>
<if test="typename != null and typename != ''">#{typename},</if>
<if test="status != null and status != ''">#{status},</if>
</trim>
</insert>
<!--更新一条 -->
<update id="update">
update t_wx_shop_type
<set>
<if test="id != null and id != ''">id = #{id},</if>
<if test="pId != null and pId != ''">p_id = #{pId},</if>
<if test="typename != null and typename != ''">typename = #{typename},</if>
<if test="status != null and status != ''">status = #{status},</if>
</set>
where id = #{id}
</update>
<!--删除一条 -->
<update id="deleteById">
delete from t_wx_shop_type where id = #{id}
</update>
<!--多条件查询单个 -->
<select id="findByNamedParam" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_wx_shop_type
<trim prefix="where" prefixOverrides="and |or ">
<if test="id != null and id != ''">and id = #{id}</if>
<if test="pId != null and pId != ''">and p_id = #{pId}</if>
<if test="typename != null and typename != ''">and typename = #{typename}</if>
<if test="status != null and status != ''">and status = #{status}</if>
</trim>
limit 1
</select>
<!--多条件条件查询列表 -->
<select id="findByNamedParamList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_wx_shop_type
<trim prefix="where" prefixOverrides="and |or ">
<if test="id != null and id != ''">and id = #{id}</if>
<if test="pId != null and pId != ''">and p_id = #{pId}</if>
<if test="typename != null and typename != ''">and typename = #{typename}</if>
<if test="status != null and status != ''">and status = #{status}</if>
</trim>
order by id desc
</select>
</mapper>
\ No newline at end of file
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.weChatmarket.dao.WxShopInforDao">
<resultMap id="ResultMap" type="com.weChatmarket.dto.WxShopInforDto">
<result column="id" property="id" jdbcType="BIGINT"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="code" property="code" jdbcType="VARCHAR"/>
<result column="typeId" property="typeId" jdbcType="BIGINT"/>
<result column="label" property="label" jdbcType="VARCHAR"/>
<result column="telephone" property="telephone" jdbcType="VARCHAR"/>
<result column="introduce" property="introduce" jdbcType="VARCHAR"/>
<result column="wechat" property="wechat" jdbcType="VARCHAR"/>
<result column="shopMap" property="shopMap" jdbcType="VARCHAR"/>
<result column="shopMapName" property="shopMapName" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="TINYINT"/>
<result column="top" property="top" jdbcType="TINYINT"/>
</resultMap>
<resultMap id="ResultMapWxShopInfor" type="com.weChatmarket.domain.WxShopInfor">
<result column="id" property="id" jdbcType="BIGINT"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="code" property="code" jdbcType="VARCHAR"/>
<result column="typeId" property="typeId" jdbcType="BIGINT"/>
<result column="label" property="label" jdbcType="VARCHAR"/>
<result column="telephone" property="telephone" jdbcType="VARCHAR"/>
<result column="introduce" property="introduce" jdbcType="VARCHAR"/>
<result column="wechat" property="wechat" jdbcType="VARCHAR"/>
<result column="shopMap" property="shopMap" jdbcType="VARCHAR"/>
<result column="shopMapName" property="shopMapName" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="TINYINT"/>
<result column="top" property="top" jdbcType="TINYINT"/>
</resultMap>
<sql id="Column_List">
id,name,code,typeId,label,telephone,introduce,wechat,shopMap,shopMapName,status,top
</sql>
<!--多条件条件查询列表 -->
<select id="findPage" resultMap="ResultMap">
select
<include refid="Column_List" />
from t_wx_shop_infor
<trim prefix="where" prefixOverrides="and |or ">
and status = 1
<if test="searchValue != null and searchValue != ''">
and (
name like concat('%', #{searchValue}, '%')
or
code like concat('%', #{searchValue}, '%')
)
</if>
<if test="typeId != null and typeId != ''">
and typeId = #{typeId}
</if>
</trim>
order by top desc, name desc
</select>
<!--多条件条件查询列表 -->
<select id="findByLabel" resultMap="ResultMapWxShopInfor">
select wxinf.* from (
select * ,
FIND_IN_SET( #{label} , label) as IsLabel
from t_wx_shop_infor
) wxinf
<trim prefix="where" prefixOverrides="and |or ">
and status = 1
<if test="label != null and label != ''">
and IsLabel > 0
</if>
</trim>
order by id
</select>
<!-- 清空种类和标签 -->
<update id="cleanTypeAndLabelByTypeId">
update t_wx_shop_infor
set typeId = NULL,
label = NULL
where typeId = #{typeId}
and status = 1
</update>
<!--更新商城主图 -->
<update id="updateShopMapById">
update t_wx_shop_infor
set shopMap = null
where id =
#{id}
</update>
<!--更新店铺现象图 -->
<update id="updateShopImageById">
update t_wx_shop_infor
set shopImage = #{shopImage}
where id = #{id}
</update>
</mapper>
\ No newline at end of file
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.weChatmarket.dao.WxShopItemDao">
<resultMap id="ResultMap" type="com.weChatmarket.domain.WxShopItem">
<result column="id" property="id" jdbcType="BIGINT"/>
<result column="p_id" property="pId" jdbcType="BIGINT"/>
<result column="photo_id" property="photoId" jdbcType="VARCHAR"/>
<result column="title" property="title" jdbcType="VARCHAR"/>
<result column="content" property="content" jdbcType="VARCHAR"/>
<result column="status" property="status" jdbcType="TINYINT"/>
</resultMap>
<sql id="Column_List">
id,p_id,photo_id,photoName,title,content,status
</sql>
<!--多条件条件查询列表 -->
<select id="findPage" resultMap="ResultMap">
select
<include refid="Column_List" />
from t_wx_shop_item
<trim prefix="where" prefixOverrides="and |or ">
<if test="pId != null and pId != ''">and p_id = #{pId}</if>
and status = 1
</trim>
order by id desc
</select>
</mapper>
\ No newline at end of file
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.weChatmarket.dao.WxShopTypeDao">
<resultMap id="ResultMap" type="com.weChatmarket.domain.WxShopType">
<result column="id" property="id" jdbcType="BIGINT" />
<result column="p_id" property="pId" jdbcType="BIGINT" />
<result column="typename" property="typename" jdbcType="VARCHAR" />
<result column="status" property="status" jdbcType="TINYINT" />
</resultMap>
<sql id="Column_List">
id,p_id,typename,status
</sql>
<!--查询种类 -->
<select id="findTypeList" resultMap="ResultMap">
select
<include refid="Column_List" />
from t_wx_shop_type
<trim prefix="where" prefixOverrides="and |or ">
and p_id = 0 and status = 1
<if test="typename != null and typename != ''">and typename = #{typename}</if>
</trim>
</select>
<!--更新状态一条 -->
<update id="updateStatusById">
update t_wx_shop_type set status = 2 where id = #{id}
</update>
<!--更新状态一条 -->
<update id="updateStatusByPid">
update t_wx_shop_type set status = 2 where p_id =#{pId}
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<beans default-autowire="byName"
xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd">
<description>全局配置,配置文件读取,注解扫描</description>
<context:property-placeholder location="classpath:config.properties" file-encoding="UTF-8" ignore-unresolvable="true"/>
<context:component-scan base-package="com.weChatmarket.service" use-default-filters="true">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
<context:exclude-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice"/>
</context:component-scan>
</beans>
\ No newline at end of file
<?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:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<description>数据源配置</description>
<bean id="ds_master_0" class="com.alibaba.druid.pool.DruidDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="${ds_master_0.url}" />
<property name="username" value="${ds_master_0.username}" />
<property name="password" value="${ds_master_0.password}" />
<property name="maxActive" value="500" />
<property name="validationQuery" value="select 1" />
<property name="timeBetweenEvictionRunsMillis" value="60000" />
<property name="minEvictableIdleTimeMillis" value="300000" />
<property name="testWhileIdle" value="true" />
<property name="testOnBorrow" value="false" />
<property name="testOnReturn" value="false" />
<property name="filters" value="stat" />
<property name="connectionProperties" value="druid.stat.logSlowSql=true" />
</bean>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="ds_master_0" />
</bean>
<bean id="transactionTemplate"
class="org.springframework.transaction.support.TransactionTemplate">
<property name="transactionManager" ref="transactionManager" />
<!--ISOLATION_DEFAULT 表示由使用的数据库决定 -->
<property name="isolationLevelName" value="ISOLATION_DEFAULT" />
<property name="propagationBehaviorName" value="PROPAGATION_REQUIRED" />
<property name="timeout" value="30" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="ds_master_0" />
<property name="mapperLocations">
<array>
<value>classpath*:META-INF/mappers/*.xml</value>
<value>classpath*:META-INF/mappers/adapter/*.xml</value>
</array>
</property>
<property name="plugins">
<array>
<bean class="com.github.pagehelper.PageInterceptor">
<property name="properties">
<value>
helperDialect=mysql
reasonable=true
supportMethodsArguments=true
params=count=countSql
autoRuntimeDialect=true
reasonable=false
</value>
</property>
</bean>
</array>
</property>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.weChatmarket.dao" />
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
</bean>
</beans>
\ No newline at end of file
server:
port: 8089
context-path: /weChat-market
spring:
http:
multipart:
maxFileSize: 10Mb
maxRequestSize: 10Mb
uploadFile:
resourceHandler: /image/** #请求 url 中的资源映射
location: D:/WX/uploadFiles/ #自定义上传文件本地保存路径
userLogin: admin
passWord: 123456
#数据库配置
#ds_master_0.url=jdbc:mysql://123.57.2.50:3333/db_freight_platform?useUnicode=true&amp;characterEncoding=utf-8&amp;allowMultiQueries=true&amp;tinyInt1isBit=false&amp;useSSL=false
ds_master_0.url=jdbc:mysql://192.168.1.147:3306/wx_market?characterEncoding=utf8&amp;allowMultiQueries=true&amp;tinyInt1isBit=false&amp;useSSL=false
ds_master_0.username=root
ds_master_0.password=123456
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="log.charset" value="UTF-8" />
<property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n" />
<property name="log.home" value="/var/log/weChat-market" />
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder charset="${log.charset}">
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<appender name="DEBUG"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder charset="${log.charset}">
<pattern>${log.pattern}</pattern>
</encoder>
<file>${log.home}/debug.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.home}/debug.%d{yyyy-MM-dd}.log
</fileNamePattern>
<MaxHistory>30</MaxHistory>
</rollingPolicy>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>DENY</onMatch>
<onMismatch>ACCEPT</onMismatch>
</filter>
</appender>
<appender name="ERROR"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder charset="${log.charset}">
<pattern>${log.pattern}</pattern>
</encoder>
<file>${log.home}/error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.home}/error.%d{yyyy-MM-dd}.log
</fileNamePattern>
<MaxHistory>30</MaxHistory>
</rollingPolicy>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<logger name="com.weChatmarket" level="DEBUG" />
<logger name="org.apache" level="ERROR" />
<logger name="org.apache" level="ERROR" />
<logger name="org.springframework" level="ERROR" />
<root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="DEBUG" />
<appender-ref ref="ERROR" />
</root>
</configuration>
\ No newline at end of file
#!/bin/bash
source ~/.bashrc
DEPLOY_DIR='/usr/local/'
SERVER_NAME='weChat-market'
PIDS=`ps -f | grep java | grep "$CONF_DIR" |awk '{print $2}'`
if [ -z "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME does not started!"
exit 1
fi
DUMP_DIR=$DEPLOY_DIR/dump
if [ ! -d $DUMP_DIR ]; then
mkdir $DUMP_DIR
fi
DUMP_DATE=`date +%Y%m%d%H%M%S`
DATE_DIR=$DUMP_DIR/$DUMP_DATE
if [ ! -d $DATE_DIR ]; then
mkdir $DATE_DIR
fi
echo -e "Dumping the $SERVER_NAME ...\c"
for PID in $PIDS ; do
jstack $PID > $DATE_DIR/jstack-$PID.dump 2>&1
echo -e ".\c"
jinfo $PID > $DATE_DIR/jinfo-$PID.dump 2>&1
echo -e ".\c"
jstat -gcutil $PID > $DATE_DIR/jstat-gcutil-$PID.dump 2>&1
echo -e ".\c"
jstat -gccapacity $PID > $DATE_DIR/jstat-gccapacity-$PID.dump 2>&1
echo -e ".\c"
jmap $PID > $DATE_DIR/jmap-$PID.dump 2>&1
echo -e ".\c"
jmap -heap $PID > $DATE_DIR/jmap-heap-$PID.dump 2>&1
echo -e ".\c"
jmap -histo $PID > $DATE_DIR/jmap-histo-$PID.dump 2>&1
echo -e ".\c"
if [ -r /usr/sbin/lsof ]; then
/usr/sbin/lsof -p $PID > $DATE_DIR/lsof-$PID.dump
echo -e ".\c"
fi
done
if [ -r /bin/netstat ]; then
/bin/netstat -an > $DATE_DIR/netstat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/iostat ]; then
/usr/bin/iostat > $DATE_DIR/iostat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/mpstat ]; then
/usr/bin/mpstat > $DATE_DIR/mpstat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/vmstat ]; then
/usr/bin/vmstat > $DATE_DIR/vmstat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/free ]; then
/usr/bin/free -t > $DATE_DIR/free.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/sar ]; then
/usr/bin/sar > $DATE_DIR/sar.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/uptime ]; then
/usr/bin/uptime > $DATE_DIR/uptime.dump 2>&1
echo -e ".\c"
fi
echo "OK!"
echo "DUMP: $DATE_DIR"
#!/bin/bash
cd `dirname $0`
./stop.sh $1
./start.sh $1
#!/bin/bash
source ~/.bashrc
DEPLOY_DIR='/usr/local/'
SERVER_NAME='weChat-market'
PIDS=`ps -f | grep java | grep "$SERVER_NAME" |awk '{print $2}'`
if [ -n "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME already started!"
echo "PID: $PIDS"
exit 1
fi
JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true "
JAVA_DEBUG_OPTS=""
if [ "$1" = "debug" ]; then
JAVA_DEBUG_OPTS=" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n "
fi
JAVA_JMX_OPTS=""
if [ "$1" = "jmx" ]; then
JAVA_JMX_OPTS=" -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false "
fi
JAVA_MEM_OPTS=""
BITS=`java -version 2>&1 | grep -i 64-bit`
JAVA_MEM_OPTS=" -server -Xmx1024M -Xms1024M -Xmn512M -XX:MaxMetaspaceSize=128M -XX:MetaspaceSize=128M -XX:+UseConcMarkSweepGC -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 -XX:+ExplicitGCInvokesConcurrentAndUnloadsClasses -XX:+CMSClassUnloadingEnabled -XX:+ParallelRefProcEnabled -XX:+CMSScavengeBeforeRemark -XX:+UseFastAccessorMethods -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -Xloggc:/var/log/$SERVER_NAME/gc.log"
echo -e "Starting the $SERVER_NAME ...\c"
nohup java -jar $JAVA_OPTS $JAVA_MEM_OPTS $JAVA_DEBUG_OPTS $JAVA_JMX_OPTS $DEPLOY_DIR$SERVER_NAME.jar > nohup.out &
echo "OK!"
PIDS=`ps -f | grep java | grep "$SERVER_NAME" | awk '{print $2}'`
echo "PID: $PIDS"
#!/bin/bash
source ~/.bashrc
DEPLOY_DIR='/usr/local/'
SERVER_NAME='weChat-market'
PIDS=`ps -ef | grep java | grep "$SERVER_NAME" |awk '{print $2}'`
if [ -z "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME does not started!"
exit 1
fi
if [ "$1" != "skip" ]; then
$DEPLOY_DIR/bin/$SERVER_NAME/dump.sh
fi
echo -e "Stopping the $SERVER_NAME ...\c"
for PID in $PIDS ; do
kill $PID > /dev/null 2>&1
done
COUNT=0
while [ $COUNT -lt 120 ]; do
((COUNT++))
for PID in $PIDS ; do
echo -e ".\c"
PID_EXIST=`ps -ef | grep $PID | grep java |awk '{print $2}'`
if [ -z "$PID_EXIST" ]; then
COUNT=120
break
fi
sleep 1
done
done
echo "OK!"
echo "PID: $PIDS"
/* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */
html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section {
display: block;
}
body {
line-height: 1;
}
ol,
ul {
list-style: none;
}
blockquote,
q {
quotes: none;
}
blockquote:before,
blockquote:after,
q:before,
q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
var hljs=new function(){function l(o){return o.replace(/&/gm,"&amp;").replace(/</gm,"&lt;").replace(/>/gm,"&gt;")}function b(p){for(var o=p.firstChild;o;o=o.nextSibling){if(o.nodeName=="CODE"){return o}if(!(o.nodeType==3&&o.nodeValue.match(/\s+/))){break}}}function h(p,o){return Array.prototype.map.call(p.childNodes,function(q){if(q.nodeType==3){return o?q.nodeValue.replace(/\n/g,""):q.nodeValue}if(q.nodeName=="BR"){return"\n"}return h(q,o)}).join("")}function a(q){var p=(q.className+" "+q.parentNode.className).split(/\s+/);p=p.map(function(r){return r.replace(/^language-/,"")});for(var o=0;o<p.length;o++){if(e[p[o]]||p[o]=="no-highlight"){return p[o]}}}function c(q){var o=[];(function p(r,s){for(var t=r.firstChild;t;t=t.nextSibling){if(t.nodeType==3){s+=t.nodeValue.length}else{if(t.nodeName=="BR"){s+=1}else{if(t.nodeType==1){o.push({event:"start",offset:s,node:t});s=p(t,s);o.push({event:"stop",offset:s,node:t})}}}}return s})(q,0);return o}function j(x,v,w){var p=0;var y="";var r=[];function t(){if(x.length&&v.length){if(x[0].offset!=v[0].offset){return(x[0].offset<v[0].offset)?x:v}else{return v[0].event=="start"?x:v}}else{return x.length?x:v}}function s(A){function z(B){return" "+B.nodeName+'="'+l(B.value)+'"'}return"<"+A.nodeName+Array.prototype.map.call(A.attributes,z).join("")+">"}while(x.length||v.length){var u=t().splice(0,1)[0];y+=l(w.substr(p,u.offset-p));p=u.offset;if(u.event=="start"){y+=s(u.node);r.push(u.node)}else{if(u.event=="stop"){var o,q=r.length;do{q--;o=r[q];y+=("</"+o.nodeName.toLowerCase()+">")}while(o!=u.node);r.splice(q,1);while(q<r.length){y+=s(r[q]);q++}}}}return y+l(w.substr(p))}function f(q){function o(s,r){return RegExp(s,"m"+(q.cI?"i":"")+(r?"g":""))}function p(y,w){if(y.compiled){return}y.compiled=true;var s=[];if(y.k){var r={};function z(A,t){t.split(" ").forEach(function(B){var C=B.split("|");r[C[0]]=[A,C[1]?Number(C[1]):1];s.push(C[0])})}y.lR=o(y.l||hljs.IR,true);if(typeof y.k=="string"){z("keyword",y.k)}else{for(var x in y.k){if(!y.k.hasOwnProperty(x)){continue}z(x,y.k[x])}}y.k=r}if(w){if(y.bWK){y.b="\\b("+s.join("|")+")\\s"}y.bR=o(y.b?y.b:"\\B|\\b");if(!y.e&&!y.eW){y.e="\\B|\\b"}if(y.e){y.eR=o(y.e)}y.tE=y.e||"";if(y.eW&&w.tE){y.tE+=(y.e?"|":"")+w.tE}}if(y.i){y.iR=o(y.i)}if(y.r===undefined){y.r=1}if(!y.c){y.c=[]}for(var v=0;v<y.c.length;v++){if(y.c[v]=="self"){y.c[v]=y}p(y.c[v],y)}if(y.starts){p(y.starts,w)}var u=[];for(var v=0;v<y.c.length;v++){u.push(y.c[v].b)}if(y.tE){u.push(y.tE)}if(y.i){u.push(y.i)}y.t=u.length?o(u.join("|"),true):{exec:function(t){return null}}}p(q)}function d(D,E){function o(r,M){for(var L=0;L<M.c.length;L++){var K=M.c[L].bR.exec(r);if(K&&K.index==0){return M.c[L]}}}function s(K,r){if(K.e&&K.eR.test(r)){return K}if(K.eW){return s(K.parent,r)}}function t(r,K){return K.i&&K.iR.test(r)}function y(L,r){var K=F.cI?r[0].toLowerCase():r[0];return L.k.hasOwnProperty(K)&&L.k[K]}function G(){var K=l(w);if(!A.k){return K}var r="";var N=0;A.lR.lastIndex=0;var L=A.lR.exec(K);while(L){r+=K.substr(N,L.index-N);var M=y(A,L);if(M){v+=M[1];r+='<span class="'+M[0]+'">'+L[0]+"</span>"}else{r+=L[0]}N=A.lR.lastIndex;L=A.lR.exec(K)}return r+K.substr(N)}function z(){if(A.sL&&!e[A.sL]){return l(w)}var r=A.sL?d(A.sL,w):g(w);if(A.r>0){v+=r.keyword_count;B+=r.r}return'<span class="'+r.language+'">'+r.value+"</span>"}function J(){return A.sL!==undefined?z():G()}function I(L,r){var K=L.cN?'<span class="'+L.cN+'">':"";if(L.rB){x+=K;w=""}else{if(L.eB){x+=l(r)+K;w=""}else{x+=K;w=r}}A=Object.create(L,{parent:{value:A}});B+=L.r}function C(K,r){w+=K;if(r===undefined){x+=J();return 0}var L=o(r,A);if(L){x+=J();I(L,r);return L.rB?0:r.length}var M=s(A,r);if(M){if(!(M.rE||M.eE)){w+=r}x+=J();do{if(A.cN){x+="</span>"}A=A.parent}while(A!=M.parent);if(M.eE){x+=l(r)}w="";if(M.starts){I(M.starts,"")}return M.rE?0:r.length}if(t(r,A)){throw"Illegal"}w+=r;return r.length||1}var F=e[D];f(F);var A=F;var w="";var B=0;var v=0;var x="";try{var u,q,p=0;while(true){A.t.lastIndex=p;u=A.t.exec(E);if(!u){break}q=C(E.substr(p,u.index-p),u[0]);p=u.index+q}C(E.substr(p));return{r:B,keyword_count:v,value:x,language:D}}catch(H){if(H=="Illegal"){return{r:0,keyword_count:0,value:l(E)}}else{throw H}}}function g(s){var o={keyword_count:0,r:0,value:l(s)};var q=o;for(var p in e){if(!e.hasOwnProperty(p)){continue}var r=d(p,s);r.language=p;if(r.keyword_count+r.r>q.keyword_count+q.r){q=r}if(r.keyword_count+r.r>o.keyword_count+o.r){q=o;o=r}}if(q.language){o.second_best=q}return o}function i(q,p,o){if(p){q=q.replace(/^((<[^>]+>|\t)+)/gm,function(r,v,u,t){return v.replace(/\t/g,p)})}if(o){q=q.replace(/\n/g,"<br>")}return q}function m(r,u,p){var v=h(r,p);var t=a(r);if(t=="no-highlight"){return}var w=t?d(t,v):g(v);t=w.language;var o=c(r);if(o.length){var q=document.createElement("pre");q.innerHTML=w.value;w.value=j(o,c(q),v)}w.value=i(w.value,u,p);var s=r.className;if(!s.match("(\\s|^)(language-)?"+t+"(\\s|$)")){s=s?(s+" "+t):t}r.innerHTML=w.value;r.className=s;r.result={language:t,kw:w.keyword_count,re:w.r};if(w.second_best){r.second_best={language:w.second_best.language,kw:w.second_best.keyword_count,re:w.second_best.r}}}function n(){if(n.called){return}n.called=true;Array.prototype.map.call(document.getElementsByTagName("pre"),b).filter(Boolean).forEach(function(o){m(o,hljs.tabReplace)})}function k(){window.addEventListener("DOMContentLoaded",n,false);window.addEventListener("load",n,false)}var e={};this.LANGUAGES=e;this.highlight=d;this.highlightAuto=g;this.fixMarkup=i;this.highlightBlock=m;this.initHighlighting=n;this.initHighlightingOnLoad=k;this.IR="[a-zA-Z][a-zA-Z0-9_]*";this.UIR="[a-zA-Z_][a-zA-Z0-9_]*";this.NR="\\b\\d+(\\.\\d+)?";this.CNR="(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";this.BNR="\\b(0b[01]+)";this.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|\\.|-|-=|/|/=|:|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";this.BE={b:"\\\\[\\s\\S]",r:0};this.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[this.BE],r:0};this.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[this.BE],r:0};this.CLCM={cN:"comment",b:"//",e:"$"};this.CBLCLM={cN:"comment",b:"/\\*",e:"\\*/"};this.HCM={cN:"comment",b:"#",e:"$"};this.NM={cN:"number",b:this.NR,r:0};this.CNM={cN:"number",b:this.CNR,r:0};this.BNM={cN:"number",b:this.BNR,r:0};this.inherit=function(q,r){var o={};for(var p in q){o[p]=q[p]}if(r){for(var p in r){o[p]=r[p]}}return o}}();hljs.LANGUAGES.xml=function(a){var c="[A-Za-z0-9\\._:-]+";var b={eW:true,c:[{cN:"attribute",b:c,r:0},{b:'="',rB:true,e:'"',c:[{cN:"value",b:'"',eW:true}]},{b:"='",rB:true,e:"'",c:[{cN:"value",b:"'",eW:true}]},{b:"=",c:[{cN:"value",b:"[^\\s/>]+"}]}]};return{cI:true,c:[{cN:"pi",b:"<\\?",e:"\\?>",r:10},{cN:"doctype",b:"<!DOCTYPE",e:">",r:10,c:[{b:"\\[",e:"\\]"}]},{cN:"comment",b:"<!--",e:"-->",r:10},{cN:"cdata",b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{cN:"tag",b:"<style(?=\\s|>|$)",e:">",k:{title:"style"},c:[b],starts:{e:"</style>",rE:true,sL:"css"}},{cN:"tag",b:"<script(?=\\s|>|$)",e:">",k:{title:"script"},c:[b],starts:{e:"<\/script>",rE:true,sL:"javascript"}},{b:"<%",e:"%>",sL:"vbscript"},{cN:"tag",b:"</?",e:"/?>",c:[{cN:"title",b:"[^ />]+"},b]}]}}(hljs);hljs.LANGUAGES.json=function(a){var e={literal:"true false null"};var d=[a.QSM,a.CNM];var c={cN:"value",e:",",eW:true,eE:true,c:d,k:e};var b={b:"{",e:"}",c:[{cN:"attribute",b:'\\s*"',e:'"\\s*:\\s*',eB:true,eE:true,c:[a.BE],i:"\\n",starts:c}],i:"\\S"};var f={b:"\\[",e:"\\]",c:[a.inherit(c,{cN:null})],i:"\\S"};d.splice(d.length,0,b,f);return{c:d,k:e,i:"\\S"}}(hljs);
\ No newline at end of file
This diff is collapsed.
/*
* jQuery BBQ: Back Button & Query Library - v1.2.1 - 2/17/2010
* http://benalman.com/projects/jquery-bbq-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function($,p){var i,m=Array.prototype.slice,r=decodeURIComponent,a=$.param,c,l,v,b=$.bbq=$.bbq||{},q,u,j,e=$.event.special,d="hashchange",A="querystring",D="fragment",y="elemUrlAttr",g="location",k="href",t="src",x=/^.*\?|#.*$/g,w=/^.*\#/,h,C={};function E(F){return typeof F==="string"}function B(G){var F=m.call(arguments,1);return function(){return G.apply(this,F.concat(m.call(arguments)))}}function n(F){return F.replace(/^[^#]*#?(.*)$/,"$1")}function o(F){return F.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}function f(H,M,F,I,G){var O,L,K,N,J;if(I!==i){K=F.match(H?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);J=K[3]||"";if(G===2&&E(I)){L=I.replace(H?w:x,"")}else{N=l(K[2]);I=E(I)?l[H?D:A](I):I;L=G===2?I:G===1?$.extend({},I,N):$.extend({},N,I);L=a(L);if(H){L=L.replace(h,r)}}O=K[1]+(H?"#":L||!K[1]?"?":"")+L+J}else{O=M(F!==i?F:p[g][k])}return O}a[A]=B(f,0,o);a[D]=c=B(f,1,n);c.noEscape=function(G){G=G||"";var F=$.map(G.split(""),encodeURIComponent);h=new RegExp(F.join("|"),"g")};c.noEscape(",/");$.deparam=l=function(I,F){var H={},G={"true":!0,"false":!1,"null":null};$.each(I.replace(/\+/g," ").split("&"),function(L,Q){var K=Q.split("="),P=r(K[0]),J,O=H,M=0,R=P.split("]["),N=R.length-1;if(/\[/.test(R[0])&&/\]$/.test(R[N])){R[N]=R[N].replace(/\]$/,"");R=R.shift().split("[").concat(R);N=R.length-1}else{N=0}if(K.length===2){J=r(K[1]);if(F){J=J&&!isNaN(J)?+J:J==="undefined"?i:G[J]!==i?G[J]:J}if(N){for(;M<=N;M++){P=R[M]===""?O.length:R[M];O=O[P]=M<N?O[P]||(R[M+1]&&isNaN(R[M+1])?{}:[]):J}}else{if($.isArray(H[P])){H[P].push(J)}else{if(H[P]!==i){H[P]=[H[P],J]}else{H[P]=J}}}}else{if(P){H[P]=F?i:""}}});return H};function z(H,F,G){if(F===i||typeof F==="boolean"){G=F;F=a[H?D:A]()}else{F=E(F)?F.replace(H?w:x,""):F}return l(F,G)}l[A]=B(z,0);l[D]=v=B(z,1);$[y]||($[y]=function(F){return $.extend(C,F)})({a:k,base:k,iframe:t,img:t,input:t,form:"action",link:k,script:t});j=$[y];function s(I,G,H,F){if(!E(H)&&typeof H!=="object"){F=H;H=G;G=i}return this.each(function(){var L=$(this),J=G||j()[(this.nodeName||"").toLowerCase()]||"",K=J&&L.attr(J)||"";L.attr(J,a[I](K,H,F))})}$.fn[A]=B(s,A);$.fn[D]=B(s,D);b.pushState=q=function(I,F){if(E(I)&&/^#/.test(I)&&F===i){F=2}var H=I!==i,G=c(p[g][k],H?I:{},H?F:2);p[g][k]=G+(/#/.test(G)?"":"#")};b.getState=u=function(F,G){return F===i||typeof F==="boolean"?v(F):v(G)[F]};b.removeState=function(F){var G={};if(F!==i){G=u();$.each($.isArray(F)?F:arguments,function(I,H){delete G[H]})}q(G,2)};e[d]=$.extend(e[d],{add:function(F){var H;function G(J){var I=J[D]=c();J.getState=function(K,L){return K===i||typeof K==="boolean"?l(I,K):l(I,L)[K]};H.apply(this,arguments)}if($.isFunction(F)){H=F;return G}else{H=F.handler;F.handler=G}}})})(jQuery,this);
/*
* jQuery hashchange event - v1.2 - 2/11/2010
* http://benalman.com/projects/jquery-hashchange-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function($,i,b){var j,k=$.event.special,c="location",d="hashchange",l="href",f=$.browser,g=document.documentMode,h=f.msie&&(g===b||g<8),e="on"+d in i&&!h;function a(m){m=m||i[c][l];return m.replace(/^[^#]*#?(.*)$/,"$1")}$[d+"Delay"]=100;k[d]=$.extend(k[d],{setup:function(){if(e){return false}$(j.start)},teardown:function(){if(e){return false}$(j.stop)}});j=(function(){var m={},r,n,o,q;function p(){o=q=function(s){return s};if(h){n=$('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this);
\ No newline at end of file
(function(b){b.fn.slideto=function(a){a=b.extend({slide_duration:"slow",highlight_duration:3E3,highlight:true,highlight_color:"#FFFF99"},a);return this.each(function(){obj=b(this);b("body").animate({scrollTop:obj.offset().top},a.slide_duration,function(){a.highlight&&b.ui.version&&obj.effect("highlight",{color:a.highlight_color},a.highlight_duration)})})}})(jQuery);
/*
jQuery Wiggle
Author: WonderGroup, Jordan Thomas
URL: http://labs.wondergroup.com/demos/mini-ui/index.html
License: MIT (http://en.wikipedia.org/wiki/MIT_License)
*/
jQuery.fn.wiggle=function(o){var d={speed:50,wiggles:3,travel:5,callback:null};var o=jQuery.extend(d,o);return this.each(function(){var cache=this;var wrap=jQuery(this).wrap('<div class="wiggle-wrap"></div>').css("position","relative");var calls=0;for(i=1;i<=o.wiggles;i++){jQuery(this).animate({left:"-="+o.travel},o.speed).animate({left:"+="+o.travel*2},o.speed*2).animate({left:"-="+o.travel},o.speed,function(){calls++;if(jQuery(cache).parent().hasClass('wiggle-wrap')){jQuery(cache).parent().replaceWith(cache);}
if(calls==o.wiggles&&jQuery.isFunction(o.callback)){o.callback();}});}});};
\ No newline at end of file
This diff is collapsed.
// The purpose of the `Content` object is to abstract away the data conversions
// to and from raw content entities as strings. For example, you want to be able
// to pass in a Javascript object and have it be automatically converted into a
// JSON string if the `content-type` is set to a JSON-based media type.
// Conversely, you want to be able to transparently get back a Javascript object
// in the response if the `content-type` is a JSON-based media-type.
// One limitation of the current implementation is that it [assumes the `charset` is UTF-8](https://github.com/spire-io/shred/issues/5).
// The `Content` constructor takes an options object, which *must* have either a
// `body` or `data` property and *may* have a `type` property indicating the
// media type. If there is no `type` attribute, a default will be inferred.
var Content = function(options) {
this.body = options.body;
this.data = options.data;
this.type = options.type;
};
Content.prototype = {
// Treat `toString()` as asking for the `content.body`. That is, the raw content entity.
//
// toString: function() { return this.body; }
//
// Commented out, but I've forgotten why. :/
};
// `Content` objects have the following attributes:
Object.defineProperties(Content.prototype,{
// - **type**. Typically accessed as `content.type`, reflects the `content-type`
// header associated with the request or response. If not passed as an options
// to the constructor or set explicitly, it will infer the type the `data`
// attribute, if possible, and, failing that, will default to `text/plain`.
type: {
get: function() {
if (this._type) {
return this._type;
} else {
if (this._data) {
switch(typeof this._data) {
case "string": return "text/plain";
case "object": return "application/json";
}
}
}
return "text/plain";
},
set: function(value) {
this._type = value;
return this;
},
enumerable: true
},
// - **data**. Typically accessed as `content.data`, reflects the content entity
// converted into Javascript data. This can be a string, if the `type` is, say,
// `text/plain`, but can also be a Javascript object. The conversion applied is
// based on the `processor` attribute. The `data` attribute can also be set
// directly, in which case the conversion will be done the other way, to infer
// the `body` attribute.
data: {
get: function() {
if (this._body) {
return this.processor.parser(this._body);
} else {
return this._data;
}
},
set: function(data) {
if (this._body&&data) Errors.setDataWithBody(this);
this._data = data;
return this;
},
enumerable: true
},
// - **body**. Typically accessed as `content.body`, reflects the content entity
// as a UTF-8 string. It is the mirror of the `data` attribute. If you set the
// `data` attribute, the `body` attribute will be inferred and vice-versa. If
// you attempt to set both, an exception is raised.
body: {
get: function() {
if (this._data) {
return this.processor.stringify(this._data);
} else {
return this._body.toString();
}
},
set: function(body) {
if (this._data&&body) Errors.setBodyWithData(this);
this._body = body;
return this;
},
enumerable: true
},
// - **processor**. The functions that will be used to convert to/from `data` and
// `body` attributes. You can add processors. The two that are built-in are for
// `text/plain`, which is basically an identity transformation and
// `application/json` and other JSON-based media types (including custom media
// types with `+json`). You can add your own processors. See below.
processor: {
get: function() {
var processor = Content.processors[this.type];
if (processor) {
return processor;
} else {
// Return the first processor that matches any part of the
// content type. ex: application/vnd.foobar.baz+json will match json.
var main = this.type.split(";")[0];
var parts = main.split(/\+|\//);
for (var i=0, l=parts.length; i < l; i++) {
processor = Content.processors[parts[i]]
}
return processor || {parser:identity,stringify:toString};
}
},
enumerable: true
},
// - **length**. Typically accessed as `content.length`, returns the length in
// bytes of the raw content entity.
length: {
get: function() {
if (typeof Buffer !== 'undefined') {
return Buffer.byteLength(this.body);
}
return this.body.length;
}
}
});
Content.processors = {};
// The `registerProcessor` function allows you to add your own processors to
// convert content entities. Each processor consists of a Javascript object with
// two properties:
// - **parser**. The function used to parse a raw content entity and convert it
// into a Javascript data type.
// - **stringify**. The function used to convert a Javascript data type into a
// raw content entity.
Content.registerProcessor = function(types,processor) {
// You can pass an array of types that will trigger this processor, or just one.
// We determine the array via duck-typing here.
if (types.forEach) {
types.forEach(function(type) {
Content.processors[type] = processor;
});
} else {
// If you didn't pass an array, we just use what you pass in.
Content.processors[types] = processor;
}
};
// Register the identity processor, which is used for text-based media types.
var identity = function(x) { return x; }
, toString = function(x) { return x.toString(); }
Content.registerProcessor(
["text/html","text/plain","text"],
{ parser: identity, stringify: toString });
// Register the JSON processor, which is used for JSON-based media types.
Content.registerProcessor(
["application/json; charset=utf-8","application/json","json"],
{
parser: function(string) {
return JSON.parse(string);
},
stringify: function(data) {
return JSON.stringify(data); }});
var qs = require('querystring');
// Register the post processor, which is used for JSON-based media types.
Content.registerProcessor(
["application/x-www-form-urlencoded"],
{ parser : qs.parse, stringify : qs.stringify });
// Error functions are defined separately here in an attempt to make the code
// easier to read.
var Errors = {
setDataWithBody: function(object) {
throw new Error("Attempt to set data attribute of a content object " +
"when the body attributes was already set.");
},
setBodyWithData: function(object) {
throw new Error("Attempt to set body attribute of a content object " +
"when the data attributes was already set.");
}
}
module.exports = Content;
\ No newline at end of file
var appName;
var popupMask;
var popupDialog;
var clientId;
var realm;
function handleLogin() {
var scopes = [];
if(window.swaggerUi.api.authSchemes
&& window.swaggerUi.api.authSchemes.oauth2
&& window.swaggerUi.api.authSchemes.oauth2.scopes) {
scopes = window.swaggerUi.api.authSchemes.oauth2.scopes;
}
if(window.swaggerUi.api
&& window.swaggerUi.api.info) {
appName = window.swaggerUi.api.info.title;
}
if(popupDialog.length > 0)
popupDialog = popupDialog.last();
else {
popupDialog = $(
[
'<div class="api-popup-dialog">',
'<div class="api-popup-title">Select OAuth2.0 Scopes</div>',
'<div class="api-popup-content">',
'<p>Scopes are used to grant an application different levels of access to data on behalf of the end user. Each API may declare one or more scopes.',
'<a href="#">Learn how to use</a>',
'</p>',
'<p><strong>' + appName + '</strong> API requires the following scopes. Select which ones you want to grant to Swagger UI.</p>',
'<ul class="api-popup-scopes">',
'</ul>',
'<p class="error-msg"></p>',
'<div class="api-popup-actions"><button class="api-popup-authbtn api-button green" type="button">Authorize</button><button class="api-popup-cancel api-button gray" type="button">Cancel</button></div>',
'</div>',
'</div>'].join(''));
$(document.body).append(popupDialog);
popup = popupDialog.find('ul.api-popup-scopes').empty();
for (i = 0; i < scopes.length; i ++) {
scope = scopes[i];
str = '<li><input type="checkbox" id="scope_' + i + '" scope="' + scope.scope + '"/>' + '<label for="scope_' + i + '">' + scope.scope;
if (scope.description) {
str += '<br/><span class="api-scope-desc">' + scope.description + '</span>';
}
str += '</label></li>';
popup.append(str);
}
}
var $win = $(window),
dw = $win.width(),
dh = $win.height(),
st = $win.scrollTop(),
dlgWd = popupDialog.outerWidth(),
dlgHt = popupDialog.outerHeight(),
top = (dh -dlgHt)/2 + st,
left = (dw - dlgWd)/2;
popupDialog.css({
top: (top < 0? 0 : top) + 'px',
left: (left < 0? 0 : left) + 'px'
});
popupDialog.find('button.api-popup-cancel').click(function() {
popupMask.hide();
popupDialog.hide();
});
popupDialog.find('button.api-popup-authbtn').click(function() {
popupMask.hide();
popupDialog.hide();
var authSchemes = window.swaggerUi.api.authSchemes;
var host = window.location;
var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/"));
var redirectUrl = host.protocol + '//' + host.host + pathname + "/o2c.html";
var url = null;
for (var key in authSchemes) {
if (authSchemes.hasOwnProperty(key)) {
var o = authSchemes[key].grantTypes;
for(var t in o) {
if(o.hasOwnProperty(t) && t === 'implicit') {
var dets = o[t];
url = dets.loginEndpoint.url + "?response_type=token";
window.swaggerUi.tokenName = dets.tokenName;
}
}
}
}
var scopes = []
var o = $('.api-popup-scopes').find('input:checked');
for(k =0; k < o.length; k++) {
scopes.push($(o[k]).attr("scope"));
}
window.enabledScopes=scopes;
url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
url += '&realm=' + encodeURIComponent(realm);
url += '&client_id=' + encodeURIComponent(clientId);
url += '&scope=' + encodeURIComponent(scopes);
window.open(url);
});
popupMask.show();
popupDialog.show();
return;
}
function handleLogout() {
for(key in window.authorizations.authz){
window.authorizations.remove(key)
}
window.enabledScopes = null;
$('.api-ic.ic-on').addClass('ic-off');
$('.api-ic.ic-on').removeClass('ic-on');
// set the info box
$('.api-ic.ic-warning').addClass('ic-error');
$('.api-ic.ic-warning').removeClass('ic-warning');
}
function initOAuth(opts) {
var o = (opts||{});
var errors = [];
appName = (o.appName||errors.push("missing appName"));
popupMask = (o.popupMask||$('#api-common-mask'));
popupDialog = (o.popupDialog||$('.api-popup-dialog'));
clientId = (o.clientId||errors.push("missing client id"));
realm = (o.realm||errors.push("missing realm"));
if(errors.length > 0){
log("auth unable initialize oauth: " + errors);
return;
}
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
$('.api-ic').click(function(s) {
if($(s.target).hasClass('ic-off'))
handleLogin();
else {
handleLogout();
}
false;
});
}
function onOAuthComplete(token) {
if(token) {
if(token.error) {
var checkbox = $('input[type=checkbox],.secured')
checkbox.each(function(pos){
checkbox[pos].checked = false;
});
alert(token.error);
}
else {
var b = token[window.swaggerUi.tokenName];
if(b){
// if all roles are satisfied
var o = null;
$.each($('.auth #api_information_panel'), function(k, v) {
var children = v;
if(children && children.childNodes) {
var requiredScopes = [];
$.each((children.childNodes), function (k1, v1){
var inner = v1.innerHTML;
if(inner)
requiredScopes.push(inner);
});
var diff = [];
for(var i=0; i < requiredScopes.length; i++) {
var s = requiredScopes[i];
if(window.enabledScopes && window.enabledScopes.indexOf(s) == -1) {
diff.push(s);
}
}
if(diff.length > 0){
o = v.parentNode;
$(o.parentNode).find('.api-ic.ic-on').addClass('ic-off');
$(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on');
// sorry, not all scopes are satisfied
$(o).find('.api-ic').addClass('ic-warning');
$(o).find('.api-ic').removeClass('ic-error');
}
else {
o = v.parentNode;
$(o.parentNode).find('.api-ic.ic-off').addClass('ic-on');
$(o.parentNode).find('.api-ic.ic-off').removeClass('ic-off');
// all scopes are satisfied
$(o).find('.api-ic').addClass('ic-info');
$(o).find('.api-ic').removeClass('ic-warning');
$(o).find('.api-ic').removeClass('ic-error');
}
}
});
window.authorizations.add("oauth2", new ApiKeyAuthorization("Authorization", "Bearer " + b, "header"));
}
}
}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<!DOCTYPE html>
<html>
<head>
<title>team</title>
<link href='api-static/css/reset.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='api-static/css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
<link href='api-static/css/reset.css' media='print' rel='stylesheet' type='text/css'/>
<link href='api-static/css/screen.css' media='print' rel='stylesheet' type='text/css'/>
<script src="api-static/lib/shred.bundle.js" type="text/javascript"></script>
<script src='api-static/lib/jquery-1.8.0.min.js' type='text/javascript'></script>
<script src='api-static/lib/jquery.slideto.min.js' type='text/javascript'></script>
<script src='api-static/lib/jquery.wiggle.min.js' type='text/javascript'></script>
<script src='api-static/lib/jquery.ba-bbq.min.js' type='text/javascript'></script>
<script src='api-static/lib/handlebars-1.0.0.js' type='text/javascript'></script>
<script src='api-static/lib/underscore-min.js' type='text/javascript'></script>
<script src='api-static/lib/backbone-min.js' type='text/javascript'></script>
<script src='api-static/lib/swagger.js' type='text/javascript'></script>
<script src='api-static/swagger-ui.js' type='text/javascript'></script>
<script src='api-static/lib/highlight.7.3.pack.js' type='text/javascript'></script>
<script type="text/javascript">
$(function () {
window.swaggerUi = new SwaggerUi({
url: "/weChat-market/api-docs",
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
onComplete: function(swaggerApi, swaggerUi){
log("Loaded SwaggerUI");
if(typeof initOAuth == "function") {
}
$('pre code').each(function(i, e) {
hljs.highlightBlock(e)
});
},
onFailure: function(data) {
log("Unable to Load SwaggerUI");
},
docExpansion: "none",
sorter : "alpha"
});
$('#input_apiKey').change(function() {
var key = $('#input_apiKey')[0].value;
log("key: " + key);
if(key && key.trim() != "") {
log("added key " + key);
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query"));
}
})
window.swaggerUi.load();
});
</script>
</head>
<body class="swagger-section">
<div id='header'>
<div class="swagger-ui-wrap">
<a id="logo" href="#">opensesame</a>
<form id='api_selector'>
<div class='input'><input placeholder="#" id="input_baseUrl" name="baseUrl" type="text"/></div>
<div class='input'><input placeholder="api_key" id="input_apiKey" name="apiKey" type="text"/></div>
<div class='input'><a id="explore" href="#">Explore</a></div>
</form>
</div>
</div>
<div id="message-bar" class="swagger-ui-wrap">&nbsp;</div>
<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
</body>
</html>
<script>
var qp = null;
if(window.location.hash) {
qp = location.hash.substring(1);
}
else {
qp = location.search.substring(1);
}
qp = qp ? JSON.parse('{"' + qp.replace(/&/g, '","').replace(/=/g,'":"') + '"}',
function(key, value) {
return key===""?value:decodeURIComponent(value) }
):{}
window.opener.onOAuthComplete(qp);
window.close();
</script>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment