Commit ada5b913 by 吴迪

Merge remote-tracking branch 'origin/master'

parents febade2d 69f45679
package io.office.modules.manage.controller;
import java.util.Arrays;
import java.util.Map;
import io.office.modules.sys.controller.AbstractController;
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 io.office.modules.manage.entity.PcategoryEntity;
import io.office.modules.manage.service.PcategoryService;
import io.office.common.utils.PageUtils;
import io.office.common.utils.R;
/**
* 商品分类
*
* @author rkl
* @email
* @date 2021-11-13 22:13:03
*/
@RestController
@RequestMapping("/pcategory")
@Slf4j
public class PcategoryController extends AbstractController {
@Autowired
private PcategoryService pcategoryService;
/**
* 列表
*/
@RequestMapping("/list")
// @RequiresPermissions("manage:pcategory:list")
public R list(@RequestParam Map<String, Object> params){
PageUtils page = pcategoryService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 信息
*/
@RequestMapping("/info/{categoryid}")
// @RequiresPermissions("manage:pcategory:info")
public R info(@PathVariable("categoryid") Integer categoryid){
PcategoryEntity pcategory = pcategoryService.getById(categoryid);
return R.ok().put("pcategory", pcategory);
}
/**
* 保存
*/
@RequestMapping("/save")
// @RequiresPermissions("manage:pcategory:save")
public R save(@RequestBody PcategoryEntity pcategory){
try {
R r = this.pcategoryService.insertPcategory(pcategory, getUser());
return r;
} catch (Exception e) {
log.error("save error:", e);
return R.error(e.getMessage());
}
}
/**
* 修改
*/
@RequestMapping("/update")
// @RequiresPermissions("manage:pcategory:update")
public R update(@RequestBody PcategoryEntity pcategory){
try {
R r = this.pcategoryService.updatePcategory(pcategory, getUser());
return r;
} catch (Exception e) {
log.error("update error:", e);
return R.error(e.getMessage());
}
}
/**
* 删除
*/
@RequestMapping("/delete")
// @RequiresPermissions("manage:pcategory:delete")
public R delete(@RequestBody Integer[] categoryids){
pcategoryService.removeByIds(Arrays.asList(categoryids));
return R.ok();
}
}
......@@ -3,27 +3,25 @@ package io.office.modules.manage.controller;
import java.util.Arrays;
import java.util.Map;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.PictureEntity;
import io.office.modules.manage.entity.PolicyEntity;
import io.office.modules.manage.entity.dto.PolicyParams;
import io.office.modules.manage.service.PolicyService;
import io.office.modules.sys.controller.AbstractController;
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.*;
/**
* ${comments}
* 政策法规
*
* @author chenshun
* @author rkl
* @email sunlightcs@gmail.com
* @date 2021-11-04 22:13:54
*/
......@@ -39,10 +37,11 @@ public class PolicyController extends AbstractController {
*/
@RequestMapping("/list")
// @RequiresPermissions("generator:policy:list")
public R list(@RequestParam Map<String, Object> params){
PageUtils page = policyService.queryPage(params);
return R.ok().put("page", page);
public R list(@RequestBody PolicyParams params){
Page<PictureEntity> page = this.policyService.selectPolicyList(params,
new Page(params.getPage(),params.getLimit()));
PageUtils pageUtils = new PageUtils(page);
return R.ok().put("page", pageUtils);
}
......@@ -93,9 +92,27 @@ public class PolicyController extends AbstractController {
@RequestMapping("/delete")
// @RequiresPermissions("generator:policy:delete")
public R delete(@RequestBody Integer[] ids){
policyService.removeByIds(Arrays.asList(ids));
return R.ok();
try {
R r = this.policyService.deletePolicy(ids, getUser());
return r;
} catch (Exception e) {
log.error("delete error:", e);
return R.error(e.getMessage());
}
}
/**
* 审核
*/
@PostMapping("/verifyPolicy")
// @RequiresPermissions("manage:news:verify")
public R verify(@RequestBody PolicyEntity policyEntity) {
try {
R r = this.policyService.verifyTopic(policyEntity,getUser());
return r;
} catch (Exception e) {
log.error("verifyPolicy error:", e);
return R.error(e.getMessage());
}
}
}
package io.office.modules.manage.dao;
import io.office.modules.manage.entity.PcategoryEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* ${comments}
*
* @author rkl
* @email
* @date 2021-11-13 22:13:03
*/
@Mapper
public interface PcategoryDao extends BaseMapper<PcategoryEntity> {
}
package io.office.modules.manage.dao;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.office.modules.manage.entity.NewsEntity;
import io.office.modules.manage.entity.PolicyEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.office.modules.manage.entity.dto.PolicyParams;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* ${comments}
......@@ -14,4 +20,5 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface PolicyDao extends BaseMapper<PolicyEntity> {
List<NewsEntity> selectPolicyList(@Param("newsParams") PolicyParams 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-13 22:13:03
*/
@Data
@TableName("Pcategory")
public class PcategoryEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* $column.comments
*/
@TableId
private Integer categoryid;
/**
* $column.comments
*/
private String category;
/**
* $column.comments
*/
private Integer parentid;
/**
* $column.comments
*/
private Integer childnum;
/**
* $column.comments
*/
private Integer depth;
/**
* $column.comments
*/
private String ppath;
}
......@@ -89,11 +89,11 @@ public class PolicyEntity implements Serializable {
/**
* $column.comments
*/
private Date publicdate;
private String publicdate;
/**
* $column.comments
*/
private Date startdate;
private String startdate;
/**
* $column.comments
*/
......
package io.office.modules.manage.entity.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.office.modules.manage.entity.page.PageParams;
import lombok.Data;
import java.util.Date;
/**
* @author JavaClimber
* @version 1.0
* @date 2021/11/13 21:21
*/
@Data
public class PolicyParams extends PageParams {
private String title;
private String editor;
private String keyword;
private String status;
private String class1;
private String level;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTimeStart;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTimeEnd;
}
\ No newline at end of file
package io.office.modules.manage.service;
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.PcategoryEntity;
import io.office.modules.sys.entity.SysUserEntity;
import java.util.Map;
/**
* 商品分类
* @author rkl
* @email
* @date 2021-11-13 22:13:03
*/
public interface PcategoryService extends IService<PcategoryEntity> {
PageUtils queryPage(Map<String, Object> params);
R insertPcategory(PcategoryEntity pcategory, SysUserEntity user);
R updatePcategory(PcategoryEntity pcategory, SysUserEntity user);
}
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.PictureEntity;
import io.office.modules.manage.entity.PolicyEntity;
import io.office.modules.manage.entity.dto.PolicyParams;
import io.office.modules.sys.entity.SysUserEntity;
import java.util.Map;
......@@ -22,5 +25,11 @@ public interface PolicyService extends IService<PolicyEntity> {
R inserPolicy(PolicyEntity policy, SysUserEntity user);
R updatePolicy(PolicyEntity policy, SysUserEntity user);
R deletePolicy(Integer[] ids, SysUserEntity user);
R verifyTopic(PolicyEntity policyEntity, SysUserEntity user);
Page<PictureEntity> selectPolicyList(PolicyParams params, Page page);
}
package io.office.modules.manage.service.impl;
import io.office.common.utils.R;
import io.office.modules.manage.entity.NewsEntity;
import io.office.modules.sys.entity.SysUserEntity;
import org.springframework.stereotype.Service;
import java.util.Date;
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.PcategoryDao;
import io.office.modules.manage.entity.PcategoryEntity;
import io.office.modules.manage.service.PcategoryService;
@Service("pcategoryService")
public class PcategoryServiceImpl extends ServiceImpl<PcategoryDao, PcategoryEntity> implements PcategoryService {
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<PcategoryEntity> page = this.page(
new Query<PcategoryEntity>().getPage(params),
new QueryWrapper<PcategoryEntity>()
);
return new PageUtils(page);
}
@Override
public R insertPcategory(PcategoryEntity pcategory, SysUserEntity user) {
int insert = baseMapper.insert(pcategory);
if (insert>0){
return R.ok("新增成功!");
}else{
return R.error("新增失败!");
}
}
@Override
public R updatePcategory(PcategoryEntity pcategory, SysUserEntity user) {
QueryWrapper<PcategoryEntity> newsEntityQueryWrapper = new QueryWrapper<>();
newsEntityQueryWrapper.eq("categoryid",pcategory.getCategoryid());
int update = baseMapper.update(pcategory, newsEntityQueryWrapper);
if (update>0){
return R.ok("修改成功!");
}else{
return R.error("修改失败!");
}
}
}
\ 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.DateUtils;
import io.office.common.utils.PageUtils;
import io.office.common.utils.Query;
import io.office.common.utils.R;
import io.office.modules.manage.dao.PolicyDao;
import io.office.modules.manage.entity.NewsEntity;
import io.office.modules.manage.entity.PictureEntity;
import io.office.modules.manage.entity.PolicyEntity;
import io.office.modules.manage.entity.dto.PolicyParams;
import io.office.modules.manage.service.PolicyService;
import io.office.modules.sys.entity.SysUserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
......@@ -20,6 +26,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@Service("policyService")
public class PolicyServiceImpl extends ServiceImpl<PolicyDao, PolicyEntity> implements PolicyService {
@Autowired
private PolicyDao policyDao;
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<PolicyEntity> page = this.page(
......@@ -34,8 +42,8 @@ public class PolicyServiceImpl extends ServiceImpl<PolicyDao, PolicyEntity> impl
public R inserPolicy(PolicyEntity policy, SysUserEntity user) {
policy.setEditor(user.getUsername());
policy.setLasteditor(user.getUsername());
policy.setStartdate(new Date());
policy.setPublicdate(new Date());
policy.setReleasedate(new Date());
policy.setUpdatedate(new Date());
//二级栏目不为空时 classid取值二级栏目id值
int insert = baseMapper.insert(policy);
if (insert>0){
......@@ -54,6 +62,7 @@ public class PolicyServiceImpl extends ServiceImpl<PolicyDao, PolicyEntity> impl
newsEntityQueryWrapper.eq("id",policy.getId());
policy.setEditor(user.getUsername());
policy.setLasteditor(user.getUsername());
policy.setUpdatedate(new Date());
int update = baseMapper.update(policy, newsEntityQueryWrapper);
if (update>0){
return R.ok("修改成功!");
......@@ -62,4 +71,37 @@ public class PolicyServiceImpl extends ServiceImpl<PolicyDao, PolicyEntity> impl
}
}
@Override
public R deletePolicy(Integer[] ids, SysUserEntity user) {
PolicyEntity policyEntity = new PolicyEntity();
policyEntity.setLevels(0);
policyEntity.setLasteditor(user.getUsername());
policyEntity.setUpdatedate(new Date());
QueryWrapper<PolicyEntity> newsEntityQueryWrapper = new QueryWrapper<>();
newsEntityQueryWrapper.in("id",ids);
int delete = baseMapper.update(policyEntity, newsEntityQueryWrapper);
if (delete>0){
return R.ok("删除成功!");
}else{
return R.error("删除失败!");
}
}
@Override
public R verifyTopic(PolicyEntity policyEntity, SysUserEntity user) {
policyEntity.setAuditor(user.getUsername());
policyEntity.setLasteditor(user.getUsername());
QueryWrapper<PolicyEntity> newsEntityQueryWrapper = new QueryWrapper<>();
newsEntityQueryWrapper.eq("id",policyEntity.getId());
baseMapper.update(policyEntity, newsEntityQueryWrapper);
return R.ok("审核成功!");
}
@Override
public Page<PictureEntity> selectPolicyList(PolicyParams params, Page page) {
List<NewsEntity> newsList = this.policyDao.selectPolicyList(params, page);
page.setRecords(newsList);
return page;
}
}
\ No newline at end of file
......@@ -6,7 +6,7 @@
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="io.office.modules.manage.entity.PolicyEntity" id="policyMap">
<result property="id" column="id"/>
<result property="class" column="class"/>
<result property="class1" column="class"/>
<result property="title" column="title"/>
<result property="titleOld" column="title_old"/>
<result property="keyword" column="keyword"/>
......@@ -26,6 +26,27 @@
<result property="status" column="status"/>
<result property="auditor" column="auditor"/>
</resultMap>
<select id="selectPolicyList" resultMap="policyMap" parameterType="io.office.modules.manage.entity.dto.PolicyParams">
select class,title,editor,lasteditor,releasedate,updatedate,auditor,status from Policy
where 1=1
<if test="newsParams.updateTimeStart !=null and newsParams.updateTimeEnd !=null">
and updatedate BETWEEN #{newsParams.updateTimeStart} AND #{newsParams.updateTimeEnd}
</if>
<if test="newsParams.keyword !=null and newsParams.keyword !=''">
and keyword like concat('%',#{newsParams.keyword},'%')
</if>
<if test="newsParams.title !=null and newsParams.title !=''">
and title like concat('%',#{newsParams.title},'%')
</if>
<if test="newsParams.status !=null">
and status =#{newsParams.status}
</if>
<if test="newsParams.editor !=null and newsParams.editor !=''">
and editor =#{newsParams.editor}
</if>
ORDER BY
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