Commit 9ced1266 by rongkailun

【新增】商品管理审核、列表;术语管理新增列表修改

parent f80999e3
package io.office.modules.manage.controller;
import java.util.Arrays;
import java.util.Date;
import java.util.Map;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.office.modules.manage.entity.ProductEntity;
import io.office.modules.sys.controller.AbstractController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.office.modules.manage.entity.GlossaryEntity;
import io.office.modules.manage.service.GlossaryService;
import io.office.common.utils.PageUtils;
import io.office.common.utils.R;
/**
*
* 术语管理
* @author rkl
* @email
* @date 2021-11-15 18:29:59
*/
@RestController
@RequestMapping("/glossary")
public class GlossaryController extends AbstractController {
@Autowired
private GlossaryService glossaryService;
/**
* 列表
*/
@RequestMapping("/list")
// @RequiresPermissions("manage:glossary:list")
public R list(@RequestParam Map<String, Object> params){
Page<GlossaryEntity> page = this.glossaryService.selectGlossaryList(params,
new Page(Integer.valueOf(params.get("page").toString()),
Integer.valueOf(params.get("limit").toString())));
return R.ok().put("page", page);
}
/**
* 信息
*/
@RequestMapping("/info/{id}")
// @RequiresPermissions("manage:glossary:info")
public R info(@PathVariable("id") Integer id){
GlossaryEntity glossary = glossaryService.getById(id);
return R.ok().put("glossary", glossary);
}
/**
* 保存
*/
@RequestMapping("/save")
// @RequiresPermissions("manage:glossary:save")
public R save(@RequestBody GlossaryEntity glossary){
glossary.setEditor(getUser().getUsername());
glossary.setLasteditor(getUser().getUsername());
glossaryService.save(glossary);
return R.ok("术语新增成功!");
}
/**
* 修改
*/
@RequestMapping("/update")
// @RequiresPermissions("manage:glossary:update")
public R update(@RequestBody GlossaryEntity glossary){
glossary.setEditor(getUser().getUsername());
glossary.setLasteditor(getUser().getUsername());
glossary.setUpdatedate(new Date());
glossaryService.updateById(glossary);
return R.ok("术语修改成功!");
}
/**
* 删除
*/
@RequestMapping("/delete")
// @RequiresPermissions("manage:glossary:delete")
public R delete(@RequestBody Integer[] ids){
GlossaryEntity glossary = new GlossaryEntity();
glossary.setEditor(getUser().getUsername());
glossary.setLasteditor(getUser().getUsername());
glossaryService.updateById(glossary);
return R.ok("术语删除成功!");
}
}
......@@ -4,15 +4,14 @@ import java.util.Arrays;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.office.modules.manage.entity.NewsEntity;
import io.office.modules.sys.controller.AbstractController;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import io.office.modules.manage.entity.ProductEntity;
import io.office.modules.manage.service.ProductService;
......@@ -41,8 +40,11 @@ public class ProductController extends AbstractController {
@RequestMapping("/list")
// @RequiresPermissions("manage:product:list")
public R list(@RequestParam Map<String, Object> params){
PageUtils page = productService.queryPage(params);
return R.ok().put("page", page);
Page<ProductEntity> page = this.productService.selectProductList(params,
new Page(Integer.valueOf(params.get("page").toString()),
Integer.valueOf(params.get("limit").toString())));
PageUtils pageUtils = new PageUtils(page);
return R.ok().put("page", pageUtils);
}
......@@ -97,4 +99,19 @@ public class ProductController extends AbstractController {
}
}
/**
* 审核
*/
@PostMapping("/verifyProduct")
// @RequiresPermissions("manage:news:verify")
public R verify(@RequestBody ProductEntity product) {
try {
R r = this.productService.verifyProduct(product, getUser());
return r;
} catch (Exception e) {
log.error("verifyProduct error:", e);
return R.error(e.getMessage());
}
}
}
package io.office.modules.manage.dao;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.office.modules.manage.entity.GlossaryEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* ${comments}
*
* @author wudi
* @email
* @date 2021-11-15 18:29:59
*/
@Mapper
public interface GlossaryDao extends BaseMapper<GlossaryEntity> {
List<GlossaryEntity> selectGlossaryList(@Param("params") Map<String, Object> params, Page page);
}
package io.office.modules.manage.dao;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.office.modules.manage.entity.ProductEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* ${comments}
......@@ -13,5 +18,6 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface ProductDao extends BaseMapper<ProductEntity> {
List<ProductEntity> selectProductList(@Param("params") Map<String, Object> params, Page page);
}
package io.office.modules.manage.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* ${comments}
*
* @author rkl
* @email
* @date 2021-11-15 18:29:59
*/
@Data
@TableName("glossary")
public class GlossaryEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* $column.comments
*/
@TableId
private Integer id;
/**
* $column.comments
*/
private String titleEn;
/**
* $column.comments
*/
private String titleCn;
/**
* $column.comments
*/
private String keyword;
/**
* $column.comments
*/
private String brief;
/**
* $column.comments
*/
private Date releasedate;
/**
* $column.comments
*/
private Date updatedate;
/**
* $column.comments
*/
private String author;
/**
* $column.comments
*/
private String content;
/**
* $column.comments
*/
private Integer hits;
/**
* $column.comments
*/
private String editor;
/**
* $column.comments
*/
private String lasteditor;
}
package io.office.modules.manage.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import io.office.common.utils.PageUtils;
import io.office.modules.manage.entity.GlossaryEntity;
import io.office.modules.manage.entity.ProductEntity;
import java.util.Map;
/**
* ${comments}
*
* @author wudi
* @email
* @date 2021-11-15 18:29:59
*/
public interface GlossaryService extends IService<GlossaryEntity> {
PageUtils queryPage(Map<String, Object> params);
Page<GlossaryEntity> selectGlossaryList(Map<String, Object> params, Page page);
}
package io.office.modules.manage.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import io.office.common.utils.PageUtils;
import io.office.common.utils.R;
import io.office.modules.manage.entity.NewsEntity;
import io.office.modules.manage.entity.ProductEntity;
import io.office.modules.sys.entity.SysUserEntity;
......@@ -23,5 +25,9 @@ public interface ProductService extends IService<ProductEntity> {
R insertProduct(ProductEntity product, SysUserEntity user);
R deleteProduct(List<Long> ids, SysUserEntity user);
R verifyProduct(ProductEntity product, SysUserEntity user);
Page<ProductEntity> selectProductList(Map<String, Object> params, Page page);
}
package io.office.modules.manage.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.office.modules.manage.entity.ProductEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.office.common.utils.PageUtils;
import io.office.common.utils.Query;
import io.office.modules.manage.dao.GlossaryDao;
import io.office.modules.manage.entity.GlossaryEntity;
import io.office.modules.manage.service.GlossaryService;
@Service("glossaryService")
public class GlossaryServiceImpl extends ServiceImpl<GlossaryDao, GlossaryEntity> implements GlossaryService {
@Autowired
GlossaryDao glossaryDao;
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<GlossaryEntity> page = this.page(
new Query<GlossaryEntity>().getPage(params),
new QueryWrapper<GlossaryEntity>()
);
return new PageUtils(page);
}
@Override
public Page<GlossaryEntity> selectGlossaryList(Map<String, Object> params, Page page) {
List<GlossaryEntity> list = this.glossaryDao.selectGlossaryList(params,page);
page.setRecords(list);
return page;
}
}
\ No newline at end of file
package io.office.modules.manage.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.office.common.utils.R;
import io.office.modules.manage.controller.ProductController;
import io.office.modules.manage.entity.NewsEntity;
import io.office.modules.sys.entity.SysUserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
......@@ -22,6 +25,8 @@ import io.office.modules.manage.service.ProductService;
@Service("productService")
public class ProductServiceImpl extends ServiceImpl<ProductDao, ProductEntity> implements ProductService {
@Autowired
ProductDao productDao;
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<ProductEntity> page = this.page(
......@@ -57,4 +62,24 @@ public class ProductServiceImpl extends ServiceImpl<ProductDao, ProductEntity> i
}
}
@Override
public R verifyProduct(ProductEntity product, SysUserEntity user) {
product.setAuditor(user.getUsername());
QueryWrapper<ProductEntity> newsEntityQueryWrapper = new QueryWrapper<>();
newsEntityQueryWrapper.in("id",product.getId());
int delete = baseMapper.update(product, newsEntityQueryWrapper);
if (delete>0){
return R.ok("审核成功!");
}else{
return R.error("审核失败!");
}
}
@Override
public Page<ProductEntity> selectProductList(Map<String, Object> params, Page page) {
List<ProductEntity> list = this.productDao.selectProductList(params,page);
page.setRecords(list);
return page;
}
}
\ No newline at end of file
<?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="io.office.modules.manage.dao.GlossaryDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="io.office.modules.manage.entity.GlossaryEntity" id="glossaryMap">
<result property="id" column="ID"/>
<result property="titleEn" column="title_EN"/>
<result property="titleCn" column="title_CN"/>
<result property="keyword" column="keyword"/>
<result property="brief" column="brief"/>
<result property="releasedate" column="releasedate"/>
<result property="updatedate" column="updatedate"/>
<result property="author" column="author"/>
<result property="content" column="content"/>
<result property="hits" column="hits"/>
<result property="editor" column="editor"/>
<result property="lasteditor" column="lasteditor"/>
</resultMap>
<select id="selectGlossaryList" resultMap="glossaryMap" parameterType="java.util.Map">
select * from glossary t
where 1=1
<if test="params.titleCn !='' and params.titleCn !=null">
<choose>
<when test="params.titleCn == '中文标题'">
and t.title_CN like concat('%',#{params.keyword},'%')
</when>
<otherwise>
and t.title_EN like concat('%',#{params.keyword},'%')
</otherwise>
</choose>
</if>
order by id desc
</select>
</mapper>
\ No newline at end of file
......@@ -47,5 +47,14 @@
<result property="auditor" column="auditor"/>
</resultMap>
<select id="selectProductList" resultMap="productMap" parameterType="java.util.Map">
select a.* from product a left join Pcategory b on a.categoryid=b.categoryid where levels>0
<if test="params.keyword !='' and params.keyword !=null">
and a.prename like concat('%',#{params.keyword},'%')
</if>
<if test="params.categoryid !='' and params.categoryid !=null">
and a.categoryid =#{params.categoryid}
</if>
order by a.id desc
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment