Commit dcd0a502 authored by xiaoyao's avatar xiaoyao

fix

parent e627dfb9

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.jbp</groupId>
<artifactId>sph_system</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>admin-api</artifactId>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>com.jbp</groupId>
<artifactId>core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.jbp</groupId>
<artifactId>dao</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-miniapp</artifactId>
</dependency>
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring-boot-web-starter</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>4.5.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
<!--增加jvm参数-->
<jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
package com.jbp.admin.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ ElementType.TYPE, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
public @interface RequiresPermissionsDesc {
String[] menu();
String button();
}
package com.jbp.admin.api;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
* 管理后台服务启动类
*
* @author xuebaoyu
* @QQ:1197673878
*/
@SpringBootApplication(scanBasePackages = { "com.wwdz.ch.db", "com.wwdz.ch.core",
"com.wwdz.ch.admin" })
@MapperScan({ "com.wwdz.ch.db.dao", "com.wwdz.ch.db.dao.ex" })
@EnableTransactionManagement
@EnableScheduling
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
\ No newline at end of file
package com.jbp.admin.config;
import java.util.LinkedHashMap;
import java.util.Map;
import com.jbp.admin.shiro.AdminAuthorizingRealm;
import com.jbp.admin.shiro.AdminWebSessionManager;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.realm.Realm;
import org.apache.shiro.session.mgt.SessionManager;
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
@Configuration
public class ShiroConfig {
@Bean
public Realm realm() {
return new AdminAuthorizingRealm();
}
@Bean
public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) {
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
shiroFilterFactoryBean.setSecurityManager(securityManager);
Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>();
filterChainDefinitionMap.put("/admin/auth/login", "anon");
filterChainDefinitionMap.put("/admin/auth/captchaImage", "anon");
filterChainDefinitionMap.put("/admin/auth/401", "anon");
filterChainDefinitionMap.put("/admin/auth/index", "anon");
filterChainDefinitionMap.put("/admin/auth/403", "anon");
filterChainDefinitionMap.put("/admin/**", "authc");
shiroFilterFactoryBean.setLoginUrl("/admin/auth/401");
shiroFilterFactoryBean.setSuccessUrl("/admin/auth/index");
shiroFilterFactoryBean.setUnauthorizedUrl("/admin/auth/403");
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
return shiroFilterFactoryBean;
}
@Bean
public SessionManager sessionManager() {
AdminWebSessionManager mySessionManager = new AdminWebSessionManager();
return mySessionManager;
}
@Bean
public DefaultWebSecurityManager securityManager() {
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
securityManager.setRealm(realm());
securityManager.setSessionManager(sessionManager());
return securityManager;
}
@Bean
public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) {
AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor();
authorizationAttributeSourceAdvisor.setSecurityManager(securityManager);
return authorizationAttributeSourceAdvisor;
}
@Bean
@DependsOn("lifecycleBeanPostProcessor")
public static DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
DefaultAdvisorAutoProxyCreator creator = new DefaultAdvisorAutoProxyCreator();
creator.setProxyTargetClass(true);
return creator;
}
}
package com.jbp.admin.config;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authz.AuthorizationException;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import com.jbp.core.util.ResponseUtil;
@ControllerAdvice
@Order(value = Ordered.HIGHEST_PRECEDENCE)
public class ShiroExceptionHandler {
@ExceptionHandler(AuthenticationException.class)
@ResponseBody
public Object unauthenticatedHandler(AuthenticationException e) {
e.printStackTrace();
return ResponseUtil.unlogin();
}
@ExceptionHandler(AuthorizationException.class)
@ResponseBody
public Object unauthorizedHandler(AuthorizationException e) {
e.printStackTrace();
return ResponseUtil.unauthz();
}
}
package com.jbp.admin.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.ArrayList;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket docket(Environment environment) {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
//指定包名 basePackage
.apis(RequestHandlerSelectors.basePackage("com.wwdz.ch.admin.web"))
//再次过滤(根据接口过滤)
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
//contact 维护接口人信息
Contact contact = new Contact("xiaoyao", "", "");
return new ApiInfo(
//标题
"泉库后端文档",
//描述
"增加注释,实时更新,在线测试",
//版本
"v1.0",
//服务条款网址
"urn:tos",
//维护人信息
contact,
//许可
"Apache 2.0",
//许可链接
"http://www.apache.org/licenses/LICENSE-2.0",
new ArrayList());
}
}
package com.jbp.admin.dao;
import java.io.Serializable;
import java.math.BigDecimal;
public class AccountVo implements Serializable {
private static final long serialVersionUID = 1567048369574496965L;
private Integer userId;
private BigDecimal remainAmount;
private BigDecimal totalAmount;
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public BigDecimal getRemainAmount() {
return remainAmount;
}
public void setRemainAmount(BigDecimal remainAmount) {
this.remainAmount = remainAmount;
}
public BigDecimal getTotalAmount() {
return totalAmount;
}
public void setTotalAmount(BigDecimal totalAmount) {
this.totalAmount = totalAmount;
}
}
package com.jbp.admin.dao;
import com.qiniu.util.StringUtils;
import com.jbp.db.domain.BidRecord;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
@ApiModel(value = "BidRecordVo", description = "成交记录前端交互VO")
public class BidRecordVo implements Serializable {
private static final long serialVersionUID = 4014894220574552837L;
@ApiModelProperty(value = "成交记录id", name = "id")
private Long id;
@ApiModelProperty(value = "购买人", name = "buyer")
private String buyer;
@ApiModelProperty(value = "购买平台", name = "platform")
private String platform;
@ApiModelProperty(value = "分类Id", name = "cid")
private Integer cid;
@ApiModelProperty(value = "图片", name = "images")
private List<String> images;
@ApiModelProperty(value = "成交时间", name = "bidtime")
private Integer bidtime;
@ApiModelProperty(value = "成交价格", name = "price")
private Long price;
public BidRecord toDo() {
BidRecord record = new BidRecord();
record.setBidtime(bidtime);
record.setBuyer(buyer);
record.setIsDeleted(false);
record.setCid(cid);
record.setImages(StringUtils.join(images, ";"));
record.setPlatform(platform);
record.setPrice(price);
record.setExtra("");
record.setLink("");
return record;
}
public BidRecordVo() {}
public BidRecordVo(BidRecord record) {
this.id = record.getId();
this.cid = record.getCid();
this.images = Arrays.asList(record.getImages().split(";"));
this.bidtime = record.getBidtime();
this.price = record.getPrice();
this.buyer = record.getBuyer();
this.platform = record.getPlatform();
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getBuyer() {
return buyer;
}
public void setBuyer(String buyer) {
this.buyer = buyer;
}
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform;
}
public Integer getCid() {
return cid;
}
public void setCid(Integer cid) {
this.cid = cid;
}
public List<String> getImages() {
return images;
}
public void setImages(List<String> images) {
this.images = images;
}
public Integer getBidtime() {
return bidtime;
}
public void setBidtime(Integer bidtime) {
this.bidtime = bidtime;
}
public Long getPrice() {
return price;
}
public void setPrice(Long price) {
this.price = price;
}
}
package com.jbp.admin.dao;
import java.io.Serializable;
import java.util.List;
import com.jbp.db.bean.CategorySellAmts;
public class CategorySellVo implements Serializable{
private static final long serialVersionUID = 96458407347975166L;
private String[] categoryNames;//一级大类目录名称
private List<CategorySellAmts> categorySellData;//大类销售金额集合
public String[] getCategoryNames() {
return categoryNames;
}
public void setCategoryNames(String[] categoryNames) {
this.categoryNames = categoryNames;
}
public List<CategorySellAmts> getCategorySellData() {
return categorySellData;
}
public void setCategorySellData(List<CategorySellAmts> categorySellData) {
this.categorySellData = categorySellData;
}
}
package com.jbp.admin.dao;
import com.alibaba.druid.support.json.JSONUtils;
import com.jbp.db.domain.Category;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.util.StringUtils;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ApiModel
public class CategoryVo implements Serializable {
private static final long serialVersionUID = 96458407347975312L;
@ApiModelProperty(value = "分类Id")
private Integer id;
@ApiModelProperty(value = "分类名称")
private String name;
@ApiModelProperty(value = "分类图片")
private String icon;
@ApiModelProperty(value = "父类目ID")
private Integer pid;
@ApiModelProperty(value = "层级")
private Integer level;
@ApiModelProperty(value = "描述")
private String desc;
@ApiModelProperty(value = "面值")
private String parValue;
@ApiModelProperty(value = "命名来源")
private String nameSrc;
@ApiModelProperty(value = "造币厂")
private String mint;
@ApiModelProperty(value = "铸造时间")
private String publishTime;
@ApiModelProperty(value = "铸造者")
private String publisher;
@ApiModelProperty(value = "王朝")
private String dynasty;
@ApiModelProperty(value = "品种代码")
private String serialNo;
@ApiModelProperty(value = "分类路径")
private String categoryPath;
@ApiModelProperty(value = "扩展名称")
private String extendName;
@ApiModelProperty(value = "材质")
private String material;
@ApiModelProperty(value = "直径 (mm * 100)")
private Integer diameter;
@ApiModelProperty(value = " 厚度 (mm * 100)")
private Integer thickness;
@ApiModelProperty(value = "重量 (g * 100)")
private Integer weight;
@ApiModelProperty(value = "合金成分分析表图片路径")
private String caTableImage;
@ApiModelProperty(value = "是否叶子节点")
private Boolean isLeaf;
@ApiModelProperty(value = "存世量")
private Integer exiQuantity;
/**
* 子类目
*/
private List<CategoryVo> children;
public String getCaTableImage() {
return caTableImage;
}
public void setCaTableImage(String caTableImage) {
this.caTableImage = caTableImage;
}
public Boolean getLeaf() {
return isLeaf;
}
public void setLeaf(Boolean leaf) {
isLeaf = leaf;
}
public String getParValue() {
return parValue;
}
public void setParValue(String parValue) {
this.parValue = parValue;
}
public String getNameSrc() {
return nameSrc;
}
public void setNameSrc(String nameSrc) {
this.nameSrc = nameSrc;
}
public String getMint() {
return mint;
}
public void setMint(String mint) {
this.mint = mint;
}
public String getMaterial() {
return material;
}
public void setMaterial(String material) {
this.material = material;
}
public CategoryVo(){}
public CategoryVo(Category category) {
this.id = category.getId();
this.name = category.getName();
this.icon = category.getIcon();
this.pid = category.getPid();
this.desc = category.getDesc();
this.level = category.getLevel();
this.isLeaf = category.getIsLeaf();
if (!StringUtils.isEmpty(category.getExtra())) {
Map<String, Object> extraData = (Map<String, Object>) JSONUtils.parse(category.getExtra());
this.publishTime = extractExtra(extraData, "publishTime");
this.publisher = extractExtra(extraData, "publisher");
this.exiQuantity = extractExtraInt(extraData, "exiQuantity");
this.dynasty = extractExtra(extraData, "dynasty");
this.diameter = extractExtraInt(extraData, "diameter");
this.thickness = extractExtraInt(extraData, "thickness");
this.weight = extractExtraInt(extraData, "weight");
this.extendName = extractExtra(extraData, "extendName");
this.serialNo = extractExtra(extraData, "serialNo");
this.caTableImage = extractExtra(extraData, "caTableImage");
this.nameSrc = extractExtra(extraData, "nameSrc");
this.mint = extractExtra(extraData, "mint");
this.parValue = extractExtra(extraData, "parValue");
this.material = extractExtra(extraData, "material");
}
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public Integer getPid() {
return pid;
}
public void setPid(Integer pid) {
this.pid = pid;
}
public List<CategoryVo> getChildren() {
return children;
}
public void setChildren(List<CategoryVo> children) {
this.children = children;
}
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public String getPublishTime() {
return publishTime;
}
public void setPublishTime(String publishTime) {
this.publishTime = publishTime;
}
public String getPublisher() {
return publisher;
}
public void setPublisher(String publisher) {
this.publisher = publisher;
}
public Integer getExiQuantity() {
return exiQuantity;
}
public void setExiQuantity(Integer exiQuantity) {
this.exiQuantity = exiQuantity;
}
public String getDynasty() {
return dynasty;
}
public void setDynasty(String dynasty) {
this.dynasty = dynasty;
}
public String getSerialNo() {
return serialNo;
}
public void setSerialNo(String serialNo) {
this.serialNo = serialNo;
}
public String getCategoryPath() {
return categoryPath;
}
public void setCategoryPath(String categoryPath) {
this.categoryPath = categoryPath;
}
public String getExtendName() {
return extendName;
}
public void setExtendName(String extendName) {
this.extendName = extendName;
}
public Integer getDiameter() {
return diameter;
}
public void setDiameter(Integer diameter) {
this.diameter = diameter;
}
public Integer getThickness() {
return thickness;
}
public void setThickness(Integer thickness) {
this.thickness = thickness;
}
public Integer getWeight() {
return weight;
}
public void setWeight(Integer weight) {
this.weight = weight;
}
private String extractExtra(Map<String, Object> extraData, String key) {
if (null != extraData.get(key)) {
return extraData.get(key).toString();
}
return "";
}
private Integer extractExtraInt(Map<String, Object> extraData, String key) {
if (!StringUtils.isEmpty(extraData.get(key))) {
return Integer.valueOf(extraData.get(key).toString());
}
return null;
}
public Category toDo() {
Category category = new Category();
category.setId(this.id);
category.setDesc(this.desc);
category.setIcon(this.icon);
category.setLevel(this.level);
category.setName(this.name);
category.setPid(this.pid);
category.setExtra(createExtra());
return category;
}
private String createExtra() {
Map<String, Object> extraObj = new HashMap<>();
extraObj.put("publishTime", this.publishTime);
extraObj.put("publisher", this.publisher);
extraObj.put("exiQuantity", this.exiQuantity);
extraObj.put("mint", this.mint);
extraObj.put("parValue", this.parValue);
extraObj.put("nameSrc",this.nameSrc);
extraObj.put("caTableImage", this.caTableImage);
extraObj.put("diameter", this.diameter);
extraObj.put("dynasty", this.dynasty);
extraObj.put("extendName", this.extendName);
extraObj.put("serialNo", this.serialNo);
extraObj.put("thickness", this.thickness);
extraObj.put("weight", this.weight);
extraObj.put("material", this.material);
return JSONUtils.toJSONString(extraObj);
}
}
package com.jbp.admin.dao;
import com.qiniu.util.StringUtils;
import com.jbp.core.util.PriceUtil;
import com.jbp.db.domain.Item;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Objects;
public class ItemVo implements Serializable {
private static final long serialVersionUID = 3840196224538738818L;
/**
* 商品id
*/
private Long id;
/**
* 类目id
*/
private Integer cid;
/**
* 商品详情
*/
private String detail;
/**
* 商品图片
*/
private String[] images;
/**
* 商品标题
*/
private String name;
/**
* 商品价格
*/
private Double price;
/**
* 是否在架
*/
private Boolean isOnSale;
/**
* 是否分类标准品
*/
private Boolean isStd;
public Integer getCid() {
return cid;
}
public void setCid(Integer cid) {
this.cid = cid;
}
public String getDetail() {
return detail;
}
public void setDetail(String detail) {
this.detail = detail;
}
public String[] getImages() {
return images;
}
public void setImages(String[] images) {
this.images = images;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Double getPrice() {
return price;
}
public void setPrice(Double price) {
this.price = price;
}
public Boolean getIsOnSale() {
return isOnSale;
}
public void setIsOnSale(Boolean onSale) {
isOnSale = onSale;
}
public Boolean getIsStd() {
return isStd;
}
public void setIsStd(Boolean std) {
isStd = std;
}
public Item toItem() {
Item item = new Item();
item.setId(this.id);
item.setCid(this.cid);
item.setName(this.name);
item.setDetail(this.detail);
item.setImages(StringUtils.join(images, ";"));
item.setIsOnSale(this.isOnSale);
item.setIsStd(this.isStd);
item.setPrice((long)(this.price*100L));
return item;
}
public static final ItemVo fromItem(Item item) {
ItemVo itemVo = new ItemVo();
itemVo.setName(item.getName());
itemVo.setCid(item.getCid());
itemVo.setId(item.getId());
itemVo.setDetail(item.getDetail());
itemVo.setImages(item.getImages().split(";"));
itemVo.setIsStd(item.getIsStd());
itemVo.setIsOnSale(item.getIsOnSale());
itemVo.setPrice(Double.parseDouble(PriceUtil.convertPrice(item.getPrice())));
return itemVo;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ItemVo itemVo = (ItemVo) o;
return Objects.equals(cid, itemVo.cid) && Objects.equals(detail, itemVo.detail) && Arrays.equals(images, itemVo.images) && Objects.equals(name, itemVo.name) && Objects.equals(price, itemVo.price) && Objects.equals(isOnSale, itemVo.isOnSale) && Objects.equals(isStd, itemVo.isStd);
}
@Override
public int hashCode() {
int result = Objects.hash(cid, detail, name, price, isOnSale, isStd);
result = 31 * result + Arrays.hashCode(images);
return result;
}
@Override
public String toString() {
return "ItemVo{" +
"cid=" + cid +
", detail='" + detail + '\'' +
", images=" + Arrays.toString(images) +
", name='" + name + '\'' +
", price=" + price +
", isOnSale=" + isOnSale +
", isStd=" + isStd +
'}';
}
}
package com.jbp.admin.dao;
import java.io.Serializable;
import java.math.BigDecimal;
public class OrderAmtsVo implements Serializable {
private static final long serialVersionUID = 3840196229938738818L;
private String[] dayData;//日期数据
private BigDecimal[] orderAmtData;//日订单金额
private int[] orderCntData;//日订单量
public String[] getDayData() {
return dayData;
}
public void setDayData(String[] dayData) {
this.dayData = dayData;
}
public BigDecimal[] getOrderAmtData() {
return orderAmtData;
}
public void setOrderAmtData(BigDecimal[] orderAmtData) {
this.orderAmtData = orderAmtData;
}
public int[] getOrderCntData() {
return orderCntData;
}
public void setOrderCntData(int[] orderCntData) {
this.orderCntData = orderCntData;
}
}
package com.jbp.admin.dao;
import java.math.BigDecimal;
public class Product {
String[] specifications;
BigDecimal price;
Integer number;
String url;
public String[] getSpecifications() {
return specifications;
}
public void setSpecifications(String[] specifications) {
this.specifications = specifications;
}
public BigDecimal getPrice() {
return price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
public Integer getNumber() {
return number;
}
public void setNumber(Integer number) {
this.number = number;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
package com.jbp.admin.dao;
import java.io.Serializable;
public class UserOrderCntVo implements Serializable {
private static final long serialVersionUID = -5460904409450124808L;
private String[] dayData;//日期数据
private int[] userCnt;//每日用户新增量
private int[] orderCnt;//每日订单量
public String[] getDayData() {
return dayData;
}
public void setDayData(String[] dayData) {
this.dayData = dayData;
}
public int[] getUserCnt() {
return userCnt;
}
public void setUserCnt(int[] userCnt) {
this.userCnt = userCnt;
}
public int[] getOrderCnt() {
return orderCnt;
}
public void setOrderCnt(int[] orderCnt) {
this.orderCnt = orderCnt;
}
}
package com.jbp.admin.service;
import java.util.Set;
import com.jbp.admin.util.AuthSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.jbp.db.domain.DtsAdmin;
import com.jbp.db.service.DtsRoleService;
@Service
public class AdminDataAuthService {
@Autowired
private DtsRoleService roleService;
/**
* 是否属于运营商管理员,超级管理员除外
* @return
*/
public boolean isBrandManager() {
Integer[] roleIds = null;
DtsAdmin currentUser = AuthSupport.currentUser();
if (currentUser != null) {
roleIds = currentUser.getRoleIds();
Set<String> roles = roleService.queryByIds(roleIds);
//仅仅只是品牌管理员且不属于超级管理员
if (roles.contains(AuthSupport.BRAND_ROLE_NAME) && !roles.contains(AuthSupport.SUPER_ROLE_NAME)) {
return true;
}
}
return false;
}
}
package com.jbp.admin.service;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.jbp.admin.dao.ItemVo;
import com.jbp.db.domain.Category;
import com.jbp.db.domain.Item;
import com.jbp.db.service.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.jbp.core.qcode.QCodeService;
import com.jbp.core.util.ResponseUtil;
@Service
public class AdminGoodsService {
private static final Logger logger = LoggerFactory.getLogger(AdminGoodsService.class);
@Autowired
private ItemService itemService;
@Autowired
private DtsGoodsSpecificationService specificationService;
@Autowired
private DtsGoodsAttributeService attributeService;
@Autowired
private DtsGoodsProductService productService;
@Autowired
private CategoryService categoryService;
@Autowired
private QCodeService qCodeService;
public Object list(String name, Integer page, Integer limit, String sort, String order) {
List<Item> itemList = itemService.querySelective(name, page, limit, sort, order);
long total = PageInfo.of(itemList).getTotal();
Map<String, Object> data = new HashMap<>();
List<ItemVo> itemVoList = new ArrayList<>();
itemVoList = itemList.stream().map(i -> ItemVo.fromItem(i)).collect(Collectors.toList());
data.put("total", total);
data.put("items", itemVoList);
logger.info("【请求结束】商品管理->商品管理->查询,响应结果:{}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data);
}
private Object validate(Item item) {
String name = item.getName();
if (StringUtils.isEmpty(name)) {
return ResponseUtil.badArgument();
}
// 分类可以不设置,如果设置则需要验证分类存在
Integer categoryId = item.getCid();
if (categoryId != null && categoryId != 0) {
if (categoryService.findById(categoryId) == null) {
return ResponseUtil.badArgumentValue();
}
}
return null;
}
/**
* 编辑商品
* <p>
* TODO 目前商品修改的逻辑是 1. 更新Dts_goods表 2.
* 逻辑删除Dts_goods_specification、Dts_goods_attribute、Dts_goods_product 3.
* 添加Dts_goods_specification、Dts_goods_attribute、Dts_goods_product
* <p>
* 这里商品三个表的数据采用删除再添加的策略是因为 商品编辑页面,支持管理员添加删除商品规格、添加删除商品属性,因此这里仅仅更新是不可能的,
* 只能删除三个表旧的数据,然后添加新的数据。 但是这里又会引入新的问题,就是存在订单商品货品ID指向了失效的商品货品表。
* 因此这里会拒绝管理员编辑商品,如果订单或购物车中存在商品。 所以这里可能需要重新设计。
*/
@Transactional
public Object update(Item item) {
Object error = validate(item);
if (error != null) {
return error;
}
Long id = item.getId();
// 将生成的分享图片地址写入数据库
String url = qCodeService.createGoodShareImage(null,item.getId().toString(), item.getImages().split(";")[0], item.getName(),item.getPrice());
item.setShareImage(url);
// 商品基本信息表Dts_goods
if (itemService.updateById(item) == 0) {
logger.error("商品管理->商品管理->编辑错误:{}", "更新数据失败");
throw new RuntimeException("更新数据失败");
}
Long gid = item.getId();
//qCodeService.createGoodShareImage(goods.getId().toString(), goods.getPicUrl(), goods.getName());
logger.info("【请求结束】商品管理->商品管理->编辑,响应结果:{}", "成功!");
return ResponseUtil.ok();
}
@Transactional
public Object delete(Item item) {
Long id = item.getId();
if (id == null) {
return ResponseUtil.badArgument();
}
Long gid = item.getId();
itemService.deleteById(gid);
logger.info("【请求结束】商品管理->商品管理->删除,响应结果:{}", "成功!");
return ResponseUtil.ok();
}
@Transactional
public Object create(Item item) {
Object error = validate(item);
if (error != null) {
return error;
}
// 商品基本信息表Dts_goods
item.setCreated(LocalDateTime.now());
item.setUpdated(LocalDateTime.now());
item.setIsDeleted(false);
itemService.add(item);
// 将生成的分享图片地址写入数据库
String url = qCodeService.createGoodShareImage(null,item.getId().toString(), item.getImages().split(";")[0], item.getName(), item.getPrice());
if (!StringUtils.isEmpty(url)) {
item.setShareImage(url);
if (itemService.updateById(item) == 0) {
logger.error("商品管理->商品管理->上架错误:{}", "更新数据失败");
throw new RuntimeException("更新数据失败");
}
}
logger.info("【请求结束】商品管理->商品管理->上架,响应结果:{}", "成功!");
return ResponseUtil.ok();
}
public Object detail(Long id) {
Item item = itemService.findById(id);
//用于展示商品归属的类目(页面级联下拉控件数据展示)
Integer categoryId = item.getCid();
Category category = categoryService.findById(categoryId);
List<Integer> categoryIds = new ArrayList<>();
if (null != category) {
categoryIds.add(0, category.getId());
Integer pid = category.getPid();
while (pid != 0) {
categoryIds.add(0, pid);
Category pCategory = categoryService.findById(pid);
if (null != pCategory) {
pid = pCategory.getPid();
} else {
break;
}
}
}
Map<String, Object> data = new HashMap<>();
data.put("goods", ItemVo.fromItem(item));
data.put("categoryIds", categoryIds.toArray());
logger.info("【请求结束】商品管理->商品管理->详情,响应结果:{}", "成功!");
return ResponseUtil.ok(data);
}
}
package com.jbp.admin.shiro;
import java.util.List;
import java.util.Set;
import org.apache.shiro.authc.AccountException;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.SimpleAuthenticationInfo;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import com.jbp.core.util.bcrypt.BCryptPasswordEncoder;
import com.jbp.db.domain.DtsAdmin;
import com.jbp.db.service.DtsAdminService;
import com.jbp.db.service.DtsPermissionService;
import com.jbp.db.service.DtsRoleService;
/**
* 授权相关服务-shiro
*
* @author qiguliuxing
* @since 1.0.0
*/
public class AdminAuthorizingRealm extends AuthorizingRealm {
private static final Logger logger = LoggerFactory.getLogger(AdminAuthorizingRealm.class);
@Autowired
private DtsAdminService adminService;
@Autowired
private DtsRoleService roleService;
@Autowired
private DtsPermissionService permissionService;
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
if (principals == null) {
throw new AuthorizationException("PrincipalCollection method argument cannot be null.");
}
DtsAdmin admin = (DtsAdmin) getAvailablePrincipal(principals);
Integer[] roleIds = admin.getRoleIds();
Set<String> roles = roleService.queryByIds(roleIds);
Set<String> permissions = permissionService.queryByRoleIds(roleIds);
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
info.setRoles(roles);
info.setStringPermissions(permissions);
return info;
}
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
UsernamePasswordToken upToken = (UsernamePasswordToken) token;
String username = upToken.getUsername();
String password = new String(upToken.getPassword());
if (StringUtils.isEmpty(username)) {
throw new AccountException("用户名不能为空");
}
if (StringUtils.isEmpty(password)) {
throw new AccountException("密码不能为空");
}
List<DtsAdmin> adminList = adminService.findAdmin(username);
Assert.state(adminList.size() < 2, "同一个用户名存在两个账户");
if (adminList.size() == 0) {
logger.error("找不到用户(" + username + ")的帐号信息");
throw new UnknownAccountException("找不到用户(" + username + ")的帐号信息");
}
DtsAdmin admin = adminList.get(0);
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
if (!encoder.matches(password, admin.getPassword())) {
logger.error("找不到用户(" + username + ")的帐号信息");
throw new UnknownAccountException("找不到用户(" + username + ")的帐号信息");
}
return new SimpleAuthenticationInfo(admin, password, getName());
}
}
package com.jbp.admin.shiro;
import java.io.Serializable;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import org.apache.shiro.web.servlet.ShiroHttpServletRequest;
import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
import org.apache.shiro.web.util.WebUtils;
import com.alibaba.druid.util.StringUtils;
public class AdminWebSessionManager extends DefaultWebSessionManager {
public static final String LOGIN_TOKEN_KEY = "X-Dts-Admin-Token";
private static final String REFERENCED_SESSION_ID_SOURCE = "Stateless request";
@Override
protected Serializable getSessionId(ServletRequest request, ServletResponse response) {
String id = WebUtils.toHttp(request).getHeader(LOGIN_TOKEN_KEY);
if (!StringUtils.isEmpty(id)) {
request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID_SOURCE, REFERENCED_SESSION_ID_SOURCE);
request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID, id);
request.setAttribute(ShiroHttpServletRequest.REFERENCED_SESSION_ID_IS_VALID, Boolean.TRUE);
return id;
} else {
return super.getSessionId(request, response);
}
}
}
package com.jbp.admin.util;
/**
* 返回码定义
*
* @author CHENBO
* @since 1.0.0
* @QQ 623659388
*
*/
public enum AdminResponseCode {
ADMIN_INVALID_NAME(600, "管理员名称不符合规定"), ADMIN_INVALID_PASSWORD(601, "管理员密码长度不能小于6"),
ADMIN_NAME_EXIST(602, "管理员已经存在"),
// ADMIN_ALTER_NOT_ALLOWED(603,""),
// ADMIN_DELETE_NOT_ALLOWED(604,""),
ADMIN_INVALID_ACCOUNT_OR_PASSWORD(605, "用户帐号或密码不正确"), ADMIN_LOCK_ACCOUNT(606, "用户帐号已锁定不可用"),
ADMIN_INVALID_AUTH(607, "认证失败"), GOODS_UPDATE_NOT_ALLOWED(610, "商品已经在订单或购物车中,不能修改"),
GOODS_NAME_EXIST(611, "商品名已经存在"), ORDER_CONFIRM_NOT_ALLOWED(620, "当前订单状态不能确认收货"),
ORDER_REFUND_FAILED(621, "当前订单状态不能退款"), ORDER_REPLY_EXIST(622, "订单商品已回复!"),
ADMIN_INVALID_OLD_PASSWORD(623, "原始密码不正确!"),
// USER_INVALID_NAME(630,""),
// USER_INVALID_PASSWORD(631,""),
// USER_INVALID_MOBILE(632,""),
// USER_NAME_EXIST(633,""),
// USER_MOBILE_EXIST(634,""),
ROLE_NAME_EXIST(640, "角色已经存在"), ROLE_SUPER_SUPERMISSION(641, "当前角色的超级权限不能变更"),
ARTICLE_NAME_EXIST(642,"公告或通知文章已经存在"),
AUTH_CAPTCHA_FREQUENCY(643,"验证码请求过于频繁"),
AUTH_CAPTCHA_ERROR(644,"验证码错误"), AUTH_CAPTCHA_EXPIRED(645,"验证码过期");
private final Integer code;
private final String desc;
AdminResponseCode(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
public static AdminResponseCode getInstance(Integer code) {
if (code != null) {
for (AdminResponseCode tmp : AdminResponseCode.values()) {
if (tmp.code.intValue() == code.intValue()) {
return tmp;
}
}
}
return null;
}
public Integer code() {
return code;
}
public String desc() {
return desc;
}
}
package com.jbp.admin.util;
import com.jbp.core.util.ResponseUtil;
/**
* 管理后台接口枚举信息的响应
*
* @author CHENBO
* @since 1.0.0
* @QQ 623659388
*/
public class AdminResponseUtil extends ResponseUtil {
/**
* 按枚举返回错误响应结果
*
* @param orderUnknown
* @return
*/
public static Object fail(AdminResponseCode responseCode) {
return fail(responseCode.code(), responseCode.desc());
}
}
package com.jbp.admin.util;
import org.apache.commons.lang3.StringUtils;
/**
* 公告,通知文章等类型定义
*
* @author CHENBO
* @since 1.0.0
* @QQ 623659388
*
*/
public enum ArticleType {
NOTICE("0", "通知"), ANNOUNCE("1", "公告");
private final String type;
private final String desc;
ArticleType(String type, String desc) {
this.type = type;
this.desc = desc;
}
public static ArticleType getInstance(String type) {
if (StringUtils.isNotBlank(type)) {
for (ArticleType tmp : ArticleType.values()) {
if (type.equals(tmp.type)) {
return tmp;
}
}
}
return null;
}
public String type() {
return type;
}
public String desc() {
return desc;
}
}
package com.jbp.admin.util;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import com.jbp.db.domain.DtsAdmin;
/**
* 用于权限支持服务
* @author QIGULIXING
* @since 1.0.0
* @QQ 623659388
*
*/
public class AuthSupport {
public static final Object BRAND_ROLE_NAME = "品牌制造商";
public static final Object SUPER_ROLE_NAME = "超级管理员";
/**
* 获取用户
* @return
*/
public static DtsAdmin currentUser() {
DtsAdmin admin = null;
Subject currentUser = SecurityUtils.getSubject();
if (currentUser != null) {
admin = (DtsAdmin) currentUser.getPrincipal();
}
return admin;
}
/**
* 获取用户名
* @return
*/
public static String userName() {
String userName = null;
DtsAdmin currentUser = currentUser();
if (currentUser != null) {
userName = currentUser.getUsername();
}
return userName;
}
/**
* 获取用户id
* @return
*/
public static Integer adminId() {
Integer adminId = null;
DtsAdmin currentUser = currentUser();
if (currentUser != null) {
adminId = currentUser.getId();
}
return adminId;
}
}
package com.jbp.admin.util;
import java.util.List;
@SuppressWarnings("rawtypes")
public class CatVo {
private Integer value = null;
private String label = null;
private List children = null;
public Integer getValue() {
return value;
}
public void setValue(Integer value) {
this.value = value;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public List getChildren() {
return children;
}
public void setChildren(List children) {
this.children = children;
}
}
package com.jbp.admin.util;
import java.util.List;
public class PermVo {
private String id;
private String label;
private String api;
private List<PermVo> children;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public void setApi(String api) {
this.api = api;
}
public String getApi() {
return api;
}
public List<PermVo> getChildren() {
return children;
}
public void setChildren(List<PermVo> children) {
this.children = children;
}
}
package com.jbp.admin.util;
import com.jbp.admin.annotation.RequiresPermissionsDesc;
import org.apache.shiro.authz.annotation.RequiresPermissions;
public class Permission {
private RequiresPermissions requiresPermissions;
private RequiresPermissionsDesc requiresPermissionsDesc;
private String api;
public RequiresPermissions getRequiresPermissions() {
return requiresPermissions;
}
public RequiresPermissionsDesc getRequiresPermissionsDesc() {
return requiresPermissionsDesc;
}
public void setRequiresPermissions(RequiresPermissions requiresPermissions) {
this.requiresPermissions = requiresPermissions;
}
public void setRequiresPermissionsDesc(RequiresPermissionsDesc requiresPermissionsDesc) {
this.requiresPermissionsDesc = requiresPermissionsDesc;
}
public String getApi() {
return api;
}
public void setApi(String api) {
this.api = api;
}
}
package com.jbp.admin.util;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.jbp.admin.annotation.RequiresPermissionsDesc;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.reflect.MethodUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.context.ApplicationContext;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.stereotype.Controller;
import org.springframework.util.ClassUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
public class PermissionUtil {
public static List<PermVo> listPermVo(List<Permission> permissions) {
List<PermVo> root = new ArrayList<>();
for (Permission permission : permissions) {
RequiresPermissions requiresPermissions = permission.getRequiresPermissions();
RequiresPermissionsDesc requiresPermissionsDesc = permission.getRequiresPermissionsDesc();
String api = permission.getApi();
String[] menus = requiresPermissionsDesc.menu();
if (menus.length != 2) {
throw new RuntimeException("目前只支持两级菜单");
}
String menu1 = menus[0];
PermVo perm1 = null;
for (PermVo permVo : root) {
if (permVo.getLabel().equals(menu1)) {
perm1 = permVo;
break;
}
}
if (perm1 == null) {
perm1 = new PermVo();
perm1.setId(menu1);
perm1.setLabel(menu1);
perm1.setChildren(new ArrayList<>());
root.add(perm1);
}
String menu2 = menus[1];
PermVo perm2 = null;
for (PermVo permVo : perm1.getChildren()) {
if (permVo.getLabel().equals(menu2)) {
perm2 = permVo;
break;
}
}
if (perm2 == null) {
perm2 = new PermVo();
perm2.setId(menu2);
perm2.setLabel(menu2);
perm2.setChildren(new ArrayList<>());
perm1.getChildren().add(perm2);
}
String button = requiresPermissionsDesc.button();
PermVo leftPerm = null;
for (PermVo permVo : perm2.getChildren()) {
if (permVo.getLabel().equals(button)) {
leftPerm = permVo;
break;
}
}
if (leftPerm == null) {
leftPerm = new PermVo();
leftPerm.setId(requiresPermissions.value()[0]);
leftPerm.setLabel(requiresPermissionsDesc.button());
leftPerm.setApi(api);
perm2.getChildren().add(leftPerm);
} else {
// TODO
// 目前限制Controller里面每个方法的RequiresPermissionsDesc注解是唯一的
// 如果允许相同,可能会造成内部权限不一致。
throw new RuntimeException("权限已经存在,不能添加新权限");
}
}
return root;
}
@SuppressWarnings("rawtypes")
public static List<Permission> listPermission(ApplicationContext context, String basicPackage) {
Map<String, Object> map = context.getBeansWithAnnotation(Controller.class);
List<Permission> permissions = new ArrayList<>();
for (Map.Entry<String, Object> entry : map.entrySet()) {
Object bean = entry.getValue();
if (!StringUtils.contains(ClassUtils.getPackageName(bean.getClass()), basicPackage)) {
continue;
}
Class<?> clz = bean.getClass();
Class controllerClz = clz.getSuperclass();
RequestMapping clazzRequestMapping = AnnotationUtils.findAnnotation(controllerClz, RequestMapping.class);
List<Method> methods = MethodUtils.getMethodsListWithAnnotation(controllerClz, RequiresPermissions.class);
for (Method method : methods) {
RequiresPermissions requiresPermissions = AnnotationUtils.getAnnotation(method,
RequiresPermissions.class);
RequiresPermissionsDesc requiresPermissionsDesc = AnnotationUtils.getAnnotation(method,
RequiresPermissionsDesc.class);
if (requiresPermissions == null || requiresPermissionsDesc == null) {
continue;
}
String api = "";
if (clazzRequestMapping != null) {
api = clazzRequestMapping.value()[0];
}
PostMapping postMapping = AnnotationUtils.getAnnotation(method, PostMapping.class);
if (postMapping != null) {
api = "POST " + api + postMapping.value()[0];
Permission permission = new Permission();
permission.setRequiresPermissions(requiresPermissions);
permission.setRequiresPermissionsDesc(requiresPermissionsDesc);
permission.setApi(api);
permissions.add(permission);
continue;
}
GetMapping getMapping = AnnotationUtils.getAnnotation(method, GetMapping.class);
if (getMapping != null) {
api = "GET " + api + getMapping.value()[0];
Permission permission = new Permission();
permission.setRequiresPermissions(requiresPermissions);
permission.setRequiresPermissionsDesc(requiresPermissionsDesc);
permission.setApi(api);
permissions.add(permission);
continue;
}
// TODO
// 这里只支持GetMapping注解或者PostMapping注解,应该进一步提供灵活性
throw new RuntimeException("目前权限管理应该在method的前面使用GetMapping注解或者PostMapping注解");
}
}
return permissions;
}
public static Set<String> listPermissionString(List<Permission> permissions) {
Set<String> permissionsString = new HashSet<>();
for (Permission permission : permissions) {
permissionsString.add(permission.getRequiresPermissions().value()[0]);
}
return permissionsString;
}
}
package com.jbp.admin.util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@SuppressWarnings("rawtypes")
public class StatVo {
private String[] columns = new String[0];
private List<Map> rows = new ArrayList<>();
public String[] getColumns() {
return columns;
}
public void setColumns(String[] columns) {
this.columns = columns;
}
public List<Map> getRows() {
return rows;
}
public void setRows(List<Map> rows) {
this.rows = rows;
}
public void add(Map... r) {
rows.addAll(Arrays.asList(r));
}
}
package com.jbp.admin.util;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Random;
import javax.imageio.ImageIO;
/**
* 验证码图片生成工具类
*/
public class VerifyCodeUtils {
// 使用到Algerian字体,系统里没有的话需要安装字体,字体只显示大写,去掉了1,0,i,o几个容易混淆的字符
public static final String VERIFY_CODES = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ";
private static Random random = new SecureRandom();
/**
* 使用系统默认字符源生成验证码
*
* @param verifySize
* 验证码长度
* @return
*/
public static String generateVerifyCode(int verifySize) {
return generateVerifyCode(verifySize, VERIFY_CODES);
}
/**
* 使用指定源生成验证码
*
* @param verifySize
* 验证码长度
* @param sources
* 验证码字符源
* @return
*/
public static String generateVerifyCode(int verifySize, String sources) {
if (sources == null || sources.length() == 0) {
sources = VERIFY_CODES;
}
int codesLen = sources.length();
Random rand = new Random(System.currentTimeMillis());
StringBuilder verifyCode = new StringBuilder(verifySize);
for (int i = 0; i < verifySize; i++) {
verifyCode.append(sources.charAt(rand.nextInt(codesLen - 1)));
}
return verifyCode.toString();
}
/**
* 输出指定验证码图片流
*
* @param w
* @param h
* @param os
* @param code
* @throws IOException
*/
public static void outputImage(int w, int h, OutputStream os, String code) throws IOException {
int verifySize = code.length();
BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
Random rand = new Random();
Graphics2D g2 = image.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Color[] colors = new Color[5];
Color[] colorSpaces = new Color[] { Color.WHITE, Color.CYAN, Color.GRAY, Color.LIGHT_GRAY, Color.MAGENTA,
Color.ORANGE, Color.PINK, Color.YELLOW };
float[] fractions = new float[colors.length];
for (int i = 0; i < colors.length; i++) {
colors[i] = colorSpaces[rand.nextInt(colorSpaces.length)];
fractions[i] = rand.nextFloat();
}
Arrays.sort(fractions);
g2.setColor(Color.GRAY);// 设置边框色
g2.fillRect(0, 0, w, h);
Color c = getRandColor(200, 250);
g2.setColor(c);// 设置背景色
g2.fillRect(0, 2, w, h - 4);
// 绘制干扰线
Random random = new Random();
g2.setColor(getRandColor(160, 200));// 设置线条的颜色
for (int i = 0; i < 20; i++) {
int x = random.nextInt(w - 1);
int y = random.nextInt(h - 1);
int xl = random.nextInt(6) + 1;
int yl = random.nextInt(12) + 1;
g2.drawLine(x, y, x + xl + 40, y + yl + 20);
}
// 添加噪点
float yawpRate = 0.05f;// 噪声率
int area = (int) (yawpRate * w * h);
for (int i = 0; i < area; i++) {
int x = random.nextInt(w);
int y = random.nextInt(h);
int rgb = getRandomIntColor();
image.setRGB(x, y, rgb);
}
shear(g2, w, h, c);// 使图片扭曲
g2.setColor(getRandColor(100, 160));
int fontSize = h - 4;
Font font = new Font("Algerian", Font.ITALIC, fontSize);
g2.setFont(font);
char[] chars = code.toCharArray();
for (int i = 0; i < verifySize; i++) {
AffineTransform affine = new AffineTransform();
affine.setToRotation(Math.PI / 4 * rand.nextDouble() * (rand.nextBoolean() ? 1 : -1),
(w / verifySize) * i + fontSize / 2, h / 2);
g2.setTransform(affine);
g2.drawChars(chars, i, 1, ((w - 10) / verifySize) * i + 5, h / 2 + fontSize / 2 - 10);
}
g2.dispose();
ImageIO.write(image, "jpg", os);
}
private static Color getRandColor(int fc, int bc) {
if (fc > 255)
fc = 255;
if (bc > 255)
bc = 255;
int r = fc + random.nextInt(bc - fc);
int g = fc + random.nextInt(bc - fc);
int b = fc + random.nextInt(bc - fc);
return new Color(r, g, b);
}
private static int getRandomIntColor() {
int[] rgb = getRandomRgb();
int color = 0;
for (int c : rgb) {
color = color << 8;
color = color | c;
}
return color;
}
private static int[] getRandomRgb() {
int[] rgb = new int[3];
for (int i = 0; i < 3; i++) {
rgb[i] = random.nextInt(255);
}
return rgb;
}
private static void shear(Graphics g, int w1, int h1, Color color) {
shearX(g, w1, h1, color);
shearY(g, w1, h1, color);
}
private static void shearX(Graphics g, int w1, int h1, Color color) {
int period = random.nextInt(2);
boolean borderGap = true;
int frames = 1;
int phase = random.nextInt(2);
for (int i = 0; i < h1; i++) {
double d = (double) (period >> 1)
* Math.sin((double) i / (double) period + (6.2831853071795862D * (double) phase) / (double) frames);
g.copyArea(0, i, w1, 1, (int) d, 0);
if (borderGap) {
g.setColor(color);
g.drawLine((int) d, i, 0, i);
g.drawLine((int) d + w1, i, w1, i);
}
}
}
private static void shearY(Graphics g, int w1, int h1, Color color) {
int period = random.nextInt(40) + 10; // 50;
boolean borderGap = true;
int frames = 20;
int phase = 7;
for (int i = 0; i < w1; i++) {
double d = (double) (period >> 1)
* Math.sin((double) i / (double) period + (6.2831853071795862D * (double) phase) / (double) frames);
g.copyArea(i, 0, 1, h1, 0, (int) d);
if (borderGap) {
g.setColor(color);
g.drawLine(i, (int) d, i, 0);
g.drawLine(i, (int) d + h1, i, h1);
}
}
}
}
\ No newline at end of file
package com.jbp.admin.web;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.validation.constraints.NotNull;
import com.jbp.admin.annotation.RequiresPermissionsDesc;
import com.jbp.admin.util.AuthSupport;
import com.jbp.admin.util.AdminResponseCode;
import com.jbp.admin.util.AdminResponseUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.jbp.core.util.RegexUtil;
import com.jbp.core.util.ResponseUtil;
import com.jbp.core.util.bcrypt.BCryptPasswordEncoder;
import com.jbp.core.validator.Order;
import com.jbp.core.validator.Sort;
import com.jbp.db.domain.DtsAdmin;
import com.jbp.db.service.DtsAdminService;
@RestController
@RequestMapping("/admin/admin")
@Validated
public class AdminAdminController {
private static final Logger logger = LoggerFactory.getLogger(AdminAdminController.class);
@Autowired
private DtsAdminService adminService;
@RequiresPermissions("admin:admin:list")
@RequiresPermissionsDesc(menu = { "系统管理", "管理员管理" }, button = "查询")
@GetMapping("/list")
public Object list(String username, @RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 系统管理->管理员管理->查询,请求参数:username:{},page:{}", username, page);
List<DtsAdmin> adminList = adminService.querySelective(username, page, limit, sort, order);
long total = PageInfo.of(adminList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", adminList);
logger.info("【请求结束】系统管理->管理员管理->查询,响应结果:{}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data);
}
private Object validate(DtsAdmin admin) {
String name = admin.getUsername();
if (StringUtils.isEmpty(name)) {
return ResponseUtil.badArgument();
}
if (!RegexUtil.isUsername(name)) {
logger.error("校验错误:{}", AdminResponseCode.ADMIN_INVALID_NAME.desc());
return AdminResponseUtil.fail(AdminResponseCode.ADMIN_INVALID_NAME);
}
String password = admin.getPassword();
if (StringUtils.isEmpty(password) || password.length() < 6) {
logger.error("校验错误:{}", AdminResponseCode.ADMIN_INVALID_PASSWORD.desc());
return AdminResponseUtil.fail(AdminResponseCode.ADMIN_INVALID_PASSWORD);
}
return null;
}
@RequiresPermissions("admin:admin:create")
@RequiresPermissionsDesc(menu = { "系统管理", "管理员管理" }, button = "添加")
@PostMapping("/create")
public Object create(@RequestBody DtsAdmin admin) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 系统管理->管理员管理->添加,请求参数:{}", JSONObject.toJSONString(admin));
Object error = validate(admin);
if (error != null) {
return error;
}
String username = admin.getUsername();
List<DtsAdmin> adminList = adminService.findAdmin(username);
if (adminList.size() > 0) {
logger.error("系统管理->管理员管理->添加 ,错误:{}", AdminResponseCode.ADMIN_NAME_EXIST.desc());
return AdminResponseUtil.fail(AdminResponseCode.ADMIN_NAME_EXIST);
}
String rawPassword = admin.getPassword();
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
String encodedPassword = encoder.encode(rawPassword);
admin.setPassword(encodedPassword);
adminService.add(admin);
logger.info("【请求结束】系统管理->管理员管理->添加,响应结果:{}", JSONObject.toJSONString(admin));
return ResponseUtil.ok(admin);
}
@RequiresPermissions("admin:admin:read")
@RequiresPermissionsDesc(menu = { "系统管理", "管理员管理" }, button = "详情")
@GetMapping("/read")
public Object read(@NotNull Integer id) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 系统管理->管理员管理->详情,请求参数,id:{}", id);
DtsAdmin admin = adminService.findById(id);
logger.info("【请求结束】系统管理->管理员管理->详情,响应结果:{}", JSONObject.toJSONString(admin));
return ResponseUtil.ok(admin);
}
@RequiresPermissions("admin:admin:update")
@RequiresPermissionsDesc(menu = { "系统管理", "管理员管理" }, button = "编辑")
@PostMapping("/update")
public Object update(@RequestBody DtsAdmin admin) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 系统管理->管理员管理->编辑,请求参数:{}", JSONObject.toJSONString(admin));
Object error = validate(admin);
if (error != null) {
return error;
}
Integer anotherAdminId = admin.getId();
if (anotherAdminId == null) {
return ResponseUtil.badArgument();
}
String rawPassword = admin.getPassword();
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
String encodedPassword = encoder.encode(rawPassword);
admin.setPassword(encodedPassword);
if (adminService.updateById(admin) == 0) {
logger.error("系统管理->管理员管理-编辑 ,错误:{}", "更新数据失败!");
return ResponseUtil.updatedDataFailed();
}
logger.info("【请求结束】系统管理->管理员管理->编辑,响应结果:{}", JSONObject.toJSONString(admin));
return ResponseUtil.ok(admin);
}
@RequiresPermissions("admin:admin:delete")
@RequiresPermissionsDesc(menu = { "系统管理", "管理员管理" }, button = "删除")
@PostMapping("/delete")
public Object delete(@RequestBody DtsAdmin admin) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 系统管理->管理员管理->删除,请求参数:{}", JSONObject.toJSONString(admin));
Integer anotherAdminId = admin.getId();
if (anotherAdminId == null) {
return ResponseUtil.badArgument();
}
adminService.deleteById(anotherAdminId);
logger.info("【请求结束】系统管理->管理员管理->删除 成功!");
return ResponseUtil.ok();
}
}
package com.jbp.admin.web;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletResponse;
import com.jbp.admin.util.PermissionUtil;
import com.jbp.admin.util.VerifyCodeUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.LockedAccountException;
import org.apache.shiro.authc.UnknownAccountException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.jbp.admin.util.AdminResponseCode;
import com.jbp.admin.util.AdminResponseUtil;
import com.jbp.admin.util.Permission;
import com.jbp.core.captcha.CaptchaCodeManager;
import com.jbp.core.util.Base64;
import com.jbp.core.util.JacksonUtil;
import com.jbp.core.util.ResponseUtil;
import com.jbp.core.util.UUID;
import com.jbp.db.domain.DtsAdmin;
import com.jbp.db.service.DtsPermissionService;
import com.jbp.db.service.DtsRoleService;
@RestController
@RequestMapping("/admin/auth")
@Validated
public class AdminAuthController {
private static final Logger logger = LoggerFactory.getLogger(AdminAuthController.class);
@Autowired
private DtsRoleService roleService;
@Autowired
private DtsPermissionService permissionService;
/*
* { username : value, password : value }
*/
@PostMapping("/login")
public Object login(@RequestBody String body) {
logger.info("【请求开始】系统管理->用户登录,请求参数:body:{}", body);
String username = JacksonUtil.parseString(body, "username");
String password = JacksonUtil.parseString(body, "password");
String code = JacksonUtil.parseString(body, "code");
String uuid = JacksonUtil.parseString(body, "uuid");
if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password) || StringUtils.isEmpty(code) || StringUtils.isEmpty(uuid)) {
return ResponseUtil.badArgument();
}
//验证码校验
String cachedCaptcha = CaptchaCodeManager.getCachedCaptcha(uuid);
if (cachedCaptcha == null) {
logger.error("系统管理->用户登录 错误:{},", AdminResponseCode.AUTH_CAPTCHA_EXPIRED.desc());
return AdminResponseUtil.fail(AdminResponseCode.AUTH_CAPTCHA_EXPIRED);
}
if (!code.equalsIgnoreCase(cachedCaptcha)) {
logger.error("系统管理->用户登录 错误:{},输入验证码:{},后台验证码:{}", AdminResponseCode.AUTH_CAPTCHA_ERROR.desc(),code,cachedCaptcha);
return AdminResponseUtil.fail(AdminResponseCode.AUTH_CAPTCHA_ERROR);
}
Subject currentUser = SecurityUtils.getSubject();
try {
currentUser.login(new UsernamePasswordToken(username, password));
} catch (UnknownAccountException uae) {
logger.error("系统管理->用户登录 错误:{}", AdminResponseCode.ADMIN_INVALID_ACCOUNT_OR_PASSWORD.desc());
return AdminResponseUtil.fail(AdminResponseCode.ADMIN_INVALID_ACCOUNT_OR_PASSWORD);
} catch (LockedAccountException lae) {
logger.error("系统管理->用户登录 错误:{}", AdminResponseCode.ADMIN_LOCK_ACCOUNT.desc());
return AdminResponseUtil.fail(AdminResponseCode.ADMIN_LOCK_ACCOUNT);
} catch (AuthenticationException ae) {
logger.error("系统管理->用户登录 错误:{}", AdminResponseCode.ADMIN_LOCK_ACCOUNT.desc());
return AdminResponseUtil.fail(AdminResponseCode.ADMIN_INVALID_AUTH);
}
logger.info("【请求结束】系统管理->用户登录,响应结果:{}", JSONObject.toJSONString(currentUser.getSession().getId()));
return ResponseUtil.ok(currentUser.getSession().getId());
}
/*
* 用户注销
*/
@RequiresAuthentication
@PostMapping("/logout")
public Object login() {
Subject currentUser = SecurityUtils.getSubject();
currentUser.logout();
logger.info("【请求结束】系统管理->用户注销,响应结果:{}", JSONObject.toJSONString(currentUser.getSession().getId()));
return ResponseUtil.ok();
}
@RequiresAuthentication
@GetMapping("/info")
public Object info() {
Subject currentUser = SecurityUtils.getSubject();
DtsAdmin admin = (DtsAdmin) currentUser.getPrincipal();
Map<String, Object> data = new HashMap<>();
data.put("name", admin.getUsername());
data.put("avatar", admin.getAvatar());
Integer[] roleIds = admin.getRoleIds();
Set<String> roles = roleService.queryByIds(roleIds);
Set<String> permissions = permissionService.queryByRoleIds(roleIds);
data.put("roles", roles);
// NOTE
// 这里需要转换perms结构,因为对于前端而已API形式的权限更容易理解
data.put("perms", toAPI(permissions));
logger.info("【请求结束】系统管理->用户信息获取,响应结果:{}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data);
}
@Autowired
private ApplicationContext context;
private HashMap<String, String> systemPermissionsMap = null;
private Collection<String> toAPI(Set<String> permissions) {
if (systemPermissionsMap == null) {
systemPermissionsMap = new HashMap<>();
final String basicPackage = "com.wwdz.ch.admin";
List<Permission> systemPermissions = PermissionUtil.listPermission(context, basicPackage);
for (Permission permission : systemPermissions) {
String perm = permission.getRequiresPermissions().value()[0];
String api = permission.getApi();
systemPermissionsMap.put(perm, api);
}
}
Collection<String> apis = new HashSet<>();
for (String perm : permissions) {
String api = systemPermissionsMap.get(perm);
apis.add(api);
if (perm.equals("*")) {
apis.clear();
apis.add("*");
return apis;
// return systemPermissionsMap.values();
}
}
return apis;
}
/**
* 生成验证码
*/
@GetMapping("/captchaImage")
public Object getCode(HttpServletResponse response) throws IOException {
// 生成随机字串
String verifyCode = VerifyCodeUtils.generateVerifyCode(4);
// 唯一标识
String uuid = UUID.randomUUID().toString(true);
boolean successful = CaptchaCodeManager.addToCache(uuid, verifyCode,10);//存储内存
if (!successful) {
logger.error("请求验证码出错:{}", AdminResponseCode.AUTH_CAPTCHA_FREQUENCY.desc());
return AdminResponseUtil.fail(AdminResponseCode.AUTH_CAPTCHA_FREQUENCY);
}
// 生成图片
int w = 111, h = 36;
ByteArrayOutputStream stream = new ByteArrayOutputStream();
VerifyCodeUtils.outputImage(w, h, stream, verifyCode);
try {
Map<String, Object> data = new HashMap<>();
data.put("uuid", uuid);
data.put("img", Base64.encode(stream.toByteArray()));
return ResponseUtil.ok(data);
} catch (Exception e){
e.printStackTrace();
return ResponseUtil.serious();
} finally {
stream.close();
}
}
@GetMapping("/401")
public Object page401() {
return ResponseUtil.unlogin();
}
@GetMapping("/index")
public Object pageIndex() {
return ResponseUtil.ok();
}
@GetMapping("/403")
public Object page403() {
return ResponseUtil.unauthz();
}
}
package com.jbp.admin.web;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.jbp.admin.annotation.RequiresPermissionsDesc;
import com.jbp.admin.util.AuthSupport;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.jbp.core.util.ResponseUtil;
import com.jbp.core.validator.Order;
import com.jbp.core.validator.Sort;
import com.jbp.db.domain.DtsCollect;
import com.jbp.db.service.DtsCollectService;
@RestController
@RequestMapping("/admin/collect")
@Validated
public class AdminCollectController {
private static final Logger logger = LoggerFactory.getLogger(AdminCollectController.class);
@Autowired
private DtsCollectService collectService;
@RequiresPermissions("admin:collect:list")
@RequiresPermissionsDesc(menu = { "用户管理", "用户收藏" }, button = "查询")
@GetMapping("/list")
public Object list(String userId, String valueId, @RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 用户管理->用户收藏->查询,请求参数:userId:{},page:{}", userId, page);
List<DtsCollect> collectList = collectService.querySelective(userId, valueId, page, limit, sort, order);
long total = PageInfo.of(collectList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", collectList);
logger.info("【请求结束】用户管理->用户收藏->查询:total:{}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data);
}
}
package com.jbp.admin.web;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.jbp.admin.util.AuthSupport;
import com.jbp.admin.dao.OrderAmtsVo;
import com.jbp.admin.dao.UserOrderCntVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.jbp.core.util.ResponseUtil;
import com.jbp.db.bean.DayStatis;
import com.jbp.db.service.DtsGoodsProductService;
import com.jbp.db.service.ItemService;
import com.jbp.db.service.DtsUserService;
@RestController
@RequestMapping("/admin/dashboard")
@Validated
public class AdminDashbordController {
private static final Logger logger = LoggerFactory.getLogger(AdminDashbordController.class);
private static final int STATIS_DAYS_RANG = 30;// 统计的天数范围,一个月数据
@Autowired
private DtsUserService userService;
@Autowired
private ItemService goodsService;
@Autowired
private DtsGoodsProductService productService;
@GetMapping("")
public Object info() {
logger.info("【请求开始】操作人:[" + AuthSupport.userName() + "] 系统管理->首页仪表盘查询");
int userTotal = userService.count();
int goodsTotal = goodsService.count();
int productTotal = productService.count();
Map<String, Integer> data = new HashMap<>();
data.put("userTotal", userTotal);
data.put("goodsTotal", goodsTotal);
data.put("productTotal", productTotal);
logger.info("【请求结束】系统管理->首页仪表盘查询:响应结果:{}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data);
}
@GetMapping("/chart")
public Object chart() {
logger.info("【请求开始】操作人:[" + AuthSupport.userName() + "] 系统管理->首页图表查询");
// 近期用户,订单增长量查询
UserOrderCntVo userOrderCnt = new UserOrderCntVo();
List<DayStatis> userCnts = userService.recentCount(STATIS_DAYS_RANG);
Map<String, Object> data = new HashMap<>();
data.put("userOrderCnt", userOrderCnt);
logger.info("【请求结束】系统管理->首页图表查询:响应结果:{}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data);
}
/**
* 获取日期数据并排序
*
* @param userCnts
* @param orderCnts
* @return
*/
private String[] unionDayData(List<DayStatis> userCnts, List<DayStatis> orderCnts) {
Set<String> days = new HashSet<>();
for (DayStatis userCnt : userCnts) {
days.add(userCnt.getDayStr());
}
for (DayStatis orderCnt : orderCnts) {
days.add(orderCnt.getDayStr());
}
/*days.stream().sorted(Comparator.reverseOrder());// 排序
return days.toArray(new String[days.size()]);*/
List<String> list = new ArrayList<String>(days);
Collections.sort(list);
return list.toArray(new String[0]);
}
/**
* 从统计集合中获取数量 不存在则设置 0
*
* @param dayData
* @param dayStatisCnts
* @return
*/
private int[] fetchArrCnt(String[] dayData, List<DayStatis> dayStatisCnts) {
int[] arrCnts = new int[dayData.length];
for (int i = 0; i < dayData.length; i++) {
int dayCnt = 0;
String dayStr = dayData[i];
for (DayStatis ds : dayStatisCnts) {
if (dayStr.equals(ds.getDayStr())) {
dayCnt = ds.getCnts();
break;
}
}
arrCnts[i] = dayCnt;
}
return arrCnts;
}
/**
* 获取订单统计数据
*
* @param orderCnts
* @return
*/
private OrderAmtsVo fetchOrderAmtsVo(List<DayStatis> orderCnts) {
OrderAmtsVo orderAmts = new OrderAmtsVo();
int size = 0;
if (orderCnts != null && orderCnts.size() > 0) {
size = orderCnts.size();
}
String[] dayData = new String[size];
int[] orderCntData = new int[size];
BigDecimal[] orderAmtData = new BigDecimal[size];
for (int i = 0; i < size; i++) {
dayData[i] = orderCnts.get(i).getDayStr();
orderCntData[i] = orderCnts.get(i).getCnts();
orderAmtData[i] = orderCnts.get(i).getAmts();
}
orderAmts.setDayData(dayData);
orderAmts.setOrderAmtData(orderAmtData);
orderAmts.setOrderCntData(orderCntData);
return orderAmts;
}
}
package com.jbp.admin.web;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.jbp.admin.annotation.RequiresPermissionsDesc;
import com.jbp.admin.util.AuthSupport;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.jbp.core.util.ResponseUtil;
import com.jbp.core.validator.Order;
import com.jbp.core.validator.Sort;
import com.jbp.db.domain.DtsFeedback;
import com.jbp.db.service.DtsFeedbackService;
/**
* @author CHENBO
* @date 2018/8/26 01:11
* @QQ 623659388
*/
@RestController
@RequestMapping("/admin/feedback")
@Validated
public class AdminFeedbackController {
private static final Logger logger = LoggerFactory.getLogger(AdminFeedbackController.class);
@Autowired
private DtsFeedbackService feedbackService;
@RequiresPermissions("admin:feedback:list")
@RequiresPermissionsDesc(menu = { "用户管理", "意见反馈" }, button = "查询")
@GetMapping("/list")
public Object list(Integer userId, String username, @RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 用户管理->意见反馈->查询,请求参数:userId:{},username:{},page:{}", userId, username, page);
List<DtsFeedback> feedbackList = feedbackService.querySelective(userId, username, page, limit, sort, order);
long total = PageInfo.of(feedbackList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", feedbackList);
logger.info("【请求结束】用户管理->意见反馈->查询,响应结果:{}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data);
}
}
package com.jbp.admin.web;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.jbp.admin.annotation.RequiresPermissionsDesc;
import com.jbp.admin.util.AuthSupport;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.jbp.core.util.ResponseUtil;
import com.jbp.core.validator.Order;
import com.jbp.core.validator.Sort;
import com.jbp.db.domain.DtsFootprint;
import com.jbp.db.service.DtsFootprintService;
@RestController
@RequestMapping("/admin/footprint")
@Validated
public class AdminFootprintController {
private static final Logger logger = LoggerFactory.getLogger(AdminFootprintController.class);
@Autowired
private DtsFootprintService footprintService;
@RequiresPermissions("admin:footprint:list")
@RequiresPermissionsDesc(menu = { "用户管理", "用户足迹" }, button = "查询")
@GetMapping("/list")
public Object list(String userId, String goodsId, @RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 用户管理->用户足迹->查询,请求参数:userId:{},goodsId:{},page:{}", userId, goodsId, page);
List<DtsFootprint> footprintList = footprintService.querySelective(userId, goodsId, page, limit, sort, order);
long total = PageInfo.of(footprintList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", footprintList);
logger.info("【请求结束】用户管理->用户足迹->查询,响应结果:{}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data);
}
}
package com.jbp.admin.web;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.validation.constraints.NotNull;
import com.jbp.admin.annotation.RequiresPermissionsDesc;
import com.jbp.admin.service.AdminDataAuthService;
import com.jbp.admin.service.AdminGoodsService;
import com.jbp.admin.util.AuthSupport;
import com.jbp.admin.dao.ItemVo;
import com.jbp.admin.util.CatVo;
import com.jbp.db.domain.Category;
import com.jbp.db.service.CategoryService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.util.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.jbp.core.util.ResponseUtil;
import com.jbp.core.validator.Order;
import com.jbp.core.validator.Sort;
@RestController
@RequestMapping("/admin/goods")
@Validated
public class AdminGoodsController {
private static final Logger logger = LoggerFactory.getLogger(AdminGoodsController.class);
@Autowired
private AdminGoodsService adminGoodsService;
@Autowired
private CategoryService categoryService;
@Autowired
private AdminDataAuthService adminDataAuthService;
/**
* 查询商品
*
* @param name
* @param page
* @param limit
* @param sort
* @param order
* @return
*/
@RequiresPermissions("admin:" +
":list")
@RequiresPermissionsDesc(menu = { "商品管理", "商品管理" }, button = "查询")
@GetMapping("/list")
public Object list(String name, @RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "created") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商品管理->商品管理->查询,请求参数:name:{},page:{}", name, page);
return adminGoodsService.list(name, page, limit, sort, order);
}
/**
* 编辑商品
*
* @param itemVo
* @return
*/
@RequiresPermissions("admin:goods:update")
@RequiresPermissionsDesc(menu = { "商品管理", "商品管理" }, button = "编辑")
@PostMapping("/update")
public Object update(@RequestBody ItemVo itemVo) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商品管理->商品管理->编辑,请求参数:{}", JSONObject.toJSONString(itemVo));
return adminGoodsService.update(itemVo.toItem());
}
/**
* 删除商品
*
* @param item
* @return
*/
@RequiresPermissions("admin:goods:delete")
@RequiresPermissionsDesc(menu = { "商品管理", "商品管理" }, button = "删除")
@PostMapping("/delete")
public Object delete(@RequestBody ItemVo item) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商品管理->商品管理->删除,请求参数:{}", JSONObject.toJSONString(item));
return adminGoodsService.delete(item.toItem());
}
/**
* 添加商品
*
* @param itemVo
* @return
*/
@RequiresPermissions("admin:goods:create")
@RequiresPermissionsDesc(menu = { "商品管理", "商品管理" }, button = "上架")
@PostMapping("/create")
public Object create(@RequestBody ItemVo itemVo) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商品管理->商品管理->上架,请求参数:{}", JSONObject.toJSONString(itemVo));
return adminGoodsService.create(itemVo.toItem());
}
/**
* 商品详情
*
* @param id
* @return
*/
@RequiresPermissions("admin:goods:read")
@RequiresPermissionsDesc(menu = { "商品管理", "商品管理" }, button = "详情")
@GetMapping("/detail")
public Object detail(@NotNull Long id) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商品管理->商品管理->详情,请求参数,id:{}", id);
return adminGoodsService.detail(id);
}
@RequiresPermissions("admin:goods:create")
@RequiresPermissionsDesc(menu = { "商品管理", "商品管理" }, button = "详情")
@GetMapping("/listCategories")
public Object listCategories() {
// http://element-cn.eleme.io/#/zh-CN/component/cascader
// 管理员设置“所属分类”
Map<String, Object> data = new HashMap<>();
data.put("categoryList", getChildCat(0));
return ResponseUtil.ok(data);
}
private List<CatVo> getChildCat(Integer parentId) {
List<Category> rawChildren = categoryService.queryByPid(parentId);
if (CollectionUtils.isEmpty(rawChildren)) {
return null;
}
List<CatVo> children = new ArrayList<>(rawChildren.size());
for (Category c : rawChildren) {
CatVo catVo = new CatVo();
catVo.setValue(c.getId());
catVo.setLabel(c.getName());
catVo.setChildren(getChildCat(c.getId()));
children.add(catVo);
}
return children;
}
}
package com.jbp.admin.web;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.jbp.admin.annotation.RequiresPermissionsDesc;
import com.jbp.admin.util.AuthSupport;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.jbp.core.util.ResponseUtil;
import com.jbp.core.validator.Order;
import com.jbp.core.validator.Sort;
import com.jbp.db.domain.DtsSearchHistory;
import com.jbp.db.service.DtsSearchHistoryService;
@RestController
@RequestMapping("/admin/history")
public class AdminHistoryController {
private static final Logger logger = LoggerFactory.getLogger(AdminHistoryController.class);
@Autowired
private DtsSearchHistoryService searchHistoryService;
@RequiresPermissions("admin:history:list")
@RequiresPermissionsDesc(menu = { "用户管理", "搜索历史" }, button = "查询")
@GetMapping("/list")
public Object list(String userId, String keyword, @RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 用户管理->搜索历史->查询,请求参数:userId:{},keyword:{},page:{}", userId, keyword, page);
List<DtsSearchHistory> footprintList = searchHistoryService.querySelective(userId, keyword, page, limit, sort,
order);
long total = PageInfo.of(footprintList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", footprintList);
logger.info("【请求结束】用户管理->搜索历史->查询,响应结果:{}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data);
}
}
package com.jbp.admin.web;
import com.jbp.admin.annotation.RequiresPermissionsDesc;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresGuest;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.apache.shiro.authz.annotation.RequiresUser;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jbp.core.util.ResponseUtil;
@RestController
@RequestMapping("/admin/index")
public class AdminIndexController {
@RequestMapping("/index")
public Object index() {
return ResponseUtil.ok("hello world, this is admin service");
}
@RequiresGuest
@RequestMapping("/guest")
public Object guest() {
return ResponseUtil.ok("hello world, this is admin service");
}
@RequiresAuthentication
@RequestMapping("/authn")
public Object authn() {
return ResponseUtil.ok("hello world, this is admin service");
}
@RequiresUser
@RequestMapping("/user")
public Object user() {
return ResponseUtil.ok("hello world, this is admin service");
}
@RequiresRoles("admin")
@RequestMapping("/admin")
public Object admin() {
return ResponseUtil.ok("hello world, this is admin service");
}
@RequiresRoles("admin2")
@RequestMapping("/admin2")
public Object admin2() {
return ResponseUtil.ok("hello world, this is admin service");
}
@RequiresPermissions("index:permission:read")
@RequiresPermissionsDesc(menu = { "其他", "权限测试" }, button = "权限读")
@GetMapping("/read")
public Object read() {
return ResponseUtil.ok("hello world, this is admin service");
}
@RequiresPermissions("index:permission:write")
@RequiresPermissionsDesc(menu = { "其他", "权限测试" }, button = "权限写")
@PostMapping("/write")
public Object write() {
return ResponseUtil.ok("hello world, this is admin service");
}
}
package com.jbp.admin.web;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.validation.constraints.NotNull;
import com.jbp.admin.annotation.RequiresPermissionsDesc;
import com.jbp.admin.util.AuthSupport;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.jbp.core.util.ResponseUtil;
import com.jbp.core.validator.Order;
import com.jbp.core.validator.Sort;
import com.jbp.db.domain.DtsIssue;
import com.jbp.db.service.DtsIssueService;
@RestController
@RequestMapping("/admin/issue")
@Validated
public class AdminIssueController {
private static final Logger logger = LoggerFactory.getLogger(AdminIssueController.class);
@Autowired
private DtsIssueService issueService;
@RequiresPermissions("admin:issue:list")
@RequiresPermissionsDesc(menu = { "商场管理", "通用问题" }, button = "查询")
@GetMapping("/list")
public Object list(String question, @RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->通用问题->查询,请求参数:question:{},page:{}", question, page);
List<DtsIssue> issueList = issueService.querySelective(question, page, limit, sort, order);
long total = PageInfo.of(issueList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", issueList);
logger.info("【请求结束】商场管理->通用问题->查询,响应结果:{}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data);
}
private Object validate(DtsIssue issue) {
String question = issue.getQuestion();
if (StringUtils.isEmpty(question)) {
return ResponseUtil.badArgument();
}
String answer = issue.getAnswer();
if (StringUtils.isEmpty(answer)) {
return ResponseUtil.badArgument();
}
return null;
}
@RequiresPermissions("admin:issue:create")
@RequiresPermissionsDesc(menu = { "商场管理", "通用问题" }, button = "添加")
@PostMapping("/create")
public Object create(@RequestBody DtsIssue issue) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->通用问题->添加,请求参数:question:{},page:{}", JSONObject.toJSONString(issue));
Object error = validate(issue);
if (error != null) {
return error;
}
issueService.add(issue);
logger.info("【请求结束】商场管理->通用问题->查询,响应结果:{}", JSONObject.toJSONString(issue));
return ResponseUtil.ok(issue);
}
@RequiresPermissions("admin:issue:read")
@GetMapping("/read")
public Object read(@NotNull Integer id) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->通用问题->详情,请求参数,id:{}", id);
DtsIssue issue = issueService.findById(id);
logger.info("【请求结束】商场管理->通用问题->详情,响应结果:{}", JSONObject.toJSONString(issue));
return ResponseUtil.ok(issue);
}
@RequiresPermissions("admin:issue:update")
@RequiresPermissionsDesc(menu = { "商场管理", "通用问题" }, button = "编辑")
@PostMapping("/update")
public Object update(@RequestBody DtsIssue issue) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->通用问题->编辑,请求参数:{}", JSONObject.toJSONString(issue));
Object error = validate(issue);
if (error != null) {
return error;
}
if (issueService.updateById(issue) == 0) {
logger.error("商场管理->通用问题->编辑 失败:{}", "更新数据失败!");
return ResponseUtil.updatedDataFailed();
}
logger.info("【请求结束】商场管理->通用问题->编辑,响应结果:{}", JSONObject.toJSONString(issue));
return ResponseUtil.ok(issue);
}
@RequiresPermissions("admin:issue:delete")
@RequiresPermissionsDesc(menu = { "商场管理", "通用问题" }, button = "删除")
@PostMapping("/delete")
public Object delete(@RequestBody DtsIssue issue) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->通用问题->删除,请求参数:{}", JSONObject.toJSONString(issue));
Integer id = issue.getId();
if (id == null) {
return ResponseUtil.badArgument();
}
issueService.deleteById(id);
logger.info("【请求结束】商场管理->通用问题->删除,响应结果:{}", "成功!");
return ResponseUtil.ok();
}
}
package com.jbp.admin.web;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.validation.constraints.NotNull;
import com.jbp.admin.annotation.RequiresPermissionsDesc;
import com.jbp.admin.util.AuthSupport;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.jbp.core.util.ResponseUtil;
import com.jbp.core.validator.Order;
import com.jbp.core.validator.Sort;
import com.jbp.db.domain.DtsKeyword;
import com.jbp.db.service.DtsKeywordService;
@RestController
@RequestMapping("/admin/keyword")
@Validated
public class AdminKeywordController {
private static final Logger logger = LoggerFactory.getLogger(AdminKeywordController.class);
@Autowired
private DtsKeywordService keywordService;
@RequiresPermissions("admin:keyword:list")
@RequiresPermissionsDesc(menu = { "商场管理", "关键词" }, button = "查询")
@GetMapping("/list")
public Object list(String keyword, String url, @RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->关键词->查询,请求参数:keyword:{},url:{},page:{}", keyword, url, page);
List<DtsKeyword> brandList = keywordService.querySelective(keyword, url, page, limit, sort, order);
long total = PageInfo.of(brandList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", brandList);
logger.info("【请求结束】商场管理->关键词->查询,响应结果:{}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data);
}
private Object validate(DtsKeyword keywords) {
String keyword = keywords.getKeyword();
if (StringUtils.isEmpty(keyword)) {
return ResponseUtil.badArgument();
}
String url = keywords.getUrl();
if (StringUtils.isEmpty(url)) {
return ResponseUtil.badArgument();
}
return null;
}
@RequiresPermissions("admin:keyword:create")
@RequiresPermissionsDesc(menu = { "商场管理", "关键词" }, button = "添加")
@PostMapping("/create")
public Object create(@RequestBody DtsKeyword keywords) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->关键词->添加,请求参数:{}", JSONObject.toJSONString(keywords));
Object error = validate(keywords);
if (error != null) {
return error;
}
keywordService.add(keywords);
logger.info("【请求结束】商场管理->关键词->添加,响应结果:{}", JSONObject.toJSONString(keywords));
return ResponseUtil.ok(keywords);
}
@RequiresPermissions("admin:keyword:read")
@RequiresPermissionsDesc(menu = { "商场管理", "关键词" }, button = "详情")
@GetMapping("/read")
public Object read(@NotNull Integer id) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->关键词->详情,请求参数,id:{}", id);
DtsKeyword keywords = keywordService.findById(id);
logger.info("【请求结束】商场管理->关键词->详情,响应结果:{}", JSONObject.toJSONString(keywords));
return ResponseUtil.ok(keywords);
}
@RequiresPermissions("admin:keyword:update")
@RequiresPermissionsDesc(menu = { "商场管理", "关键词" }, button = "编辑")
@PostMapping("/update")
public Object update(@RequestBody DtsKeyword keywords) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->关键词->编辑,请求参数:{}", JSONObject.toJSONString(keywords));
Object error = validate(keywords);
if (error != null) {
return error;
}
if (keywordService.updateById(keywords) == 0) {
logger.info("商场管理->关键词->编辑 错误:{}", "更新数据失败!");
return ResponseUtil.updatedDataFailed();
}
logger.info("【请求结束】商场管理->关键词->编辑,响应结果:{}", JSONObject.toJSONString(keywords));
return ResponseUtil.ok(keywords);
}
@RequiresPermissions("admin:keyword:delete")
@RequiresPermissionsDesc(menu = { "商场管理", "关键词" }, button = "删除")
@PostMapping("/delete")
public Object delete(@RequestBody DtsKeyword keyword) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->关键词->删除,请求参数:{}", JSONObject.toJSONString(keyword));
Integer id = keyword.getId();
if (id == null) {
return ResponseUtil.badArgument();
}
keywordService.deleteById(id);
logger.info("【请求结束】商场管理->关键词->删除,响应结果:{}", "成功!");
return ResponseUtil.ok();
}
}
package com.jbp.admin.web;
import com.jbp.admin.util.AuthSupport;
import com.jbp.admin.util.AdminResponseCode;
import com.jbp.admin.util.AdminResponseUtil;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jbp.core.util.JacksonUtil;
import com.jbp.core.util.ResponseUtil;
import com.jbp.core.util.bcrypt.BCryptPasswordEncoder;
import com.jbp.db.domain.DtsAdmin;
import com.jbp.db.service.DtsAdminService;
@RestController
@RequestMapping("/admin/profile")
@Validated
public class AdminProfileController {
private static final Logger logger = LoggerFactory.getLogger(AdminProfileController.class);
@Autowired
private DtsAdminService adminService;
@RequiresAuthentication
@PostMapping("/password")
public Object create(@RequestBody String body) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 系统管理->修改密码,请求参数,body:{}", body);
String oldPassword = JacksonUtil.parseString(body, "oldPassword");
String newPassword = JacksonUtil.parseString(body, "newPassword");
if (StringUtils.isEmpty(oldPassword)) {
return ResponseUtil.badArgument();
}
if (StringUtils.isEmpty(newPassword)) {
return ResponseUtil.badArgument();
}
Subject currentUser = SecurityUtils.getSubject();
DtsAdmin admin = (DtsAdmin) currentUser.getPrincipal();
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
if (!encoder.matches(oldPassword, admin.getPassword())) {
logger.info("系统管理->修改密码 错误:{}", AdminResponseCode.ADMIN_INVALID_OLD_PASSWORD.desc());
return AdminResponseUtil.fail(AdminResponseCode.ADMIN_INVALID_OLD_PASSWORD);
}
String encodedNewPassword = encoder.encode(newPassword);
admin.setPassword(encodedNewPassword);
adminService.updateById(admin);
logger.info("【请求结束】系统管理->修改密码,响应结果:{}", "成功!");
return ResponseUtil.ok();
}
}
package com.jbp.admin.web;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.validation.constraints.NotNull;
import com.jbp.admin.annotation.RequiresPermissionsDesc;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.jbp.admin.util.AdminResponseCode;
import com.jbp.admin.util.AdminResponseUtil;
import com.jbp.admin.util.AuthSupport;
import com.jbp.admin.util.PermVo;
import com.jbp.admin.util.Permission;
import com.jbp.admin.util.PermissionUtil;
import com.jbp.core.util.JacksonUtil;
import com.jbp.core.util.ResponseUtil;
import com.jbp.core.validator.Order;
import com.jbp.core.validator.Sort;
import com.jbp.db.domain.DtsPermission;
import com.jbp.db.domain.DtsRole;
import com.jbp.db.service.DtsPermissionService;
import com.jbp.db.service.DtsRoleService;
@RestController
@RequestMapping("/admin/role")
@Validated
public class AdminRoleController {
private static final Logger logger = LoggerFactory.getLogger(AdminRoleController.class);
@Autowired
private DtsRoleService roleService;
@Autowired
private DtsPermissionService permissionService;
@RequiresPermissions("admin:role:list")
@RequiresPermissionsDesc(menu = { "系统管理", "角色管理" }, button = "角色查询")
@GetMapping("/list")
public Object list(String name, @RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 系统管理->角色管理->角色查询,请求参数,name:{},page:{}", name, page);
List<DtsRole> roleList = roleService.querySelective(name, page, limit, sort, order);
long total = PageInfo.of(roleList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", roleList);
logger.info("【请求结束】系统管理->角色管理->角色查询,响应结果:{}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data);
}
@GetMapping("/options")
public Object options() {
List<DtsRole> roleList = roleService.queryAll();
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 系统管理->角色管理->查询所有角色");
List<Map<String, Object>> options = new ArrayList<>(roleList.size());
for (DtsRole role : roleList) {
Map<String, Object> option = new HashMap<>(2);
option.put("value", role.getId());
option.put("label", role.getName());
options.add(option);
}
logger.info("【请求结束】系统管理->角色管理->查询所有角色,响应结果:{}", JSONObject.toJSONString(options));
return ResponseUtil.ok(options);
}
@RequiresPermissions("admin:role:read")
@RequiresPermissionsDesc(menu = { "系统管理", "角色管理" }, button = "角色详情")
@GetMapping("/read")
public Object read(@NotNull Integer id) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 系统管理->角色管理->角色详情,请求参数,id:{}", id);
DtsRole role = roleService.findById(id);
logger.info("【请求结束】系统管理->角色管理->角色详情,响应结果:{}", JSONObject.toJSONString(role));
return ResponseUtil.ok(role);
}
private Object validate(DtsRole role) {
String name = role.getName();
if (StringUtils.isEmpty(name)) {
return ResponseUtil.badArgument();
}
return null;
}
@RequiresPermissions("admin:role:create")
@RequiresPermissionsDesc(menu = { "系统管理", "角色管理" }, button = "角色添加")
@PostMapping("/create")
public Object create(@RequestBody DtsRole role) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 系统管理->角色管理->角色添加,请求参数:{}", JSONObject.toJSONString(role));
Object error = validate(role);
if (error != null) {
return error;
}
if (roleService.checkExist(role.getName())) {
logger.info("系统管理->角色管理->角色添加错误:{}", AdminResponseCode.ROLE_NAME_EXIST.desc());
return AdminResponseUtil.fail(AdminResponseCode.ROLE_NAME_EXIST);
}
roleService.add(role);
logger.info("【请求结束】系统管理->角色管理->角色添加,响应结果:{}", JSONObject.toJSONString(role));
return ResponseUtil.ok(role);
}
@RequiresPermissions("admin:role:update")
@RequiresPermissionsDesc(menu = { "系统管理", "角色管理" }, button = "角色编辑")
@PostMapping("/update")
public Object update(@RequestBody DtsRole role) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 系统管理->角色管理->角色编辑,请求参数:{}", JSONObject.toJSONString(role));
Object error = validate(role);
if (error != null) {
return error;
}
roleService.updateById(role);
logger.info("【请求结束】系统管理->角色管理->角色编辑,响应结果:{}", "成功!");
return ResponseUtil.ok();
}
@RequiresPermissions("admin:role:delete")
@RequiresPermissionsDesc(menu = { "系统管理", "角色管理" }, button = "角色删除")
@PostMapping("/delete")
public Object delete(@RequestBody DtsRole role) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 系统管理->角色管理->角色删除,请求参数,id:{}", JSONObject.toJSONString(role));
Integer id = role.getId();
if (id == null) {
return ResponseUtil.badArgument();
}
roleService.deleteById(id);
logger.info("【请求结束】系统管理->角色管理->角色删除,响应结果:{}", "成功!");
return ResponseUtil.ok();
}
@Autowired
private ApplicationContext context;
private List<PermVo> systemPermissions = null;
private Set<String> systemPermissionsString = null;
private List<PermVo> getSystemPermissions() {
final String basicPackage = "com.wwdz.ch.admin";
if (systemPermissions == null) {
List<Permission> permissions = PermissionUtil.listPermission(context, basicPackage);
systemPermissions = PermissionUtil.listPermVo(permissions);
systemPermissionsString = PermissionUtil.listPermissionString(permissions);
}
return systemPermissions;
}
private Set<String> getAssignedPermissions(Integer roleId) {
// 这里需要注意的是,如果存在超级权限*,那么这里需要转化成当前所有系统权限。
// 之所以这么做,是因为前端不能识别超级权限,所以这里需要转换一下。
Set<String> assignedPermissions = null;
if (permissionService.checkSuperPermission(roleId)) {
getSystemPermissions();
assignedPermissions = systemPermissionsString;
} else {
assignedPermissions = permissionService.queryByRoleId(roleId);
}
return assignedPermissions;
}
/**
* 管理员的权限情况
*
* @return 系统所有权限列表和管理员已分配权限
*/
@RequiresPermissions("admin:role:permission:get")
@RequiresPermissionsDesc(menu = { "系统管理", "角色管理" }, button = "权限详情")
@GetMapping("/permissions")
public Object getPermissions(Integer roleId) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 系统管理->角色管理->权限详情,请求参数,roleId:{}", roleId);
List<PermVo> systemPermissions = getSystemPermissions();
Set<String> assignedPermissions = getAssignedPermissions(roleId);
Map<String, Object> data = new HashMap<>();
data.put("systemPermissions", systemPermissions);
data.put("assignedPermissions", assignedPermissions);
logger.info("【请求结束】系统管理->角色管理->权限详情,响应结果:{}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data);
}
/**
* 更新管理员的权限
*
* @param body
* @return
*/
@RequiresPermissions("admin:role:permission:update")
@RequiresPermissionsDesc(menu = { "系统管理", "角色管理" }, button = "权限变更")
@PostMapping("/permissions")
public Object updatePermissions(@RequestBody String body) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 系统管理->角色管理->权限变更,请求参数,body:{}", body);
Integer roleId = JacksonUtil.parseInteger(body, "roleId");
List<String> permissions = JacksonUtil.parseStringList(body, "permissions");
if (roleId == null || permissions == null) {
return ResponseUtil.badArgument();
}
// 如果修改的角色是超级权限,则拒绝修改。
if (permissionService.checkSuperPermission(roleId)) {
logger.error("系统管理->角色管理->权限变更 错误:{}", AdminResponseCode.ROLE_SUPER_SUPERMISSION.desc());
return AdminResponseUtil.fail(AdminResponseCode.ROLE_SUPER_SUPERMISSION);
}
// 先删除旧的权限,再更新新的权限
permissionService.deleteByRoleId(roleId);
for (String permission : permissions) {
DtsPermission DtsPermission = new DtsPermission();
DtsPermission.setRoleId(roleId);
DtsPermission.setPermission(permission);
permissionService.add(DtsPermission);
}
logger.info("【请求结束】系统管理->角色管理->权限变更,响应结果:{}", "成功!");
return ResponseUtil.ok();
}
}
package com.jbp.admin.web;
import java.util.List;
import java.util.Map;
import com.jbp.admin.annotation.RequiresPermissionsDesc;
import com.jbp.admin.util.AuthSupport;
import com.jbp.admin.util.StatVo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.jbp.core.util.ResponseUtil;
import com.jbp.db.service.StatService;
@SuppressWarnings("rawtypes")
@RestController
@RequestMapping("/admin/stat")
@Validated
public class AdminStatController {
private static final Logger logger = LoggerFactory.getLogger(AdminStatController.class);
@Autowired
private StatService statService;
@RequiresPermissions("admin:stat:user")
@RequiresPermissionsDesc(menu = { "统计管理", "用户统计" }, button = "查询")
@GetMapping("/user")
public Object statUser() {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 统计管理->用户统计->查询");
List<Map> rows = statService.statUser();
String[] columns = new String[] { "day", "users" };
StatVo statVo = new StatVo();
statVo.setColumns(columns);
statVo.setRows(rows);
logger.info("【请求结束】统计管理->用户统计->查询,响应结果:{}", JSONObject.toJSONString(statVo));
return ResponseUtil.ok(statVo);
}
@RequiresPermissions("admin:stat:order")
@RequiresPermissionsDesc(menu = { "统计管理", "订单统计" }, button = "查询")
@GetMapping("/order")
public Object statOrder() {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 统计管理->订单统计->查询");
List<Map> rows = statService.statOrder();
String[] columns = new String[] { "day", "orders", "customers", "amount", "pcr" };
StatVo statVo = new StatVo();
statVo.setColumns(columns);
statVo.setRows(rows);
logger.info("【请求结束】统计管理->订单统计->查询,响应结果:{}", JSONObject.toJSONString(statVo));
return ResponseUtil.ok(statVo);
}
@RequiresPermissions("admin:stat:goods")
@RequiresPermissionsDesc(menu = { "统计管理", "商品统计" }, button = "查询")
@GetMapping("/goods")
public Object statGoods() {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 统计管理->商品统计->查询");
List<Map> rows = statService.statGoods();
String[] columns = new String[] { "day", "orders", "products", "amount" };
StatVo statVo = new StatVo();
statVo.setColumns(columns);
statVo.setRows(rows);
logger.info("【请求结束】统计管理->商品统计->查询,响应结果:{}", JSONObject.toJSONString(statVo));
return ResponseUtil.ok(statVo);
}
}
package com.jbp.admin.web;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.jbp.admin.annotation.RequiresPermissionsDesc;
import com.jbp.admin.util.AuthSupport;
import com.jbp.core.storage.StorageService;
import com.jbp.core.util.ResponseUtil;
import com.jbp.core.validator.Order;
import com.jbp.core.validator.Sort;
import com.jbp.db.domain.DtsStorage;
import com.jbp.db.service.DtsStorageService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import sun.misc.BASE64Encoder;
import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/admin/storage")
@Validated
public class AdminStorageController {
private static final Logger logger = LoggerFactory.getLogger(AdminStorageController.class);
@Autowired
private StorageService storageService;
@Autowired
private DtsStorageService DtsStorageService;
@RequiresPermissions("admin:storage:list")
@RequiresPermissionsDesc(menu = { "系统管理", "对象存储" }, button = "查询")
@GetMapping("/list")
public Object list(String key, String name, @RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 系统管理->对象存储->查询,请求参数,name:{},key:{},page:{}", name, key, page);
List<DtsStorage> storageList = DtsStorageService.querySelective(key, name, page, limit, sort, order);
long total = PageInfo.of(storageList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", storageList);
logger.info("【请求结束】系统管理->对象存储->查询:响应结果:{}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data);
}
@RequiresPermissions("admin:storage:create")
@RequiresPermissionsDesc(menu = { "系统管理", "对象存储" }, button = "上传")
@PostMapping("/create")
public Object create(@RequestParam("file") MultipartFile file) throws IOException {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 系统管理->对象存储->上传,请求参数,file:{}", file.getOriginalFilename());
String originalFilename = file.getOriginalFilename();
long nowTime = System.currentTimeMillis();
String name = new BASE64Encoder().encode(Long.toString(nowTime).getBytes()) + RandomUtil.randomInt(1000);
String url = storageService.store(file.getInputStream(), file.getSize(), file.getContentType(),
name);
Map<String, Object> data = new HashMap<>();
data.put("url", url);
logger.info("【请求结束】系统管理->对象存储->查询:响应结果:{}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data);
}
@RequiresPermissions("admin:storage:read")
@RequiresPermissionsDesc(menu = { "系统管理", "对象存储" }, button = "详情")
@PostMapping("/read")
public Object read(@NotNull Integer id) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 系统管理->对象存储->详情,请求参数,id:{}", id);
DtsStorage storageInfo = DtsStorageService.findById(id);
if (storageInfo == null) {
return ResponseUtil.badArgumentValue();
}
logger.info("【请求结束】系统管理->对象存储->详情:响应结果:{}", JSONObject.toJSONString(storageInfo));
return ResponseUtil.ok(storageInfo);
}
@RequiresPermissions("admin:storage:update")
@RequiresPermissionsDesc(menu = { "系统管理", "对象存储" }, button = "编辑")
@PostMapping("/update")
public Object update(@RequestBody DtsStorage dtsStorage) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 系统管理->对象存储->编辑,请求参数:{}", JSONObject.toJSONString(dtsStorage));
if (DtsStorageService.update(dtsStorage) == 0) {
logger.error("系统管理->对象存储->编辑 错误:{}", "更新数据失败!");
return ResponseUtil.updatedDataFailed();
}
logger.info("【请求结束】系统管理->对象存储->编辑:响应结果:{}", JSONObject.toJSONString(dtsStorage));
return ResponseUtil.ok(dtsStorage);
}
@RequiresPermissions("admin:storage:delete")
@RequiresPermissionsDesc(menu = { "系统管理", "对象存储" }, button = "删除")
@PostMapping("/delete")
public Object delete(@RequestBody DtsStorage DtsStorage) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 系统管理->对象存储->删除,请求参数:{}", JSONObject.toJSONString(DtsStorage));
String key = DtsStorage.getKey();
if (StringUtils.isEmpty(key)) {
return ResponseUtil.badArgument();
}
DtsStorageService.deleteByKey(key);
storageService.delete(key);
logger.info("【请求结束】系统管理->对象存储->删除:响应结果:{}", "成功!");
return ResponseUtil.ok();
}
}
package com.jbp.admin.web;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.jbp.admin.annotation.RequiresPermissionsDesc;
import com.jbp.admin.util.AuthSupport;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.jbp.core.util.ResponseUtil;
import com.jbp.core.validator.Order;
import com.jbp.core.validator.Sort;
import com.jbp.db.domain.DtsUser;
import com.jbp.db.service.DtsUserService;
@RestController
@RequestMapping("/admin/user")
@Validated
public class AdminUserController {
private static final Logger logger = LoggerFactory.getLogger(AdminUserController.class);
@Autowired
private DtsUserService userService;
@RequiresPermissions("admin:user:list")
@RequiresPermissionsDesc(menu = { "用户管理", "会员管理" }, button = "查询")
@GetMapping("/list")
public Object list(String username, String mobile, @RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 用户管理->会员管理->查询,请求参数,username:{},code:{},page:{}", username, mobile, page);
List<DtsUser> userList = userService.querySelective(username, mobile, page, limit, sort, order);
long total = PageInfo.of(userList).getTotal();
Map<String, Object> data = new HashMap<>();
data.put("total", total);
data.put("items", userList);
logger.info("【请求结束】用户管理->会员管理->查询:响应结果:{}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data);
}
}
package com.jbp.admin.web;
import com.jbp.admin.util.AuthSupport;
import com.jbp.admin.dao.BidRecordVo;
import com.jbp.core.type.ListResult;
import com.jbp.core.type.SimpleResult;
import com.jbp.db.domain.BidRecord;
import com.jbp.db.service.BidRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/admin/bidrecord")
@Validated
@Api
public class BidRecordController {
private static final Logger logger = LoggerFactory.getLogger(CategoryController.class);
@Autowired
private BidRecordService bidRecordService;
// @RequiresPermissions("admin:category:list")
// @RequiresPermissionsDesc(menu = { "商场管理", "成交记录管理" }, button = "查询")
@GetMapping("/list")
@ApiOperation(value = "成交记录列表")
public ListResult<BidRecordVo> list(@ApiParam("分类id") Integer cid) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->成交记录->查询,请求参数:cid:{}", cid);
List<BidRecord> collectList = bidRecordService.queryByCid(cid);
List<BidRecordVo> data = collectList.parallelStream().map(a -> new BidRecordVo(a)).collect(Collectors.toList());
return new ListResult<BidRecordVo>(data, data.size());
}
@PostMapping("/add")
@ApiOperation(value = "添加成交记录")
public SimpleResult<Boolean> add(@ApiParam("成交记录数据") @RequestBody BidRecordVo record) {
bidRecordService.add(record.toDo());
return new SimpleResult<>(true);
}
@GetMapping("/delete")
@ApiOperation(value = "删除成交记录")
public SimpleResult<Boolean> delete(@ApiParam("成交记录ID") @NotNull Long id) {
bidRecordService.deleteById(id);
return new SimpleResult<>(true);
}
}
package com.jbp.admin.web;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.validation.constraints.NotNull;
import com.jbp.admin.annotation.RequiresPermissionsDesc;
import com.jbp.admin.util.AuthSupport;
import com.jbp.admin.dao.CategoryVo;
import com.jbp.core.type.ListResult;
import com.jbp.db.domain.Category;
import com.jbp.db.service.CategoryService;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.jbp.core.util.ResponseUtil;
import com.jbp.core.validator.Order;
import com.jbp.core.validator.Sort;
import com.jbp.db.domain.DtsCategory;
@RestController
@RequestMapping("/admin/category")
@Validated
public class CategoryController {
private static final Logger logger = LoggerFactory.getLogger(CategoryController.class);
@Autowired
private CategoryService categoryService;
@RequiresPermissions("admin:category:list")
@RequiresPermissionsDesc(menu = { "商场管理", "类目管理" }, button = "查询")
@GetMapping("/list")
public ListResult<CategoryVo> list(String id, String name, @RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->类目管理->查询,请求参数:name:{},page:{}", name, page);
List<Category> collectList = categoryService.querySelective(id, name, page, limit, sort, order);
List<CategoryVo> data = collectList.parallelStream().map(a -> new CategoryVo(a)).collect(Collectors.toList());
logger.info("【请求结束】商场管理->类目管理->查询:total:{}", JSONObject.toJSONString(data));
return new ListResult<>(data, data.size());
}
@RequiresPermissions("admin:category:tree")
@RequiresPermissionsDesc(menu = { "商场管理", "类目管理" }, button = "查询")
@GetMapping("/tree")
public ListResult<CategoryVo> tree() {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 查询类目树");
/**
* 获取最大深度
*/
Integer maxLevel = categoryService.getMaxCagtegoryLevel();
Integer level = maxLevel;
Map<Integer, List<CategoryVo>> parentCategoryMap = new HashMap<>();
while (level > 0) {
List<Category> categoryList = categoryService.queryByLevel(level, 0, 10000);
for (Category c : categoryList) {
Integer parentId = c.getPid();
List<CategoryVo> children = parentCategoryMap.get(parentId);
if (null == children) {
children = new ArrayList<>();
parentCategoryMap.put(parentId, children);
}
CategoryVo cv = new CategoryVo(c);
if (!maxLevel.equals(level)) {
cv.setChildren(parentCategoryMap.get(c.getId()));
}
children.add(cv);
}
--level;
}
List<CategoryVo> data = parentCategoryMap.get(0);
return new ListResult<>(data, data.size());
}
@RequiresPermissions("admin:category:tree")
@RequiresPermissionsDesc(menu = { "商场管理", "类目管理" }, button = "查询")
@GetMapping("/getSubCategory")
public Object getSubCategory(@NotNull Integer id) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 查询根据类目ID查询子类目");
List<CategoryVo> categoryVoList = new ArrayList<>();
List<Category> categoryList = categoryService.queryByPid(id);
for (Category c : categoryList) {
CategoryVo categoryVo = new CategoryVo(c);
categoryVo.setCategoryPath(StringUtils.join(categoryService.getCategoryPath(c.getId()), ">"));
categoryVoList.add(new CategoryVo(c));
}
Map<String, Object> data = new HashMap<>();
data.put("categoryList", categoryVoList);
data.put("categoryPath", categoryService.getCategoryPath(id));
logger.info("【请求结束】查询根据类目ID查询子类目 : {}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data);
}
@RequiresPermissions("admin:category:create")
@RequiresPermissionsDesc(menu = { "商场管理", "类目管理" }, button = "添加")
@PostMapping("/create")
public Object create(@RequestBody CategoryVo categoryVo) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->类目管理->添加,请求参数:{}", JSONObject.toJSONString(categoryVo));
Integer pid = categoryVo.getPid();
Category category = categoryVo.toDo();
if (null != pid) {
Category pCat = new Category();
pCat.setId(pid);
pCat.setIsLeaf(false);
categoryService.updateById(pCat);
} else {
category.setIsLeaf(true);
}
categoryService.add(category);
logger.info("【请求结束】商场管理->类目管理->添加:响应结果:{}", JSONObject.toJSONString(category));
return ResponseUtil.ok(category);
}
@RequiresPermissions("admin:category:read")
@RequiresPermissionsDesc(menu = { "商场管理", "类目管理" }, button = "详情")
@GetMapping("/read")
public Object read(@NotNull Integer id) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->类目管理->详情,请求参数,id:{}", id);
Category category = categoryService.findById(id);
logger.info("【请求结束】商场管理->类目管理->详情:响应结果:{}", JSONObject.toJSONString(category));
return ResponseUtil.ok(category);
}
@RequiresPermissions("admin:category:update")
@RequiresPermissionsDesc(menu = { "商场管理", "类目管理" }, button = "编辑")
@PostMapping("/update")
public Object update(@RequestBody CategoryVo categoryVo) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->类目管理->编辑,请求参数:{}", JSONObject.toJSONString(categoryVo));
if (categoryService.updateById(categoryVo.toDo()) == 0) {
logger.error("商场管理->类目管理->编辑 失败,更新数据失败!");
return ResponseUtil.updatedDataFailed();
}
logger.info("【请求结束】商场管理->类目管理->编辑:响应结果:{}", "成功!");
return ResponseUtil.ok();
}
@RequiresPermissions("admin:category:delete")
@RequiresPermissionsDesc(menu = { "商场管理", "类目管理" }, button = "删除")
@PostMapping("/delete")
public Object delete(@RequestBody DtsCategory category) {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->类目管理->删除,请求参数:{}", JSONObject.toJSONString(category));
Integer id = category.getId();
if (id == null) {
return ResponseUtil.badArgument();
}
categoryService.deleteById(id);
logger.info("【请求结束】商场管理->类目管理->删除:响应结果:{}", "成功!");
return ResponseUtil.ok();
}
@RequiresPermissions("admin:category:list")
@GetMapping("/l1")
public Object catL1() {
logger.info("【请求开始】操作人:[" + AuthSupport.userName()+ "] 商场管理->类目管理->一级分类目录查询");
// 所有一级分类目录
List<Category> l1CatList = categoryService.queryByLevel(1, 1 ,100);
List<Map<String, Object>> data = new ArrayList<>(l1CatList.size());
for (Category category : l1CatList) {
Map<String, Object> d = new HashMap<>(2);
d.put("value", category.getId());
d.put("label", category.getName());
data.add(d);
}
logger.info("【请求结束】商场管理->类目管理->一级分类目录查询:total:{}", JSONObject.toJSONString(data));
return ResponseUtil.ok(data);
}
}
package com.jbp.admin.web;
public class UgcCoinController {
}
<?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">
<parent>
<artifactId>sph_system</artifactId>
<groupId>com.jbp</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>api</artifactId>
<dependencies>
<dependency>
<groupId>com.wwdz.mall</groupId>
<artifactId>module-common</artifactId>
<version>3.1.3</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.83</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
\ No newline at end of file
package com.jbp.api.pack;
import com.jbp.api.pack.request.PackQrcodeBindRequest;
import com.jbp.api.pack.request.PackQrcodePageParam;
import com.jbp.api.pack.response.PackQrcodeDTO;
import com.jbp.appraisal.base.PageQueryResult;
import com.wwdz.mall.common.vo.response.CloudServerResponse;
/**
* @author fengchen
* created 2021/3/1 3:51 下午
* Copyright © 2020 wanwudezhi.com. All rights reserved.
*/
public interface PackQrcodeService {
/**
* 创建一批二维码
*
* @param count 数量,最多10000
* @return
*/
CloudServerResponse<String> batchCreate(Integer count, Long operatorId);
/**
* 导出分页查询,不包含count
* @param param
* @return
*/
CloudServerResponse<PageQueryResult<PackQrcodeDTO>> exportPage(PackQrcodePageParam param);
/**
* 普通分页查询
* @param param
* @return
*/
CloudServerResponse<PageQueryResult<PackQrcodeDTO>> queryPage(PackQrcodePageParam param);
/**
* 绑定溯源码与二维码
* 必须两者都没有绑定过
* @return
*/
CloudServerResponse<Boolean> bind(PackQrcodeBindRequest request);
/**
* 重新绑定溯源码与二维码
* 必须保证,新的二维码没有绑定过
* @return
*/
CloudServerResponse<Boolean> rebind(PackQrcodeBindRequest request);
/**
* 根据二维码的包装码来查询
*
* @param packCode
* @return
*/
CloudServerResponse<PackQrcodeDTO> getByPackCode(String packCode);
}
package com.jbp.api.pack.constant;
import java.util.HashMap;
import java.util.Map;
/**
* @author fengchen
* created 2021/3/1 3:54 下午
* Copyright © 2020 wanwudezhi.com. All rights reserved.
*/
public enum PackQrcodeStatusEnum {
UNBINDED(0, "未绑定"),
BINDED(1, "已绑定"),
TRANGED(2, "已绑定"),
;
private Integer code;
private String desc;
PackQrcodeStatusEnum(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
private static Map<Integer, PackQrcodeStatusEnum> statusEnumMap;
static {
statusEnumMap = new HashMap<>();
for (PackQrcodeStatusEnum statusEnum : PackQrcodeStatusEnum.values()) {
statusEnumMap.put(statusEnum.getCode(), statusEnum);
}
}
public static PackQrcodeStatusEnum getByCode(int code) {
return statusEnumMap.get(code);
}
public Integer getCode() {
return code;
}
public String getDesc() {
return desc;
}
}
package com.jbp.api.pack.request;
import lombok.Data;
import java.io.Serializable;
/**
* @author fengchen
* created 2021/3/2 3:44 下午
* Copyright © 2020 wanwudezhi.com. All rights reserved.
*/
@Data
public class PackQrcodeBindRequest implements Serializable {
private static final long serialVersionUID = 8395267406865028138L;
/**
* 溯源码
*/
private String traceCode;
/**
* 二维码
*/
private String qrcode;
/**
* 仓库ID
*/
private Integer warehouseId;
/**
* 操作者ID
*/
private Long operatorId;
}
package com.jbp.api.pack.request;
import com.jbp.appraisal.base.BasePageQueryParam;
import lombok.Data;
import java.io.Serializable;
/**
* 分页查询参数
*
* @author fengchen
* created 2021/3/1 4:14 下午
* Copyright © 2020 wanwudezhi.com. All rights reserved.
*/
@Data
public class PackQrcodePageParam extends BasePageQueryParam implements Serializable {
private static final long serialVersionUID = -3491747970652034253L;
/**
* 批次
*/
private String batch;
/**
* 溯源码
*/
private String traceCode;
/**
* 状态
*/
private Integer status;
/**
* 操作开始时间:秒级时间戳
*/
private Integer startTime;
/**
* 操作结束时间:秒级时间戳
*/
private Integer endTime;
}
package com.jbp.api.pack.response;
import lombok.Data;
import java.io.Serializable;
/**
* @author fengchen
* created 2021/3/1 3:51 下午
* Copyright © 2020 wanwudezhi.com. All rights reserved.
*/
@Data
public class PackQrcodeDTO implements Serializable {
private static final long serialVersionUID = -6868319941340525053L;
/**
* 批次
*
* @mbggenerated
*/
private String batch;
/**
* 封标码
*
* @mbggenerated
*/
private String packCode;
/**
* 对应二维码,短链链接
*
* @mbggenerated
*/
private String qrCode;
/**
* 状态:0,未绑定;1,已绑定;2,已换绑
*
* @mbggenerated
*/
private Integer status;
/**
* 溯源码
*
* @mbggenerated
*/
private String traceCode;
/**
* 最后一个操作用户ID
*
* @mbggenerated
*/
private Long operatorId;
/**
* 最后一个操作用户名
*
* @mbggenerated
*/
private String operatorName;
private String created;
private String updated;
}
package com.jbp.api.sellerwarehouse;
import com.jbp.api.sellerwarehouse.request.ApproveWarehouseApplyRequest;
import com.jbp.api.sellerwarehouse.request.OperateWarehouseChangeRequest;
import com.jbp.api.sellerwarehouse.request.SellerWarehouseApplyQuery;
import com.jbp.api.sellerwarehouse.response.*;
import com.jbp.appraisal.base.PageQueryResult;
import com.jbp.appraisal.vo.response.EnumResponse;
import com.wwdz.mall.common.vo.response.CloudServerResponse;
import java.util.List;
/**
* @author fengchen
* created 2020/12/10 10:39 上午
* Copyright © 2020 wanwudezhi.com. All rights reserved.
*/
public interface SellerWarehouseService {
/**
* 请求商家当前的分仓信息
* @param sellerId 卖家用户ID
* @return 如果没有分仓,返回 null
*/
CloudServerResponse<SellerWarehouseInfoDTO> getSellerCurrentWarehouse(Long sellerId);
/**
* 查询卖家改仓申请记录,不分页查询所有
* 只获取商家主动申请的记录
*
* @param sellerId
* @return
*/
CloudServerResponse<List<SellerWarehouseApplyDTO>> listSellerWarehouseApplyBySellerId(Long sellerId);
/**
* 卖家更新主营类目
* @param sellerId 卖家用户ID
* @param categoryId
* @return
*/
CloudServerResponse<SellerWarehouseUpdateInfoDTO> updateSellerCategory(Long sellerId, Long categoryId);
/**
* 查询类目可选的仓库列表
* @param categoryId
* @return
*/
CloudServerResponse<List<CategoryWarehouseDTO>> listCategoryWarehouse(Long categoryId);
/**
* 卖家申请更换仓库
* @param sellerId
* @param warehouseId
* @return
*/
CloudServerResponse<Boolean> applyWarehouse(Long sellerId, Long warehouseId);
/**
* 卖家撤回更换仓库申请
* @param sellerId
* @param recordId 申请记录ID
* @return
*/
CloudServerResponse<Boolean> cancelApplyWarehouse(Long sellerId, Long recordId);
/**
* 客服审批商家的改仓申请
* @param request
* @return
*/
CloudServerResponse<Boolean> approveWarehouseApply(ApproveWarehouseApplyRequest request);
/**
* 查询所有的申请状态
* @return
*/
CloudServerResponse<List<SellerWarehouseApplyStatusDTO>> listSellerWarehouseApplyStatus();
/**
* 分页查询申请记录
* @return
*/
CloudServerResponse<PageQueryResult<SellerWarehouseApplyDTO>> queryApplyRecord(SellerWarehouseApplyQuery query);
/**
* 运营改仓
* @param changeRequest
* @return
*/
CloudServerResponse<Boolean> updateByOperator(OperateWarehouseChangeRequest changeRequest);
/**
* 获取改仓类型
* @return
*/
CloudServerResponse<List<EnumResponse>> getSellerWarehouseApplyTypeEnum();
/**
* 获取seller信息
* @param sellerId
* @return
*/
CloudServerResponse<WarehouseSellerResponseDTO> getSellerInfo(Long sellerId);
/**
* 获取seller信息
* @param sellerId
* @return
*/
CloudServerResponse<Integer> countByDate(Long sellerId);
/**
* 卖家更新主营类目
* @param sellerId 卖家用户ID
* @param categoryId
* @return
*/
CloudServerResponse<Boolean> updateToCSellerCategory(Long sellerId, Long categoryId);
}
package com.jbp.api.sellerwarehouse.request;
import lombok.Data;
import java.io.Serializable;
/**
* @author fengchen
* created 2020/12/14 8:16 下午
* Copyright © 2020 wanwudezhi.com. All rights reserved.
*/
@Data
public class ApproveWarehouseApplyRequest implements Serializable {
private static final long serialVersionUID = -4719756975090618118L;
/**
* 申请的记录ID
*/
private Long recordId;
/**
* 是否通过
*/
private Boolean pass;
/**
* 原因
*/
private String reason;
/**
* 审批人ID
*/
private Long approverId;
}
package com.jbp.api.sellerwarehouse.request;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* Created by zhoun on 2021/3/26
*/
@Data
public class AttributeRequestParam implements Serializable {
private static final long serialVersionUID = 8277376689046282286L;
private Integer id;
/**
* 类目id
*
* @mbggenerated
*/
private Integer categoryId;
/**
* 属性中文名
*
* @mbggenerated
*/
private String chName;
/**
* 属性英文名
*
* @mbggenerated
*/
private String enName;
/**
* 拼音
*
* @mbggenerated
*/
private String pinyin;
/**
* 默认值
*
* @mbggenerated
*/
private String defaultValue;
/**
* 类型:1:单行文本
*
* @mbggenerated
*/
private Integer attributeType;
/**
* 是否可以修改
*
* @mbggenerated
*/
private Boolean isModifiable;
/**
* 排序字段
*
* @mbggenerated
*/
private Integer sort;
/**
* 录入者:0:鉴定师,1:辅助人员
*
* @mbggenerated
*/
private Integer inputer;
/**
* 字数上限
*
* @mbggenerated
*/
private Integer maxLength;
/**
* 是否必填
*
* @mbggenerated
*/
private Boolean isRequire;
/**
* 备注
*
* @mbggenerated
*/
private String desc;
/**
* 扩展信息
*
* @mbggenerated
*/
private String extInfo;
private Date createTime;
private Date updateTime;
private Boolean isDeleted;
/**
* 参数默认值提醒
*
* @mbggenerated
*/
private String defaultPrompt;
}
package com.jbp.api.sellerwarehouse.request;
import lombok.Data;
import java.io.Serializable;
/**
* @author xinyi
*/
@Data
public class OperateWarehouseChangeRequest implements Serializable {
private static final long serialVersionUID = 9036060792687999353L;
private Long sellerId;
private Long warehouseId;
private Long recordId;
private String remarks;
}
package com.jbp.api.sellerwarehouse.request;
import lombok.Data;
import java.io.Serializable;
@Data
public class PhysicalCheckCategoryCheckerAndAssistantRequest implements Serializable {
private static final long serialVersionUID = -8400305348551341456L;
/**
* 仓库id
*
* @mbggenerated
*/
private Integer warehouseId;
/**
* 对应查验类目表的类目id
*
* @mbggenerated
*/
private Integer categoryId;
/**
* 父类目ID
*
* @mbggenerated
*/
private Long parentId;
/**
* 检查人(证书上显示)
*
* @mbggenerated
*/
private String defaultChecker;
/**
* 审核人
*
* @mbggenerated
*/
private String defaultAssistant;
}
\ No newline at end of file
package com.jbp.api.sellerwarehouse.request;
import com.jbp.appraisal.base.BasePageQueryParam;
import lombok.Data;
/**
* @author fengchen
* created 2020/12/16 3:19 下午
* Copyright © 2020 wanwudezhi.com. All rights reserved.
*/
@Data
public class SellerWarehouseApplyQuery extends BasePageQueryParam {
private static final long serialVersionUID = -459322311305149295L;
/**
* 商家用户ID
*/
private Long sellerId;
/**
* 申请状态
*/
private Integer status;
/**
* 改仓类型
*/
private Integer type;
/**
* 开始时间:秒
*/
private Long startTime;
/**
* 结束时间:秒
*/
private Long endTime;
}
package com.jbp.api.sellerwarehouse.response;
import lombok.Data;
import java.io.Serializable;
/**
* @author fengchen
* created 2020/12/14 6:11 下午
* Copyright © 2020 wanwudezhi.com. All rights reserved.
*/
@Data
public class CategoryWarehouseDTO implements Serializable {
private static final long serialVersionUID = 1951290427092715300L;
/**
* 二级类目ID
*/
private Long categoryId;
/**
* 类目名
*/
private String categoryName;
/**
* 父类目ID
*/
private Long parentCategoryId;
/**
*
*/
private String parentCategoryName;
private Long warehouseId;
private String warehouseName;
private Integer isDefault;
}
package com.jbp.api.sellerwarehouse.response;
import lombok.Data;
import java.io.Serializable;
/**
* @author fengchen
* created 2020/12/10 2:41 下午
* Copyright © 2020 wanwudezhi.com. All rights reserved.
*/
@Data
public class SellerWarehouseApplyStatusDTO implements Serializable {
private static final long serialVersionUID = 1811007519278968913L;
/**
* 状态值
*/
private Integer status;
/**
* 状态名
*/
private String name;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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