
10 changed files with 509 additions and 24 deletions
@ -0,0 +1,139 @@ |
|||
package com.gxwebsoft.tower.controller; |
|||
|
|||
import com.gxwebsoft.common.core.web.BaseController; |
|||
import com.gxwebsoft.common.system.entity.User; |
|||
import com.gxwebsoft.tower.service.TowerPurchaseService; |
|||
import com.gxwebsoft.tower.entity.TowerPurchase; |
|||
import com.gxwebsoft.tower.param.TowerPurchaseParam; |
|||
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 2024-02-05 20:53:32 |
|||
*/ |
|||
@Api(tags = "采购入库表管理") |
|||
@RestController |
|||
@RequestMapping("/api/tower/tower-purchase") |
|||
public class TowerPurchaseController extends BaseController { |
|||
@Resource |
|||
private TowerPurchaseService towerPurchaseService; |
|||
|
|||
@PreAuthorize("hasAuthority('tower:towerPurchase:list')") |
|||
@OperationLog |
|||
@ApiOperation("分页查询采购入库表") |
|||
@GetMapping("/page") |
|||
public ApiResult<PageResult<TowerPurchase>> page(TowerPurchaseParam param) { |
|||
PageParam<TowerPurchase, TowerPurchaseParam> page = new PageParam<>(param); |
|||
page.setDefaultOrder("create_time desc"); |
|||
return success(towerPurchaseService.page(page, page.getWrapper())); |
|||
// 使用关联查询
|
|||
//return success(towerPurchaseService.pageRel(param));
|
|||
} |
|||
|
|||
@PreAuthorize("hasAuthority('tower:towerPurchase:list')") |
|||
@OperationLog |
|||
@ApiOperation("查询全部采购入库表") |
|||
@GetMapping() |
|||
public ApiResult<List<TowerPurchase>> list(TowerPurchaseParam param) { |
|||
PageParam<TowerPurchase, TowerPurchaseParam> page = new PageParam<>(param); |
|||
page.setDefaultOrder("create_time desc"); |
|||
return success(towerPurchaseService.list(page.getOrderWrapper())); |
|||
// 使用关联查询
|
|||
//return success(towerPurchaseService.listRel(param));
|
|||
} |
|||
|
|||
@PreAuthorize("hasAuthority('tower:towerPurchase:list')") |
|||
@OperationLog |
|||
@ApiOperation("根据id查询采购入库表") |
|||
@GetMapping("/{id}") |
|||
public ApiResult<TowerPurchase> get(@PathVariable("id") Integer id) { |
|||
return success(towerPurchaseService.getById(id)); |
|||
// 使用关联查询
|
|||
//return success(towerPurchaseService.getByIdRel(id));
|
|||
} |
|||
|
|||
@PreAuthorize("hasAuthority('tower:towerPurchase:save')") |
|||
@OperationLog |
|||
@ApiOperation("添加采购入库表") |
|||
@PostMapping() |
|||
public ApiResult<?> save(@RequestBody TowerPurchase towerPurchase) { |
|||
// 记录当前登录用户id
|
|||
User loginUser = getLoginUser(); |
|||
if (loginUser != null) { |
|||
towerPurchase.setUserId(loginUser.getUserId()); |
|||
} |
|||
if (towerPurchaseService.save(towerPurchase)) { |
|||
return success("添加成功"); |
|||
} |
|||
return fail("添加失败"); |
|||
} |
|||
|
|||
@PreAuthorize("hasAuthority('tower:towerPurchase:update')") |
|||
@OperationLog |
|||
@ApiOperation("修改采购入库表") |
|||
@PutMapping() |
|||
public ApiResult<?> update(@RequestBody TowerPurchase towerPurchase) { |
|||
if (towerPurchaseService.updateById(towerPurchase)) { |
|||
return success("修改成功"); |
|||
} |
|||
return fail("修改失败"); |
|||
} |
|||
|
|||
@PreAuthorize("hasAuthority('tower:towerPurchase:remove')") |
|||
@OperationLog |
|||
@ApiOperation("删除采购入库表") |
|||
@DeleteMapping("/{id}") |
|||
public ApiResult<?> remove(@PathVariable("id") Integer id) { |
|||
if (towerPurchaseService.removeById(id)) { |
|||
return success("删除成功"); |
|||
} |
|||
return fail("删除失败"); |
|||
} |
|||
|
|||
@PreAuthorize("hasAuthority('tower:towerPurchase:save')") |
|||
@OperationLog |
|||
@ApiOperation("批量添加采购入库表") |
|||
@PostMapping("/batch") |
|||
public ApiResult<?> saveBatch(@RequestBody List<TowerPurchase> list) { |
|||
if (towerPurchaseService.saveBatch(list)) { |
|||
return success("添加成功"); |
|||
} |
|||
return fail("添加失败"); |
|||
} |
|||
|
|||
@PreAuthorize("hasAuthority('tower:towerPurchase:update')") |
|||
@OperationLog |
|||
@ApiOperation("批量修改采购入库表") |
|||
@PutMapping("/batch") |
|||
public ApiResult<?> removeBatch(@RequestBody BatchParam<TowerPurchase> batchParam) { |
|||
if (batchParam.update(towerPurchaseService, "purchase_id")) { |
|||
return success("修改成功"); |
|||
} |
|||
return fail("修改失败"); |
|||
} |
|||
|
|||
@PreAuthorize("hasAuthority('tower:towerPurchase:remove')") |
|||
@OperationLog |
|||
@ApiOperation("批量删除采购入库表") |
|||
@DeleteMapping("/batch") |
|||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) { |
|||
if (towerPurchaseService.removeByIds(ids)) { |
|||
return success("删除成功"); |
|||
} |
|||
return fail("删除失败"); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,76 @@ |
|||
package com.gxwebsoft.tower.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
|
|||
import java.math.BigDecimal; |
|||
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 2024-02-05 20:53:31 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = false) |
|||
@ApiModel(value = "TowerPurchase对象", description = "采购入库表") |
|||
public class TowerPurchase implements Serializable { |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@ApiModelProperty(value = "ID") |
|||
@TableId(value = "purchase_id", type = IdType.AUTO) |
|||
private Integer purchaseId; |
|||
|
|||
@ApiModelProperty(value = "部位名称") |
|||
private String name; |
|||
|
|||
@ApiModelProperty(value = "部件编码") |
|||
private String purchaseCode; |
|||
|
|||
@ApiModelProperty(value = "部件类型") |
|||
private String purchaseType; |
|||
|
|||
@ApiModelProperty(value = "价格") |
|||
private BigDecimal price; |
|||
|
|||
@ApiModelProperty(value = "用户ID") |
|||
private Integer userId; |
|||
|
|||
@ApiModelProperty(value = "企业ID") |
|||
private Integer companyId; |
|||
|
|||
@ApiModelProperty(value = "企业名称") |
|||
private String companyName; |
|||
|
|||
@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.tower.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.gxwebsoft.tower.entity.TowerPurchase; |
|||
import com.gxwebsoft.tower.param.TowerPurchaseParam; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 采购入库表Mapper |
|||
* |
|||
* @author 科技小王子 |
|||
* @since 2024-02-05 20:53:31 |
|||
*/ |
|||
public interface TowerPurchaseMapper extends BaseMapper<TowerPurchase> { |
|||
|
|||
/** |
|||
* 分页查询 |
|||
* |
|||
* @param page 分页对象 |
|||
* @param param 查询参数 |
|||
* @return List<TowerPurchase> |
|||
*/ |
|||
List<TowerPurchase> selectPageRel(@Param("page") IPage<TowerPurchase> page, |
|||
@Param("param") TowerPurchaseParam param); |
|||
|
|||
/** |
|||
* 查询全部 |
|||
* |
|||
* @param param 查询参数 |
|||
* @return List<User> |
|||
*/ |
|||
List<TowerPurchase> selectListRel(@Param("param") TowerPurchaseParam param); |
|||
|
|||
} |
@ -0,0 +1,59 @@ |
|||
<?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.tower.mapper.TowerPurchaseMapper"> |
|||
|
|||
<!-- 关联查询sql --> |
|||
<sql id="selectSql"> |
|||
SELECT a.* |
|||
FROM tower_purchase a |
|||
<where> |
|||
<if test="param.purchaseId != null"> |
|||
AND a.purchase_id = #{param.purchaseId} |
|||
</if> |
|||
<if test="param.name != null"> |
|||
AND a.name LIKE CONCAT('%', #{param.name}, '%') |
|||
</if> |
|||
<if test="param.purchaseCode != null"> |
|||
AND a.purchase_code LIKE CONCAT('%', #{param.purchaseCode}, '%') |
|||
</if> |
|||
<if test="param.purchaseType != null"> |
|||
AND a.purchase_type LIKE CONCAT('%', #{param.purchaseType}, '%') |
|||
</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.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.tower.entity.TowerPurchase"> |
|||
<include refid="selectSql"></include> |
|||
</select> |
|||
|
|||
<!-- 查询全部 --> |
|||
<select id="selectListRel" resultType="com.gxwebsoft.tower.entity.TowerPurchase"> |
|||
<include refid="selectSql"></include> |
|||
</select> |
|||
|
|||
</mapper> |
@ -0,0 +1,60 @@ |
|||
package com.gxwebsoft.tower.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 2024-02-05 20:53:31 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper = false) |
|||
@JsonInclude(JsonInclude.Include.NON_NULL) |
|||
@ApiModel(value = "TowerPurchaseParam对象", description = "采购入库表查询参数") |
|||
public class TowerPurchaseParam extends BaseParam { |
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@ApiModelProperty(value = "ID") |
|||
@QueryField(type = QueryType.EQ) |
|||
private Integer purchaseId; |
|||
|
|||
@ApiModelProperty(value = "部位名称") |
|||
private String name; |
|||
|
|||
@ApiModelProperty(value = "部件编码") |
|||
private String purchaseCode; |
|||
|
|||
@ApiModelProperty(value = "部件类型") |
|||
private String purchaseType; |
|||
|
|||
@ApiModelProperty(value = "用户ID") |
|||
@QueryField(type = QueryType.EQ) |
|||
private Integer userId; |
|||
|
|||
@ApiModelProperty(value = "企业名称") |
|||
private String companyName; |
|||
|
|||
@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.tower.service; |
|||
|
|||
import com.baomidou.mybatisplus.extension.service.IService; |
|||
import com.gxwebsoft.common.core.web.PageResult; |
|||
import com.gxwebsoft.tower.entity.TowerPurchase; |
|||
import com.gxwebsoft.tower.param.TowerPurchaseParam; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 采购入库表Service |
|||
* |
|||
* @author 科技小王子 |
|||
* @since 2024-02-05 20:53:31 |
|||
*/ |
|||
public interface TowerPurchaseService extends IService<TowerPurchase> { |
|||
|
|||
/** |
|||
* 分页关联查询 |
|||
* |
|||
* @param param 查询参数 |
|||
* @return PageResult<TowerPurchase> |
|||
*/ |
|||
PageResult<TowerPurchase> pageRel(TowerPurchaseParam param); |
|||
|
|||
/** |
|||
* 关联查询全部 |
|||
* |
|||
* @param param 查询参数 |
|||
* @return List<TowerPurchase> |
|||
*/ |
|||
List<TowerPurchase> listRel(TowerPurchaseParam param); |
|||
|
|||
/** |
|||
* 根据id查询 |
|||
* |
|||
* @param purchaseId ID |
|||
* @return TowerPurchase |
|||
*/ |
|||
TowerPurchase getByIdRel(Integer purchaseId); |
|||
|
|||
} |
@ -0,0 +1,47 @@ |
|||
package com.gxwebsoft.tower.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import com.gxwebsoft.tower.mapper.TowerPurchaseMapper; |
|||
import com.gxwebsoft.tower.service.TowerPurchaseService; |
|||
import com.gxwebsoft.tower.entity.TowerPurchase; |
|||
import com.gxwebsoft.tower.param.TowerPurchaseParam; |
|||
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 2024-02-05 20:53:32 |
|||
*/ |
|||
@Service |
|||
public class TowerPurchaseServiceImpl extends ServiceImpl<TowerPurchaseMapper, TowerPurchase> implements TowerPurchaseService { |
|||
|
|||
@Override |
|||
public PageResult<TowerPurchase> pageRel(TowerPurchaseParam param) { |
|||
PageParam<TowerPurchase, TowerPurchaseParam> page = new PageParam<>(param); |
|||
//page.setDefaultOrder("create_time desc");
|
|||
List<TowerPurchase> list = baseMapper.selectPageRel(page, param); |
|||
return new PageResult<>(list, page.getTotal()); |
|||
} |
|||
|
|||
@Override |
|||
public List<TowerPurchase> listRel(TowerPurchaseParam param) { |
|||
List<TowerPurchase> list = baseMapper.selectListRel(param); |
|||
// 排序
|
|||
PageParam<TowerPurchase, TowerPurchaseParam> page = new PageParam<>(); |
|||
//page.setDefaultOrder("create_time desc");
|
|||
return page.sortRecords(list); |
|||
} |
|||
|
|||
@Override |
|||
public TowerPurchase getByIdRel(Integer purchaseId) { |
|||
TowerPurchaseParam param = new TowerPurchaseParam(); |
|||
param.setPurchaseId(purchaseId); |
|||
return param.getOne(baseMapper.selectListRel(param)); |
|||
} |
|||
|
|||
} |
Loading…
Reference in new issue