实现多租户功能
This commit is contained in:
@@ -0,0 +1,139 @@
|
||||
package com.gxwebsoft.apps.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.apps.service.EquipmentService;
|
||||
import com.gxwebsoft.apps.entity.Equipment;
|
||||
import com.gxwebsoft.apps.param.EquipmentParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品记录表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-17 15:53:11
|
||||
*/
|
||||
@Api(tags = "商品记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/apps/equipment")
|
||||
public class EquipmentController extends BaseController {
|
||||
@Resource
|
||||
private EquipmentService equipmentService;
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:equipment:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询商品记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Equipment>> page(EquipmentParam param) {
|
||||
PageParam<Equipment, EquipmentParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(equipmentService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(equipmentService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:equipment:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部商品记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Equipment>> list(EquipmentParam param) {
|
||||
PageParam<Equipment, EquipmentParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(equipmentService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(equipmentService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:equipment:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询商品记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Equipment> get(@PathVariable("id") Integer id) {
|
||||
return success(equipmentService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(equipmentService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:equipment:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加商品记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Equipment equipment) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
equipment.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (equipmentService.save(equipment)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:equipment:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改商品记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Equipment equipment) {
|
||||
if (equipmentService.updateById(equipment)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:equipment:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除商品记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (equipmentService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:equipment:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加商品记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Equipment> list) {
|
||||
if (equipmentService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:equipment:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改商品记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Equipment> batchParam) {
|
||||
if (batchParam.update(equipmentService, "equipment_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('apps:equipment:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除商品记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (equipmentService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
package com.gxwebsoft.apps.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 商品记录表
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-17 15:53:11
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "Equipment对象", description = "商品记录表")
|
||||
@TableName("apps_equipment")
|
||||
public class Equipment implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "设备ID")
|
||||
@TableId(value = "equipment_id", type = IdType.AUTO)
|
||||
private Integer equipmentId;
|
||||
|
||||
@ApiModelProperty(value = "设备名称")
|
||||
private String equipmentName;
|
||||
|
||||
@ApiModelProperty(value = "头像")
|
||||
private String equipmentAvatar;
|
||||
|
||||
@ApiModelProperty(value = "客户类型")
|
||||
private String equipmentType;
|
||||
|
||||
@ApiModelProperty(value = "设备编码")
|
||||
private String equipmentCode;
|
||||
|
||||
@ApiModelProperty(value = "主图视频ID")
|
||||
private Integer videoId;
|
||||
|
||||
@ApiModelProperty(value = "主图视频ID")
|
||||
private Integer videoCoverId;
|
||||
|
||||
@ApiModelProperty(value = "商品卖点")
|
||||
private String sellingPoint;
|
||||
|
||||
@ApiModelProperty(value = "商品规格(10单规格 20多规格)")
|
||||
private Integer specType;
|
||||
|
||||
@ApiModelProperty(value = "商品价格(最低)")
|
||||
private BigDecimal equipmentPriceMin;
|
||||
|
||||
@ApiModelProperty(value = "商品价格(最高)")
|
||||
private BigDecimal equipmentPriceMax;
|
||||
|
||||
@ApiModelProperty(value = "划线价格(最低)")
|
||||
private BigDecimal linePriceMin;
|
||||
|
||||
@ApiModelProperty(value = "划线价格(最高)")
|
||||
private BigDecimal linePriceMax;
|
||||
|
||||
@ApiModelProperty(value = "库存总量(包含所有sku)")
|
||||
private Integer stockTotal;
|
||||
|
||||
@ApiModelProperty(value = "库存计算方式(10下单减库存 20付款减库存)")
|
||||
private Integer deductStockType;
|
||||
|
||||
@ApiModelProperty(value = "商品详情")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty(value = "初始销量")
|
||||
private Integer salesInitial;
|
||||
|
||||
@ApiModelProperty(value = "实际销量")
|
||||
private Integer salesActual;
|
||||
|
||||
@ApiModelProperty(value = "配送模板ID")
|
||||
private Integer deliveryId;
|
||||
|
||||
@ApiModelProperty(value = "是否开启积分赠送(1开启 0关闭)")
|
||||
private Integer isPointsGift;
|
||||
|
||||
@ApiModelProperty(value = "是否允许使用积分抵扣(1允许 0不允许)")
|
||||
private Integer isPointsDiscount;
|
||||
|
||||
@ApiModelProperty(value = "积分抵扣设置(0默认抵扣 1单独设置抵扣)")
|
||||
private Integer isAlonePointsDiscount;
|
||||
|
||||
@ApiModelProperty(value = "单独设置积分抵扣的配置")
|
||||
private String pointsDiscountConfig;
|
||||
|
||||
@ApiModelProperty(value = "是否开启会员折扣(1开启 0关闭)")
|
||||
private Integer isEnableGrade;
|
||||
|
||||
@ApiModelProperty(value = "会员折扣设置(0默认等级折扣 1单独设置折扣)")
|
||||
private Integer isAloneGrade;
|
||||
|
||||
@ApiModelProperty(value = "单独设置折扣的配置")
|
||||
private String aloneGradeEquity;
|
||||
|
||||
@ApiModelProperty(value = "是否推荐")
|
||||
private Integer isHot;
|
||||
|
||||
@ApiModelProperty(value = "规格单位")
|
||||
private String unit;
|
||||
|
||||
@ApiModelProperty(value = "商品优惠属性: 0无 1限时特惠 2特惠专区")
|
||||
private Integer attribute;
|
||||
|
||||
@ApiModelProperty(value = "是否开启单独分销(0关闭 1开启)")
|
||||
private Integer isIndDealer;
|
||||
|
||||
@ApiModelProperty(value = "分销佣金类型(10百分比 20固定金额)")
|
||||
private Integer dealerMoneyType;
|
||||
|
||||
@ApiModelProperty(value = "分销佣金(一级)")
|
||||
private BigDecimal firstMoney;
|
||||
|
||||
@ApiModelProperty(value = "分销佣金(二级)")
|
||||
private BigDecimal secondMoney;
|
||||
|
||||
@ApiModelProperty(value = "分销佣金(三级)")
|
||||
private BigDecimal thirdMoney;
|
||||
|
||||
@ApiModelProperty(value = "审核状态 (10待审核 20审核通过 30驳回)")
|
||||
private Integer applyStatus;
|
||||
|
||||
@ApiModelProperty(value = "驳回原因")
|
||||
private String rejectReason;
|
||||
|
||||
@ApiModelProperty(value = "置顶时间")
|
||||
private Integer topTime;
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "所属门店ID")
|
||||
private Integer shopId;
|
||||
|
||||
@ApiModelProperty(value = "排序(数字越小越靠前)")
|
||||
private Integer sortNumber;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0正常, 1冻结")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@ApiModelProperty(value = "注册时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.gxwebsoft.apps.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.apps.entity.Equipment;
|
||||
import com.gxwebsoft.apps.param.EquipmentParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品记录表Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-17 15:53:11
|
||||
*/
|
||||
public interface EquipmentMapper extends BaseMapper<Equipment> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<Equipment>
|
||||
*/
|
||||
List<Equipment> selectPageRel(@Param("page") IPage<Equipment> page,
|
||||
@Param("param") EquipmentParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<Equipment> selectListRel(@Param("param") EquipmentParam param);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.gxwebsoft.apps.mapper.EquipmentMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM apps_equipment a
|
||||
<where>
|
||||
<if test="param.equipmentId != null">
|
||||
AND a.equipment_id = #{param.equipmentId}
|
||||
</if>
|
||||
<if test="param.equipmentName != null">
|
||||
AND a.equipment_name LIKE CONCAT('%', #{param.equipmentName}, '%')
|
||||
</if>
|
||||
<if test="param.equipmentAvatar != null">
|
||||
AND a.equipment_avatar LIKE CONCAT('%', #{param.equipmentAvatar}, '%')
|
||||
</if>
|
||||
<if test="param.equipmentType != null">
|
||||
AND a.equipment_type LIKE CONCAT('%', #{param.equipmentType}, '%')
|
||||
</if>
|
||||
<if test="param.equipmentCode != null">
|
||||
AND a.equipment_code LIKE CONCAT('%', #{param.equipmentCode}, '%')
|
||||
</if>
|
||||
<if test="param.videoId != null">
|
||||
AND a.video_id = #{param.videoId}
|
||||
</if>
|
||||
<if test="param.videoCoverId != null">
|
||||
AND a.video_cover_id = #{param.videoCoverId}
|
||||
</if>
|
||||
<if test="param.sellingPoint != null">
|
||||
AND a.selling_point LIKE CONCAT('%', #{param.sellingPoint}, '%')
|
||||
</if>
|
||||
<if test="param.specType != null">
|
||||
AND a.spec_type = #{param.specType}
|
||||
</if>
|
||||
<if test="param.equipmentPriceMin != null">
|
||||
AND a.equipment_price_min = #{param.equipmentPriceMin}
|
||||
</if>
|
||||
<if test="param.equipmentPriceMax != null">
|
||||
AND a.equipment_price_max = #{param.equipmentPriceMax}
|
||||
</if>
|
||||
<if test="param.linePriceMin != null">
|
||||
AND a.line_price_min = #{param.linePriceMin}
|
||||
</if>
|
||||
<if test="param.linePriceMax != null">
|
||||
AND a.line_price_max = #{param.linePriceMax}
|
||||
</if>
|
||||
<if test="param.stockTotal != null">
|
||||
AND a.stock_total = #{param.stockTotal}
|
||||
</if>
|
||||
<if test="param.deductStockType != null">
|
||||
AND a.deduct_stock_type = #{param.deductStockType}
|
||||
</if>
|
||||
<if test="param.content != null">
|
||||
AND a.content LIKE CONCAT('%', #{param.content}, '%')
|
||||
</if>
|
||||
<if test="param.salesInitial != null">
|
||||
AND a.sales_initial = #{param.salesInitial}
|
||||
</if>
|
||||
<if test="param.salesActual != null">
|
||||
AND a.sales_actual = #{param.salesActual}
|
||||
</if>
|
||||
<if test="param.deliveryId != null">
|
||||
AND a.delivery_id = #{param.deliveryId}
|
||||
</if>
|
||||
<if test="param.isPointsGift != null">
|
||||
AND a.is_points_gift = #{param.isPointsGift}
|
||||
</if>
|
||||
<if test="param.isPointsDiscount != null">
|
||||
AND a.is_points_discount = #{param.isPointsDiscount}
|
||||
</if>
|
||||
<if test="param.isAlonePointsDiscount != null">
|
||||
AND a.is_alone_points_discount = #{param.isAlonePointsDiscount}
|
||||
</if>
|
||||
<if test="param.pointsDiscountConfig != null">
|
||||
AND a.points_discount_config LIKE CONCAT('%', #{param.pointsDiscountConfig}, '%')
|
||||
</if>
|
||||
<if test="param.isEnableGrade != null">
|
||||
AND a.is_enable_grade = #{param.isEnableGrade}
|
||||
</if>
|
||||
<if test="param.isAloneGrade != null">
|
||||
AND a.is_alone_grade = #{param.isAloneGrade}
|
||||
</if>
|
||||
<if test="param.aloneGradeEquity != null">
|
||||
AND a.alone_grade_equity LIKE CONCAT('%', #{param.aloneGradeEquity}, '%')
|
||||
</if>
|
||||
<if test="param.isHot != null">
|
||||
AND a.is_hot = #{param.isHot}
|
||||
</if>
|
||||
<if test="param.unit != null">
|
||||
AND a.unit LIKE CONCAT('%', #{param.unit}, '%')
|
||||
</if>
|
||||
<if test="param.attribute != null">
|
||||
AND a.attribute = #{param.attribute}
|
||||
</if>
|
||||
<if test="param.isIndDealer != null">
|
||||
AND a.is_ind_dealer = #{param.isIndDealer}
|
||||
</if>
|
||||
<if test="param.dealerMoneyType != null">
|
||||
AND a.dealer_money_type = #{param.dealerMoneyType}
|
||||
</if>
|
||||
<if test="param.firstMoney != null">
|
||||
AND a.first_money = #{param.firstMoney}
|
||||
</if>
|
||||
<if test="param.secondMoney != null">
|
||||
AND a.second_money = #{param.secondMoney}
|
||||
</if>
|
||||
<if test="param.thirdMoney != null">
|
||||
AND a.third_money = #{param.thirdMoney}
|
||||
</if>
|
||||
<if test="param.applyStatus != null">
|
||||
AND a.apply_status = #{param.applyStatus}
|
||||
</if>
|
||||
<if test="param.rejectReason != null">
|
||||
AND a.reject_reason LIKE CONCAT('%', #{param.rejectReason}, '%')
|
||||
</if>
|
||||
<if test="param.topTime != null">
|
||||
AND a.top_time = #{param.topTime}
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.shopId != null">
|
||||
AND a.shop_id = #{param.shopId}
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.apps.entity.Equipment">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.apps.entity.Equipment">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,188 @@
|
||||
package com.gxwebsoft.apps.param;
|
||||
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 商品记录表查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-17 15:53:11
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(value = "EquipmentParam对象", description = "商品记录表查询参数")
|
||||
public class EquipmentParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "设备ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer equipmentId;
|
||||
|
||||
@ApiModelProperty(value = "设备名称")
|
||||
private String equipmentName;
|
||||
|
||||
@ApiModelProperty(value = "头像")
|
||||
private String equipmentAvatar;
|
||||
|
||||
@ApiModelProperty(value = "客户类型")
|
||||
private String equipmentType;
|
||||
|
||||
@ApiModelProperty(value = "设备编码")
|
||||
private String equipmentCode;
|
||||
|
||||
@ApiModelProperty(value = "主图视频ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer videoId;
|
||||
|
||||
@ApiModelProperty(value = "主图视频ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer videoCoverId;
|
||||
|
||||
@ApiModelProperty(value = "商品卖点")
|
||||
private String sellingPoint;
|
||||
|
||||
@ApiModelProperty(value = "商品规格(10单规格 20多规格)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer specType;
|
||||
|
||||
@ApiModelProperty(value = "商品价格(最低)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private BigDecimal equipmentPriceMin;
|
||||
|
||||
@ApiModelProperty(value = "商品价格(最高)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private BigDecimal equipmentPriceMax;
|
||||
|
||||
@ApiModelProperty(value = "划线价格(最低)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private BigDecimal linePriceMin;
|
||||
|
||||
@ApiModelProperty(value = "划线价格(最高)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private BigDecimal linePriceMax;
|
||||
|
||||
@ApiModelProperty(value = "库存总量(包含所有sku)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer stockTotal;
|
||||
|
||||
@ApiModelProperty(value = "库存计算方式(10下单减库存 20付款减库存)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer deductStockType;
|
||||
|
||||
@ApiModelProperty(value = "商品详情")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty(value = "初始销量")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer salesInitial;
|
||||
|
||||
@ApiModelProperty(value = "实际销量")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer salesActual;
|
||||
|
||||
@ApiModelProperty(value = "配送模板ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer deliveryId;
|
||||
|
||||
@ApiModelProperty(value = "是否开启积分赠送(1开启 0关闭)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer isPointsGift;
|
||||
|
||||
@ApiModelProperty(value = "是否允许使用积分抵扣(1允许 0不允许)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer isPointsDiscount;
|
||||
|
||||
@ApiModelProperty(value = "积分抵扣设置(0默认抵扣 1单独设置抵扣)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer isAlonePointsDiscount;
|
||||
|
||||
@ApiModelProperty(value = "单独设置积分抵扣的配置")
|
||||
private String pointsDiscountConfig;
|
||||
|
||||
@ApiModelProperty(value = "是否开启会员折扣(1开启 0关闭)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer isEnableGrade;
|
||||
|
||||
@ApiModelProperty(value = "会员折扣设置(0默认等级折扣 1单独设置折扣)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer isAloneGrade;
|
||||
|
||||
@ApiModelProperty(value = "单独设置折扣的配置")
|
||||
private String aloneGradeEquity;
|
||||
|
||||
@ApiModelProperty(value = "是否推荐")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer isHot;
|
||||
|
||||
@ApiModelProperty(value = "规格单位")
|
||||
private String unit;
|
||||
|
||||
@ApiModelProperty(value = "商品优惠属性: 0无 1限时特惠 2特惠专区")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer attribute;
|
||||
|
||||
@ApiModelProperty(value = "是否开启单独分销(0关闭 1开启)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer isIndDealer;
|
||||
|
||||
@ApiModelProperty(value = "分销佣金类型(10百分比 20固定金额)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer dealerMoneyType;
|
||||
|
||||
@ApiModelProperty(value = "分销佣金(一级)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private BigDecimal firstMoney;
|
||||
|
||||
@ApiModelProperty(value = "分销佣金(二级)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private BigDecimal secondMoney;
|
||||
|
||||
@ApiModelProperty(value = "分销佣金(三级)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private BigDecimal thirdMoney;
|
||||
|
||||
@ApiModelProperty(value = "审核状态 (10待审核 20审核通过 30驳回)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer applyStatus;
|
||||
|
||||
@ApiModelProperty(value = "驳回原因")
|
||||
private String rejectReason;
|
||||
|
||||
@ApiModelProperty(value = "置顶时间")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer topTime;
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "所属门店ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer shopId;
|
||||
|
||||
@ApiModelProperty(value = "排序(数字越小越靠前)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer sortNumber;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0正常, 1冻结")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer deleted;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.gxwebsoft.apps.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.apps.entity.Equipment;
|
||||
import com.gxwebsoft.apps.param.EquipmentParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品记录表Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-17 15:53:11
|
||||
*/
|
||||
public interface EquipmentService extends IService<Equipment> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<Equipment>
|
||||
*/
|
||||
PageResult<Equipment> pageRel(EquipmentParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<Equipment>
|
||||
*/
|
||||
List<Equipment> listRel(EquipmentParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param equipmentId 设备ID
|
||||
* @return Equipment
|
||||
*/
|
||||
Equipment getByIdRel(Integer equipmentId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.gxwebsoft.apps.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.apps.mapper.EquipmentMapper;
|
||||
import com.gxwebsoft.apps.service.EquipmentService;
|
||||
import com.gxwebsoft.apps.entity.Equipment;
|
||||
import com.gxwebsoft.apps.param.EquipmentParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品记录表Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-17 15:53:11
|
||||
*/
|
||||
@Service
|
||||
public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment> implements EquipmentService {
|
||||
|
||||
@Override
|
||||
public PageResult<Equipment> pageRel(EquipmentParam param) {
|
||||
PageParam<Equipment, EquipmentParam> page = new PageParam<>(param);
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
List<Equipment> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Equipment> listRel(EquipmentParam param) {
|
||||
List<Equipment> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<Equipment, EquipmentParam> page = new PageParam<>();
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Equipment getByIdRel(Integer equipmentId) {
|
||||
EquipmentParam param = new EquipmentParam();
|
||||
param.setEquipmentId(equipmentId);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -69,6 +70,11 @@ public class ArticleController extends BaseController {
|
||||
@ApiOperation("添加文章记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Article article) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
article.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (articleService.save(article)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -69,6 +70,11 @@ public class CategoryController extends BaseController {
|
||||
@ApiOperation("添加文章分类表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Category category) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
category.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (categoryService.save(category)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
@@ -69,6 +70,11 @@ public class DocsController extends BaseController {
|
||||
@ApiOperation("添加文档管理记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Docs docs) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
docs.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (docsService.save(docs)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gxwebsoft.oa.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.oa.service.AssetsService;
|
||||
import com.gxwebsoft.oa.entity.Assets;
|
||||
import com.gxwebsoft.oa.param.AssetsParam;
|
||||
@@ -69,6 +70,11 @@ public class AssetsController extends BaseController {
|
||||
@ApiOperation("添加服务器资产记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Assets assets) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
assets.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (assetsService.save(assets)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gxwebsoft.oa.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.oa.service.CustomerService;
|
||||
import com.gxwebsoft.oa.entity.Customer;
|
||||
import com.gxwebsoft.oa.param.CustomerParam;
|
||||
@@ -69,6 +70,11 @@ public class CustomerController extends BaseController {
|
||||
@ApiOperation("添加客户管理记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Customer customer) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
customer.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (customerService.save(customer)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gxwebsoft.oa.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.oa.service.LinkService;
|
||||
import com.gxwebsoft.oa.entity.Link;
|
||||
import com.gxwebsoft.oa.param.LinkParam;
|
||||
@@ -69,6 +70,11 @@ public class LinkController extends BaseController {
|
||||
@ApiOperation("添加常用链接推荐记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Link link) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
link.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (linkService.save(link)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gxwebsoft.oa.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.oa.service.ProjectService;
|
||||
import com.gxwebsoft.oa.entity.Project;
|
||||
import com.gxwebsoft.oa.param.ProjectParam;
|
||||
@@ -69,6 +70,11 @@ public class ProjectController extends BaseController {
|
||||
@ApiOperation("添加项目管理表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Project project) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
project.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (projectService.save(project)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gxwebsoft.oa.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.oa.service.TaskService;
|
||||
import com.gxwebsoft.oa.entity.Task;
|
||||
import com.gxwebsoft.oa.param.TaskParam;
|
||||
@@ -69,6 +70,11 @@ public class TaskController extends BaseController {
|
||||
@ApiOperation("添加文章记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Task task) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
task.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (taskService.save(task)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,586 @@
|
||||
package com.gxwebsoft.oa.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.gxwebsoft.common.core.exception.BusinessException;
|
||||
import com.gxwebsoft.common.core.utils.CommonUtil;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.*;
|
||||
import com.gxwebsoft.common.system.service.*;
|
||||
import com.gxwebsoft.oa.service.TenantService;
|
||||
import com.gxwebsoft.oa.entity.Tenant;
|
||||
import com.gxwebsoft.oa.param.TenantParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 租户控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-17 17:13:39
|
||||
*/
|
||||
@Api(tags = "租户管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/oa/tenant")
|
||||
public class TenantController extends BaseController {
|
||||
@Resource
|
||||
private TenantService tenantService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private RoleService roleService;
|
||||
@Resource
|
||||
private UserRoleService userRoleService;
|
||||
@Resource
|
||||
private MenuService menuService;
|
||||
@Resource
|
||||
private RoleMenuService roleMenuService;
|
||||
|
||||
@PreAuthorize("hasAuthority('oa:tenant:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询租户")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Tenant>> page(TenantParam param) {
|
||||
PageParam<Tenant, TenantParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(tenantService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(tenantService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('oa:tenant:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部租户")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Tenant>> list(TenantParam param) {
|
||||
PageParam<Tenant, TenantParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(tenantService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(tenantService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('oa:tenant:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询租户")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Tenant> get(@PathVariable("id") Integer id) {
|
||||
return success(tenantService.getById(id));
|
||||
// 使用关联查询
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@PreAuthorize("hasAuthority('oa:tenant:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加租户")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Tenant tenant) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
tenant.setUserId(loginUser.getUserId());
|
||||
}
|
||||
tenantService.save(tenant);
|
||||
// 添加超级管理员
|
||||
User user = new User();
|
||||
user.setUsername("admin");
|
||||
user.setNickname("超级管理员");
|
||||
user.setPassword(userService.encodePassword(tenant.getPassword()));
|
||||
user.setTenantId(tenant.getTenantId());
|
||||
boolean result = userService.save(user);
|
||||
// 创建角色
|
||||
if(result){
|
||||
Role role = new Role();
|
||||
role.setRoleName("超级管理员");
|
||||
role.setRoleCode("superadmin");
|
||||
role.setComments("超级管理员");
|
||||
role.setTenantId(tenant.getTenantId());
|
||||
roleService.save(role);
|
||||
// 保存超级管理员角色ID
|
||||
Integer roleId = role.getRoleId();
|
||||
// 添加用户角色
|
||||
UserRole userRole = new UserRole();
|
||||
userRole.setUserId(user.getUserId());
|
||||
userRole.setRoleId(role.getRoleId());
|
||||
userRole.setTenantId(tenant.getTenantId());
|
||||
boolean resultUserRole = userRoleService.save(userRole);
|
||||
/// 添加系统菜单
|
||||
if(resultUserRole){
|
||||
Menu menu = new Menu();
|
||||
menu.setTitle("系统管理");
|
||||
menu.setParentId(0);
|
||||
menu.setPath("/system");
|
||||
menu.setIcon("setting-outlined");
|
||||
menu.setSortNumber(5);
|
||||
menu.setTenantId(tenant.getTenantId());
|
||||
menuService.save(menu);
|
||||
Integer parentId = menu.getMenuId();
|
||||
menu.setParentId(menu.getMenuId());
|
||||
menu.setTitle("用户管理");
|
||||
menu.setPath("/system/user");
|
||||
menu.setComponent("/system/user");
|
||||
menu.setIcon("team-outlined");
|
||||
menu.setSortNumber(1);
|
||||
menuService.save(menu);
|
||||
Integer userParentId = menu.getMenuId();
|
||||
menu.setParentId(userParentId);
|
||||
menu.setMenuType(1);
|
||||
menu.setTitle("查询用户");
|
||||
menu.setAuthority("sys:user:list");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(userParentId);
|
||||
menu.setTitle("添加用户");
|
||||
menu.setAuthority("sys:user:save");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(userParentId);
|
||||
menu.setTitle("修改用户");
|
||||
menu.setAuthority("sys:user:update");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(userParentId);
|
||||
menu.setTitle("删除用户");
|
||||
menu.setAuthority("sys:user:remove");
|
||||
menuService.save(menu);
|
||||
menu.setMenuType(0);
|
||||
menu.setParentId(parentId);
|
||||
menu.setParentId(parentId);
|
||||
menu.setTitle("角色管理");
|
||||
menu.setPath("/system/role");
|
||||
menu.setComponent("/system/role");
|
||||
menu.setIcon("idcard-outlined");
|
||||
menu.setSortNumber(2);
|
||||
menuService.save(menu);
|
||||
Integer roleParentId = menu.getMenuId();
|
||||
menu.setParentId(roleParentId);
|
||||
menu.setMenuType(1);
|
||||
menu.setTitle("查询角色");
|
||||
menu.setAuthority("sys:role:list");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(roleParentId);
|
||||
menu.setTitle("添加角色");
|
||||
menu.setAuthority("sys:role:save");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(roleParentId);
|
||||
menu.setTitle("修改角色");
|
||||
menu.setAuthority("sys:role:update");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(roleParentId);
|
||||
menu.setTitle("删除角色");
|
||||
menu.setAuthority("sys:role:remove");
|
||||
menuService.save(menu);
|
||||
menu.setMenuType(0);
|
||||
menu.setParentId(parentId);
|
||||
menu.setParentId(parentId);
|
||||
menu.setTitle("菜单管理");
|
||||
menu.setPath("/system/menu");
|
||||
menu.setComponent("/system/menu");
|
||||
menu.setIcon("appstore-outlined");
|
||||
menu.setSortNumber(3);
|
||||
menuService.save(menu);
|
||||
Integer menuParentId = menu.getMenuId();
|
||||
menu.setParentId(menuParentId);
|
||||
menu.setMenuType(1);
|
||||
menu.setTitle("查询角色");
|
||||
menu.setAuthority("sys:menu:list");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(menuParentId);
|
||||
menu.setTitle("添加角色");
|
||||
menu.setAuthority("sys:menu:save");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(menuParentId);
|
||||
menu.setTitle("修改角色");
|
||||
menu.setAuthority("sys:menu:update");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(menuParentId);
|
||||
menu.setTitle("删除角色");
|
||||
menu.setAuthority("sys:menu:remove");
|
||||
menuService.save(menu);
|
||||
menu.setMenuType(0);
|
||||
menu.setParentId(parentId);
|
||||
menu.setParentId(parentId);
|
||||
menu.setTitle("机构管理");
|
||||
menu.setPath("/system/organization");
|
||||
menu.setComponent("/system/organization");
|
||||
menu.setIcon("bank-outlined");
|
||||
menu.setSortNumber(5);
|
||||
menuService.save(menu);
|
||||
Integer orgParentId = menu.getMenuId();
|
||||
menu.setParentId(orgParentId);
|
||||
menu.setMenuType(1);
|
||||
menu.setTitle("查询角色");
|
||||
menu.setAuthority("sys:org:list");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(orgParentId);
|
||||
menu.setTitle("添加角色");
|
||||
menu.setAuthority("sys:org:save");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(orgParentId);
|
||||
menu.setTitle("修改角色");
|
||||
menu.setAuthority("sys:org:update");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(orgParentId);
|
||||
menu.setTitle("删除角色");
|
||||
menu.setAuthority("sys:org:remove");
|
||||
menuService.save(menu);
|
||||
menu.setMenuType(0);
|
||||
menu.setParentId(parentId);
|
||||
menu.setParentId(parentId);
|
||||
menu.setTitle("字典管理");
|
||||
menu.setPath("/system/dictionary");
|
||||
menu.setComponent("/system/dictionary");
|
||||
menu.setIcon("profile-outlined");
|
||||
menu.setSortNumber(4);
|
||||
menuService.save(menu);
|
||||
Integer dictParentId = menu.getMenuId();
|
||||
menu.setParentId(dictParentId);
|
||||
menu.setMenuType(1);
|
||||
menu.setTitle("查询字典");
|
||||
menu.setAuthority("sys:org:list");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(dictParentId);
|
||||
menu.setTitle("添加字典");
|
||||
menu.setAuthority("sys:org:save");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(dictParentId);
|
||||
menu.setTitle("修改字典");
|
||||
menu.setAuthority("sys:org:update");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(dictParentId);
|
||||
menu.setTitle("删除字典");
|
||||
menu.setAuthority("sys:org:remove");
|
||||
menuService.save(menu);
|
||||
menu.setMenuType(0);
|
||||
menu.setParentId(parentId);
|
||||
menu.setParentId(parentId);
|
||||
menu.setTitle("登录日志");
|
||||
menu.setPath("/system/login-record");
|
||||
menu.setComponent("/system/login-record");
|
||||
menu.setIcon("calendar-outlined");
|
||||
menu.setAuthority("sys:login-record:list");
|
||||
menu.setSortNumber(7);
|
||||
menuService.save(menu);
|
||||
menu.setParentId(parentId);
|
||||
menu.setTitle("操作日志");
|
||||
menu.setPath("/system/operation-record");
|
||||
menu.setComponent("/system/operation-record");
|
||||
menu.setIcon("file-search-outlined");
|
||||
menu.setAuthority("sys:operation-record:list");
|
||||
menu.setSortNumber(8);
|
||||
menuService.save(menu);
|
||||
menu.setParentId(parentId);
|
||||
menu.setTitle("文件管理");
|
||||
menu.setPath("/system/file");
|
||||
menu.setComponent("/system/file");
|
||||
menu.setIcon("folder-outlined");
|
||||
menu.setSortNumber(6);
|
||||
menuService.save(menu);
|
||||
Integer fileParentId = menu.getMenuId();
|
||||
menu.setParentId(fileParentId);
|
||||
menu.setMenuType(1);
|
||||
menu.setTitle("查看记录");
|
||||
menu.setAuthority("sys:file:list");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(fileParentId);
|
||||
menu.setTitle("上传文件");
|
||||
menu.setAuthority("sys:file:upload");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(fileParentId);
|
||||
menu.setTitle("删除文件");
|
||||
menu.setAuthority("sys:org:remove");
|
||||
menuService.save(menu);
|
||||
menu.setMenuType(0);
|
||||
menu.setParentId(parentId);
|
||||
menu.setParentId(parentId);
|
||||
menu.setTitle("系统设置");
|
||||
menu.setPath("/system/setting");
|
||||
menu.setComponent("/system/setting");
|
||||
menu.setIcon("setting-outlined");
|
||||
menu.setAuthority("sys:setting:list");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(parentId);
|
||||
menu.setTitle("用户信息");
|
||||
menu.setPath("/system/user-info");
|
||||
menu.setComponent("/system/user-info");
|
||||
menu.setIcon("team-outlined");
|
||||
menu.setHide(1);
|
||||
menu.setSortNumber(9);
|
||||
menuService.save(menu);
|
||||
Integer userInfoParentId = menu.getMenuId();
|
||||
menu.setParentId(userInfoParentId);
|
||||
menu.setMenuType(1);
|
||||
menu.setTitle("修改个人密码");
|
||||
menu.setAuthority("sys:auth:password");
|
||||
menuService.save(menu);
|
||||
menu.setParentId(userInfoParentId);
|
||||
menu.setTitle("修改个人资料");
|
||||
menu.setAuthority("sys:auth:user");
|
||||
menuService.save(menu);
|
||||
menu.setMenuType(0);
|
||||
menu.setParentId(parentId);
|
||||
// 个人中心
|
||||
menu.setParentId(0);
|
||||
menu.setTitle("个人中心");
|
||||
menu.setPath("/user");
|
||||
menu.setIcon("control-outlined");
|
||||
menu.setHide(1);
|
||||
menu.setSortNumber(100);
|
||||
menuService.save(menu);
|
||||
// 个人资料
|
||||
Integer userCenterParentId = menu.getMenuId();
|
||||
menu.setHide(0);
|
||||
menu.setParentId(userCenterParentId);
|
||||
menu.setTitle("个人资料");
|
||||
menu.setPath("/user/profile");
|
||||
menu.setComponent("/user/profile");
|
||||
menu.setIcon("user-outlined");
|
||||
menu.setSortNumber(1);
|
||||
menuService.save(menu);
|
||||
Integer profileParentId = menu.getMenuId();
|
||||
// 按钮
|
||||
menu.setParentId(profileParentId);
|
||||
menu.setMenuType(1);
|
||||
menu.setTitle("修改资料");
|
||||
menu.setAuthority("sys:auth:user");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("修改密码");
|
||||
menu.setAuthority("sys:auth:password");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("字典查询");
|
||||
menu.setAuthority("sys:dict:list");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("字典查询");
|
||||
menu.setAuthority("sys:dict:list");
|
||||
menuService.save(menu);
|
||||
// 控制台
|
||||
menu.setParentId(0);
|
||||
menu.setTitle("控制台");
|
||||
menu.setPath("/dashboard");
|
||||
menu.setIcon("home-outlined");
|
||||
menu.setSortNumber(0);
|
||||
menuService.save(menu);
|
||||
Integer dashboardParentId = menu.getMenuId();
|
||||
menu.setTitle("工作台");
|
||||
menu.setPath("/dashboard/workplace");
|
||||
menu.setComponent("/dashboard/workplace");
|
||||
menu.setIcon("DesktopOutlined");
|
||||
menu.setParentId(dashboardParentId);
|
||||
menu.setSortNumber(1);
|
||||
menuService.save(menu);
|
||||
menu.setTitle("网址导航");
|
||||
menu.setPath("/dashboard/link");
|
||||
menu.setComponent("/dashboard/link");
|
||||
menu.setIcon("TagOutlined");
|
||||
menu.setAuthority("oa:link:list");
|
||||
menu.setParentId(dashboardParentId);
|
||||
menu.setSortNumber(2);
|
||||
menuService.save(menu);
|
||||
// 内容管理
|
||||
menu.setParentId(0);
|
||||
menu.setTitle("内容管理");
|
||||
menu.setPath("/cms");
|
||||
menu.setIcon("FileSearchOutlined");
|
||||
menu.setHide(0);
|
||||
menu.setSortNumber(3);
|
||||
menuService.save(menu);
|
||||
Integer contentParentId = menu.getMenuId();
|
||||
menu.setTitle("文章管理");
|
||||
menu.setPath("/cms/article");
|
||||
menu.setComponent("/cms/article");
|
||||
menu.setAuthority("cms:article:list");
|
||||
menu.setIcon("FileSearchOutlined");
|
||||
menu.setSortNumber(1);
|
||||
menu.setMenuType(0);
|
||||
menu.setParentId(contentParentId);
|
||||
menuService.save(menu);
|
||||
Integer articleParentId = menu.getMenuId();
|
||||
menu.setParentId(articleParentId);
|
||||
menu.setMenuType(1);
|
||||
menu.setTitle("添加");
|
||||
menu.setAuthority("cms:article:save");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("修改");
|
||||
menu.setAuthority("cms:article:update");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("删除");
|
||||
menu.setAuthority("cms:article:remove");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("文章分类");
|
||||
menu.setPath("/cms/category");
|
||||
menu.setComponent("/cms/category");
|
||||
menu.setAuthority("cms:category:list");
|
||||
menu.setIcon("ApartmentOutlined");
|
||||
menu.setMenuType(0);
|
||||
menu.setSortNumber(2);
|
||||
menu.setParentId(contentParentId);
|
||||
menuService.save(menu);
|
||||
Integer categoryParentId = menu.getMenuId();
|
||||
menu.setParentId(categoryParentId);
|
||||
menu.setMenuType(1);
|
||||
menu.setTitle("添加");
|
||||
menu.setAuthority("cms:category:save");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("修改");
|
||||
menu.setAuthority("cms:category:update");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("删除");
|
||||
menu.setAuthority("cms:category:remove");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("文档管理");
|
||||
menu.setPath("/cms/docs/:id");
|
||||
menu.setComponent("/cms/docs");
|
||||
menu.setAuthority("cms:docs:list");
|
||||
menu.setIcon("ReadOutlined");
|
||||
menu.setSortNumber(3);
|
||||
menu.setMenuType(0);
|
||||
menu.setParentId(contentParentId);
|
||||
menuService.save(menu);
|
||||
Integer docsParentId = menu.getMenuId();
|
||||
menu.setParentId(docsParentId);
|
||||
menu.setMenuType(1);
|
||||
menu.setTitle("添加");
|
||||
menu.setAuthority("cms:docs:save");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("修改");
|
||||
menu.setAuthority("cms:docs:update");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("删除");
|
||||
menu.setAuthority("cms:docs:remove");
|
||||
menuService.save(menu);
|
||||
menu.setTitle("视频管理");
|
||||
menu.setPath("/cms/video");
|
||||
menu.setComponent("/cms/video");
|
||||
menu.setAuthority("cms:video:list");
|
||||
menu.setIcon("YoutubeOutlined");
|
||||
menu.setSortNumber(4);
|
||||
menu.setMenuType(0);
|
||||
menu.setParentId(contentParentId);
|
||||
menuService.save(menu);
|
||||
menu.setTitle("文件下载");
|
||||
menu.setPath("/cms/down");
|
||||
menu.setComponent("/cms/down");
|
||||
menu.setAuthority("/cms:down:list");
|
||||
menu.setIcon("LinkOutlined");
|
||||
menu.setSortNumber(5);
|
||||
menu.setMenuType(0);
|
||||
menu.setParentId(contentParentId);
|
||||
menuService.save(menu);
|
||||
// 商城系统
|
||||
menu.setParentId(0);
|
||||
menu.setTitle("商城系统");
|
||||
menu.setPath("/shop");
|
||||
menu.setIcon("ShoppingOutlined");
|
||||
menu.setHide(0);
|
||||
menu.setSortNumber(2);
|
||||
menuService.save(menu);
|
||||
// 办公OA系统
|
||||
menu.setParentId(0);
|
||||
menu.setTitle("办公协同");
|
||||
menu.setPath("/oa");
|
||||
menu.setIcon("LaptopOutlined");
|
||||
menu.setHide(0);
|
||||
menu.setSortNumber(1);
|
||||
menuService.save(menu);
|
||||
boolean resultMenu = menuService.save(menu);
|
||||
// 添加菜单ID到超级管理员所属角色ID
|
||||
if(resultMenu){
|
||||
return success("添加成功");
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new BusinessException("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('oa:tenant:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改租户")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Tenant tenant) {
|
||||
if (tenantService.updateById(tenant)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('oa:tenant:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除租户")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (tenantService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('oa:tenant:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加租户")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Tenant> list) {
|
||||
if (tenantService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('oa:tenant:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改租户")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Tenant> batchParam) {
|
||||
if (batchParam.update(tenantService, "tenant_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('oa:tenant:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除租户")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (tenantService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("租户角色权限初始化")
|
||||
@GetMapping("/role-menu/{id}")
|
||||
public ApiResult<List<Menu>> initialization(@PathVariable("id") Integer roleId) {
|
||||
List<Menu> menus = menuService.list(new LambdaQueryWrapper<Menu>().orderByAsc(Menu::getSortNumber));
|
||||
List<RoleMenu> roleMenus = roleMenuService.list(new LambdaQueryWrapper<RoleMenu>()
|
||||
.eq(RoleMenu::getRoleId, roleId));
|
||||
for (Menu menu : menus) {
|
||||
menu.setChecked(roleMenus.stream().anyMatch((d) -> d.getMenuId().equals(menu.getMenuId())));
|
||||
}
|
||||
List<Integer> menuIds = menus.stream().map(Menu::getMenuId).collect(Collectors.toList());
|
||||
roleMenuService.remove(new LambdaUpdateWrapper<RoleMenu>().eq(RoleMenu::getRoleId, roleId));
|
||||
if (menuIds.size() > 0) {
|
||||
List<RoleMenu> roleMenuList = new ArrayList<>();
|
||||
for (Integer menuId : menuIds) {
|
||||
RoleMenu roleMenu = new RoleMenu();
|
||||
roleMenu.setRoleId(roleId);
|
||||
roleMenu.setMenuId(menuId);
|
||||
roleMenuList.add(roleMenu);
|
||||
}
|
||||
if (!roleMenuService.saveBatch(roleMenuList)) {
|
||||
throw new BusinessException("保存失败");
|
||||
}
|
||||
}
|
||||
return success(menus);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.gxwebsoft.oa.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 租户
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-17 17:13:39
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "Tenant对象", description = "租户")
|
||||
@TableName("sys_tenant")
|
||||
public class Tenant implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
@TableId(value = "tenant_id", type = IdType.AUTO)
|
||||
private Integer tenantId;
|
||||
|
||||
@ApiModelProperty(value = "租户名称")
|
||||
private String tenantName;
|
||||
|
||||
@ApiModelProperty(value = "绑定的手机号码")
|
||||
@TableField(exist = false)
|
||||
private String phone;
|
||||
|
||||
@ApiModelProperty(value = "绑定的邮箱")
|
||||
@TableField(exist = false)
|
||||
private String email;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "所属客户")
|
||||
private Integer customerId;
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private Date updateTime;
|
||||
|
||||
@ApiModelProperty(value = "初始密码")
|
||||
@TableField(exist = false)
|
||||
private String password;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.gxwebsoft.oa.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.oa.entity.Tenant;
|
||||
import com.gxwebsoft.oa.param.TenantParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 租户Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-17 17:13:39
|
||||
*/
|
||||
public interface TenantMapper extends BaseMapper<Tenant> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<Tenant>
|
||||
*/
|
||||
List<Tenant> selectPageRel(@Param("page") IPage<Tenant> page,
|
||||
@Param("param") TenantParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<Tenant> selectListRel(@Param("param") TenantParam param);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.gxwebsoft.oa.mapper.TenantMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM sys_tenant a
|
||||
<where>
|
||||
<if test="param.tenantId != null">
|
||||
AND a.tenant_id = #{param.tenantId}
|
||||
</if>
|
||||
<if test="param.tenantName != null">
|
||||
AND a.tenant_name LIKE CONCAT('%', #{param.tenantName}, '%')
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.oa.entity.Tenant">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.oa.entity.Tenant">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.gxwebsoft.oa.param;
|
||||
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 租户查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-17 17:13:39
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(value = "TenantParam对象", description = "租户查询参数")
|
||||
public class TenantParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "租户名称")
|
||||
private String tenantName;
|
||||
|
||||
@ApiModelProperty(value = "初始密码")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "客户ID")
|
||||
private Integer customerId;
|
||||
|
||||
@ApiModelProperty(value = "状态")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer deleted;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.gxwebsoft.oa.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.oa.entity.Tenant;
|
||||
import com.gxwebsoft.oa.param.TenantParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 租户Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-17 17:13:39
|
||||
*/
|
||||
public interface TenantService extends IService<Tenant> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<Tenant>
|
||||
*/
|
||||
PageResult<Tenant> pageRel(TenantParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<Tenant>
|
||||
*/
|
||||
List<Tenant> listRel(TenantParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param tenantId 租户id
|
||||
* @return Tenant
|
||||
*/
|
||||
// Tenant getByIdRel(Integer tenantId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.gxwebsoft.oa.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.oa.mapper.TenantMapper;
|
||||
import com.gxwebsoft.oa.service.TenantService;
|
||||
import com.gxwebsoft.oa.entity.Tenant;
|
||||
import com.gxwebsoft.oa.param.TenantParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 租户Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-17 17:13:39
|
||||
*/
|
||||
@Service
|
||||
public class TenantServiceImpl extends ServiceImpl<TenantMapper, Tenant> implements TenantService {
|
||||
|
||||
@Override
|
||||
public PageResult<Tenant> pageRel(TenantParam param) {
|
||||
PageParam<Tenant, TenantParam> page = new PageParam<>(param);
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
List<Tenant> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Tenant> listRel(TenantParam param) {
|
||||
List<Tenant> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<Tenant, TenantParam> page = new PageParam<>();
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Tenant getByIdRel(Integer tenantId) {
|
||||
// TenantParam param = new TenantParam();
|
||||
// param.setTenantId(tenantId);
|
||||
// return param.getOne(baseMapper.selectListRel(param));
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.CartService;
|
||||
import com.gxwebsoft.shop.entity.Cart;
|
||||
import com.gxwebsoft.shop.param.CartParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 购物车记录表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-17 22:23:53
|
||||
*/
|
||||
@Api(tags = "购物车记录表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/cart")
|
||||
public class CartController extends BaseController {
|
||||
@Resource
|
||||
private CartService cartService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询购物车记录表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Cart>> page(CartParam param) {
|
||||
PageParam<Cart, CartParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(cartService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(cartService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部购物车记录表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Cart>> list(CartParam param) {
|
||||
PageParam<Cart, CartParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(cartService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(cartService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询购物车记录表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Cart> get(@PathVariable("id") Integer id) {
|
||||
return success(cartService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(cartService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加购物车记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Cart cart) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
cart.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (cartService.save(cart)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改购物车记录表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Cart cart) {
|
||||
if (cartService.updateById(cart)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除购物车记录表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (cartService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加购物车记录表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Cart> list) {
|
||||
if (cartService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改购物车记录表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Cart> batchParam) {
|
||||
if (batchParam.update(cartService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:cart:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除购物车记录表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (cartService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.GoodsService;
|
||||
import com.gxwebsoft.shop.entity.Goods;
|
||||
import com.gxwebsoft.shop.param.GoodsParam;
|
||||
@@ -69,6 +70,11 @@ public class GoodsController extends BaseController {
|
||||
@ApiOperation("添加商品记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Goods goods) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
goods.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (goodsService.save(goods)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.OrderService;
|
||||
import com.gxwebsoft.shop.entity.Order;
|
||||
import com.gxwebsoft.shop.param.OrderParam;
|
||||
@@ -69,6 +70,11 @@ public class OrderController extends BaseController {
|
||||
@ApiOperation("添加订单记录表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Order order) {
|
||||
// 记录当前登录用户id、租户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
order.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (orderService.save(order)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.service.StoreService;
|
||||
import com.gxwebsoft.shop.entity.Store;
|
||||
import com.gxwebsoft.shop.param.StoreParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商城管理表控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-17 15:14:05
|
||||
*/
|
||||
@Api(tags = "商城管理表管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/store")
|
||||
public class StoreController extends BaseController {
|
||||
@Resource
|
||||
private StoreService storeService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:store:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("分页查询商城管理表")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<Store>> page(StoreParam param) {
|
||||
PageParam<Store, StoreParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(storeService.page(page, page.getWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(storeService.pageRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:store:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("查询全部商城管理表")
|
||||
@GetMapping()
|
||||
public ApiResult<List<Store>> list(StoreParam param) {
|
||||
PageParam<Store, StoreParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return success(storeService.list(page.getOrderWrapper()));
|
||||
// 使用关联查询
|
||||
//return success(storeService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:store:list')")
|
||||
@OperationLog
|
||||
@ApiOperation("根据id查询商城管理表")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<Store> get(@PathVariable("id") Integer id) {
|
||||
return success(storeService.getById(id));
|
||||
// 使用关联查询
|
||||
//return success(storeService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:store:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("添加商城管理表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody Store store) {
|
||||
if (storeService.save(store)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:store:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("修改商城管理表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody Store store) {
|
||||
if (storeService.updateById(store)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:store:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("删除商城管理表")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (storeService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:store:save')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量添加商城管理表")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<Store> list) {
|
||||
if (storeService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:store:update')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量修改商城管理表")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<Store> batchParam) {
|
||||
if (batchParam.update(storeService, "store_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:store:remove')")
|
||||
@OperationLog
|
||||
@ApiOperation("批量删除商城管理表")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (storeService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.gxwebsoft.shop.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 购物车记录表
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-17 22:23:53
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "Cart对象", description = "购物车记录表")
|
||||
@TableName("shop_cart")
|
||||
public class Cart implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "商品ID")
|
||||
private Integer goodsId;
|
||||
|
||||
@ApiModelProperty(value = "商品sku唯一标识")
|
||||
private String goodsSkuId;
|
||||
|
||||
@ApiModelProperty(value = "商品数量")
|
||||
private Integer goodsNum;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0正常, 1冻结")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "所属门店ID")
|
||||
private Integer shopId;
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "排序(数字越小越靠前)")
|
||||
private Integer sortNumber;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
@ApiModelProperty(value = "商城ID")
|
||||
private Integer storeId;
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@ApiModelProperty(value = "注册时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.gxwebsoft.shop.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 商城管理表
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-17 15:14:05
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "Store对象", description = "商城管理表")
|
||||
@TableName("shop_store")
|
||||
public class Store implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "商户ID")
|
||||
@TableId(value = "store_id", type = IdType.AUTO)
|
||||
private Integer storeId;
|
||||
|
||||
@ApiModelProperty(value = "商户名称")
|
||||
private String storeName;
|
||||
|
||||
@ApiModelProperty(value = "商户全称")
|
||||
private String fullName;
|
||||
|
||||
@ApiModelProperty(value = "LOGO")
|
||||
private String logo;
|
||||
|
||||
@ApiModelProperty(value = "描述")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "排序(数字越小越靠前)")
|
||||
private Integer sortNumber;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0正常, 1冻结")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@ApiModelProperty(value = "注册时间")
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.gxwebsoft.shop.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.shop.entity.Cart;
|
||||
import com.gxwebsoft.shop.param.CartParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 购物车记录表Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-17 22:23:53
|
||||
*/
|
||||
public interface CartMapper extends BaseMapper<Cart> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<Cart>
|
||||
*/
|
||||
List<Cart> selectPageRel(@Param("page") IPage<Cart> page,
|
||||
@Param("param") CartParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<Cart> selectListRel(@Param("param") CartParam param);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.gxwebsoft.shop.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.shop.entity.Store;
|
||||
import com.gxwebsoft.shop.param.StoreParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商城管理表Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-17 15:14:05
|
||||
*/
|
||||
public interface StoreMapper extends BaseMapper<Store> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<Store>
|
||||
*/
|
||||
List<Store> selectPageRel(@Param("page") IPage<Store> page,
|
||||
@Param("param") StoreParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<Store> selectListRel(@Param("param") StoreParam param);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.gxwebsoft.shop.mapper.CartMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM shop_cart a
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.goodsId != null">
|
||||
AND a.goods_id = #{param.goodsId}
|
||||
</if>
|
||||
<if test="param.goodsSkuId != null">
|
||||
AND a.goods_sku_id LIKE CONCAT('%', #{param.goodsSkuId}, '%')
|
||||
</if>
|
||||
<if test="param.goodsNum != null">
|
||||
AND a.goods_num = #{param.goodsNum}
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.shopId != null">
|
||||
AND a.shop_id = #{param.shopId}
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.storeId != null">
|
||||
AND a.store_id = #{param.storeId}
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.Cart">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.shop.entity.Cart">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.gxwebsoft.shop.mapper.StoreMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM shop_store a
|
||||
<where>
|
||||
<if test="param.storeId != null">
|
||||
AND a.store_id = #{param.storeId}
|
||||
</if>
|
||||
<if test="param.storeName != null">
|
||||
AND a.store_name LIKE CONCAT('%', #{param.storeName}, '%')
|
||||
</if>
|
||||
<if test="param.logo != null">
|
||||
AND a.logo LIKE CONCAT('%', #{param.logo}, '%')
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.Store">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.shop.entity.Store">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.gxwebsoft.shop.param;
|
||||
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 购物车记录表查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-17 22:23:53
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(value = "CartParam对象", description = "购物车记录表查询参数")
|
||||
public class CartParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "商品ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer goodsId;
|
||||
|
||||
@ApiModelProperty(value = "商品sku唯一标识")
|
||||
private String goodsSkuId;
|
||||
|
||||
@ApiModelProperty(value = "商品数量")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer goodsNum;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0正常, 1冻结")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "所属门店ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer shopId;
|
||||
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "排序(数字越小越靠前)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer sortNumber;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer deleted;
|
||||
|
||||
@ApiModelProperty(value = "商城ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer storeId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.gxwebsoft.shop.param;
|
||||
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 商城管理表查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-17 15:14:05
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(value = "StoreParam对象", description = "商城管理表查询参数")
|
||||
public class StoreParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "商户ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer storeId;
|
||||
|
||||
@ApiModelProperty(value = "商户名称")
|
||||
private String storeName;
|
||||
|
||||
@ApiModelProperty(value = "LOGO")
|
||||
private String logo;
|
||||
|
||||
@ApiModelProperty(value = "描述")
|
||||
private String comments;
|
||||
|
||||
@ApiModelProperty(value = "排序(数字越小越靠前)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer sortNumber;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0正常, 1冻结")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer deleted;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.gxwebsoft.shop.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.shop.entity.Cart;
|
||||
import com.gxwebsoft.shop.param.CartParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 购物车记录表Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-17 22:23:53
|
||||
*/
|
||||
public interface CartService extends IService<Cart> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<Cart>
|
||||
*/
|
||||
PageResult<Cart> pageRel(CartParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<Cart>
|
||||
*/
|
||||
List<Cart> listRel(CartParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id 主键ID
|
||||
* @return Cart
|
||||
*/
|
||||
Cart getByIdRel(Integer id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.gxwebsoft.shop.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.shop.entity.Store;
|
||||
import com.gxwebsoft.shop.param.StoreParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商城管理表Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-17 15:14:05
|
||||
*/
|
||||
public interface StoreService extends IService<Store> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<Store>
|
||||
*/
|
||||
PageResult<Store> pageRel(StoreParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<Store>
|
||||
*/
|
||||
List<Store> listRel(StoreParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param storeId 商户ID
|
||||
* @return Store
|
||||
*/
|
||||
Store getByIdRel(Integer storeId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.gxwebsoft.shop.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.shop.mapper.CartMapper;
|
||||
import com.gxwebsoft.shop.service.CartService;
|
||||
import com.gxwebsoft.shop.entity.Cart;
|
||||
import com.gxwebsoft.shop.param.CartParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 购物车记录表Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-17 22:23:53
|
||||
*/
|
||||
@Service
|
||||
public class CartServiceImpl extends ServiceImpl<CartMapper, Cart> implements CartService {
|
||||
|
||||
@Override
|
||||
public PageResult<Cart> pageRel(CartParam param) {
|
||||
PageParam<Cart, CartParam> page = new PageParam<>(param);
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
List<Cart> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Cart> listRel(CartParam param) {
|
||||
List<Cart> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<Cart, CartParam> page = new PageParam<>();
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cart getByIdRel(Integer id) {
|
||||
CartParam param = new CartParam();
|
||||
param.setId(id);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.gxwebsoft.shop.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.shop.mapper.StoreMapper;
|
||||
import com.gxwebsoft.shop.service.StoreService;
|
||||
import com.gxwebsoft.shop.entity.Store;
|
||||
import com.gxwebsoft.shop.param.StoreParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商城管理表Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-17 15:14:05
|
||||
*/
|
||||
@Service
|
||||
public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements StoreService {
|
||||
|
||||
@Override
|
||||
public PageResult<Store> pageRel(StoreParam param) {
|
||||
PageParam<Store, StoreParam> page = new PageParam<>(param);
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
List<Store> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Store> listRel(StoreParam param) {
|
||||
List<Store> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<Store, StoreParam> page = new PageParam<>();
|
||||
//page.setDefaultOrder("create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Store getByIdRel(Integer storeId) {
|
||||
StoreParam param = new StoreParam();
|
||||
param.setStoreId(storeId);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
package com.gxwebsoft.generator;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||
import com.baomidou.mybatisplus.generator.AutoGenerator;
|
||||
import com.baomidou.mybatisplus.generator.InjectionConfig;
|
||||
import com.baomidou.mybatisplus.generator.config.*;
|
||||
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
|
||||
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
||||
import com.gxwebsoft.generator.engine.BeetlTemplateEnginePlus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 代码生成工具
|
||||
*
|
||||
* @author WebSoft
|
||||
* @since 2021-09-05 00:31:14
|
||||
*/
|
||||
public class AppsGenerator {
|
||||
// 输出位置
|
||||
private static final String OUTPUT_LOCATION = System.getProperty("user.dir");
|
||||
//private static final String OUTPUT_LOCATION = "D:/codegen"; // 不想生成到项目中可以写磁盘路径
|
||||
// 输出目录
|
||||
private static final String OUTPUT_DIR = "/src/main/java";
|
||||
// 作者名称
|
||||
private static final String AUTHOR = "科技小王子";
|
||||
// 是否在xml中添加二级缓存配置
|
||||
private static final boolean ENABLE_CACHE = false;
|
||||
// 数据库连接配置
|
||||
private static final String DB_URL = "jdbc:mysql://47.119.165.234:3308/com_gxwebsoft_oa?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8";
|
||||
private static final String DB_DRIVER = "com.mysql.cj.jdbc.Driver";
|
||||
private static final String DB_USERNAME = "com_gxwebsoft_oa";
|
||||
private static final String DB_PASSWORD = "EZfW2R4YiWfbLHLw";
|
||||
// 包名
|
||||
private static final String PACKAGE_NAME = "com.gxwebsoft";
|
||||
// 模块名
|
||||
private static final String MODULE_NAME = "apps";
|
||||
// 需要生成的表
|
||||
private static final String[] TABLE_NAMES = new String[]{
|
||||
"apps_equipment",
|
||||
// "oa_link",
|
||||
// "oa_assets",
|
||||
// "oa_customer",
|
||||
// "oa_task",
|
||||
// "oa_assets",
|
||||
// "oa_assets",
|
||||
// "oa_assets",
|
||||
// "oa_assets",
|
||||
// "oa_assets",
|
||||
// "oa_assets",
|
||||
|
||||
};
|
||||
// 需要去除的表前缀
|
||||
private static final String[] TABLE_PREFIX = new String[]{
|
||||
"apps_",
|
||||
"tb_"
|
||||
};
|
||||
// 不需要作为查询参数的字段
|
||||
private static final String[] PARAM_EXCLUDE_FIELDS = new String[]{
|
||||
"tenant_id",
|
||||
"create_time",
|
||||
"update_time"
|
||||
};
|
||||
// 查询参数使用String的类型
|
||||
private static final String[] PARAM_TO_STRING_TYPE = new String[]{
|
||||
"Date",
|
||||
"LocalDate",
|
||||
"LocalTime",
|
||||
"LocalDateTime"
|
||||
};
|
||||
// 查询参数使用EQ的类型
|
||||
private static final String[] PARAM_EQ_TYPE = new String[]{
|
||||
"Integer",
|
||||
"Boolean",
|
||||
"BigDecimal"
|
||||
};
|
||||
// 是否添加权限注解
|
||||
private static final boolean AUTH_ANNOTATION = true;
|
||||
// 是否添加日志注解
|
||||
private static final boolean LOG_ANNOTATION = true;
|
||||
// controller的mapping前缀
|
||||
private static final String CONTROLLER_MAPPING_PREFIX = "/api";
|
||||
// 模板所在位置
|
||||
private static final String TEMPLATES_DIR = "/src/test/java/com/gxwebsoft/generator/templates";
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 代码生成器
|
||||
AutoGenerator mpg = new AutoGenerator();
|
||||
|
||||
// 全局配置
|
||||
GlobalConfig gc = new GlobalConfig();
|
||||
gc.setOutputDir(OUTPUT_LOCATION + OUTPUT_DIR);
|
||||
gc.setAuthor(AUTHOR);
|
||||
gc.setOpen(false);
|
||||
gc.setFileOverride(true);
|
||||
gc.setEnableCache(ENABLE_CACHE);
|
||||
gc.setSwagger2(true);
|
||||
gc.setIdType(IdType.AUTO);
|
||||
gc.setServiceName("%sService");
|
||||
mpg.setGlobalConfig(gc);
|
||||
|
||||
// 数据源配置
|
||||
DataSourceConfig dsc = new DataSourceConfig();
|
||||
dsc.setUrl(DB_URL);
|
||||
// dsc.setSchemaName("public");
|
||||
dsc.setDriverName(DB_DRIVER);
|
||||
dsc.setUsername(DB_USERNAME);
|
||||
dsc.setPassword(DB_PASSWORD);
|
||||
mpg.setDataSource(dsc);
|
||||
|
||||
// 包配置
|
||||
PackageConfig pc = new PackageConfig();
|
||||
pc.setModuleName(MODULE_NAME);
|
||||
pc.setParent(PACKAGE_NAME);
|
||||
mpg.setPackageInfo(pc);
|
||||
|
||||
// 策略配置
|
||||
StrategyConfig strategy = new StrategyConfig();
|
||||
strategy.setNaming(NamingStrategy.underline_to_camel);
|
||||
strategy.setColumnNaming(NamingStrategy.underline_to_camel);
|
||||
strategy.setInclude(TABLE_NAMES);
|
||||
strategy.setTablePrefix(TABLE_PREFIX);
|
||||
strategy.setSuperControllerClass(PACKAGE_NAME + ".common.core.web.BaseController");
|
||||
strategy.setEntityLombokModel(true);
|
||||
strategy.setRestControllerStyle(true);
|
||||
strategy.setControllerMappingHyphenStyle(true);
|
||||
strategy.setLogicDeleteFieldName("deleted");
|
||||
mpg.setStrategy(strategy);
|
||||
|
||||
// 模板配置
|
||||
TemplateConfig templateConfig = new TemplateConfig();
|
||||
templateConfig.setController(TEMPLATES_DIR + "/controller.java");
|
||||
templateConfig.setEntity(TEMPLATES_DIR + "/entity.java");
|
||||
templateConfig.setMapper(TEMPLATES_DIR + "/mapper.java");
|
||||
templateConfig.setXml(TEMPLATES_DIR + "/mapper.xml");
|
||||
templateConfig.setService(TEMPLATES_DIR + "/service.java");
|
||||
templateConfig.setServiceImpl(TEMPLATES_DIR + "/serviceImpl.java");
|
||||
mpg.setTemplate(templateConfig);
|
||||
mpg.setTemplateEngine(new BeetlTemplateEnginePlus());
|
||||
|
||||
// 自定义模板配置
|
||||
InjectionConfig cfg = new InjectionConfig() {
|
||||
@Override
|
||||
public void initMap() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("packageName", PACKAGE_NAME);
|
||||
map.put("paramExcludeFields", PARAM_EXCLUDE_FIELDS);
|
||||
map.put("paramToStringType", PARAM_TO_STRING_TYPE);
|
||||
map.put("paramEqType", PARAM_EQ_TYPE);
|
||||
map.put("authAnnotation", AUTH_ANNOTATION);
|
||||
map.put("logAnnotation", LOG_ANNOTATION);
|
||||
map.put("controllerMappingPrefix", CONTROLLER_MAPPING_PREFIX);
|
||||
this.setMap(map);
|
||||
}
|
||||
};
|
||||
String templatePath = TEMPLATES_DIR + "/param.java.btl";
|
||||
List<FileOutConfig> focList = new ArrayList<>();
|
||||
focList.add(new FileOutConfig(templatePath) {
|
||||
@Override
|
||||
public String outputFile(TableInfo tableInfo) {
|
||||
return OUTPUT_LOCATION + OUTPUT_DIR + "/"
|
||||
+ PACKAGE_NAME.replace(".", "/")
|
||||
+ "/" + pc.getModuleName() + "/param/"
|
||||
+ tableInfo.getEntityName() + "Param" + StringPool.DOT_JAVA;
|
||||
}
|
||||
});
|
||||
cfg.setFileOutConfigList(focList);
|
||||
mpg.setCfg(cfg);
|
||||
|
||||
mpg.execute();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -45,10 +45,8 @@ public class OaGenerator {
|
||||
// "oa_link",
|
||||
// "oa_assets",
|
||||
// "oa_customer",
|
||||
"oa_task",
|
||||
// "oa_assets",
|
||||
// "oa_assets",
|
||||
// "oa_assets",
|
||||
// "oa_task",
|
||||
// "sys_tenant",
|
||||
// "oa_assets",
|
||||
// "oa_assets",
|
||||
// "oa_assets",
|
||||
|
||||
@@ -42,8 +42,9 @@ public class ShopGenerator {
|
||||
// 需要生成的表
|
||||
private static final String[] TABLE_NAMES = new String[]{
|
||||
// "shop_order",
|
||||
"shop_goods",
|
||||
// "oa_assets",
|
||||
// "shop_goods",
|
||||
// "shop_store",
|
||||
"shop_cart"
|
||||
// "oa_assets",
|
||||
// "oa_assets",
|
||||
// "oa_assets",
|
||||
|
||||
@@ -36,13 +36,13 @@ public class SysGenerator {
|
||||
private static final String DB_USERNAME = "com_gxwebsoft_oa";
|
||||
private static final String DB_PASSWORD = "EZfW2R4YiWfbLHLw";
|
||||
// 包名
|
||||
private static final String PACKAGE_NAME = "com.gxwebsoft.common";
|
||||
private static final String PACKAGE_NAME = "com.gxwebsoft";
|
||||
// 模块名
|
||||
private static final String MODULE_NAME = "system";
|
||||
private static final String MODULE_NAME = "common.system";
|
||||
// 需要生成的表
|
||||
private static final String[] TABLE_NAMES = new String[]{
|
||||
|
||||
"sys_setting",
|
||||
// "sys_user",
|
||||
|
||||
};
|
||||
// 需要去除的表前缀
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user