Commit 2057f79e by rongkailun

【新增】政策法规管理新增修改

parent dd6491f9
......@@ -7,6 +7,8 @@ import io.office.common.utils.PageUtils;
import io.office.common.utils.R;
import io.office.modules.manage.entity.PolicyEntity;
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;
......@@ -26,8 +28,9 @@ import org.springframework.web.bind.annotation.RestController;
* @date 2021-11-04 22:13:54
*/
@RestController
@RequestMapping("generator/policy")
public class PolicyController {
@RequestMapping("/policy")
@Slf4j
public class PolicyController extends AbstractController {
@Autowired
private PolicyService policyService;
......@@ -35,7 +38,7 @@ public class PolicyController {
* 列表
*/
@RequestMapping("/list")
@RequiresPermissions("generator:policy:list")
// @RequiresPermissions("generator:policy:list")
public R list(@RequestParam Map<String, Object> params){
PageUtils page = policyService.queryPage(params);
......@@ -47,7 +50,7 @@ public class PolicyController {
* 信息
*/
@RequestMapping("/info/{id}")
@RequiresPermissions("generator:policy:info")
// @RequiresPermissions("generator:policy:info")
public R info(@PathVariable("id") Integer id){
PolicyEntity policy = policyService.getById(id);
......@@ -58,29 +61,37 @@ public class PolicyController {
* 保存
*/
@RequestMapping("/save")
@RequiresPermissions("generator:policy:save")
// @RequiresPermissions("generator:policy:save")
public R save(@RequestBody PolicyEntity policy){
policyService.save(policy);
return R.ok();
try {
R r = this.policyService.inserPolicy(policy, getUser());
return r;
} catch (Exception e) {
log.error("save error:", e);
return R.error(e.getMessage());
}
}
/**
* 修改
*/
@RequestMapping("/update")
@RequiresPermissions("generator:policy:update")
// @RequiresPermissions("generator:policy:update")
public R update(@RequestBody PolicyEntity policy){
policyService.updateById(policy);
return R.ok();
try {
R r = this.policyService.updatePolicy(policy, getUser());
return r;
} catch (Exception e) {
log.error("save error:", e);
return R.error(e.getMessage());
}
}
/**
* 删除
*/
@RequestMapping("/delete")
@RequiresPermissions("generator:policy:delete")
// @RequiresPermissions("generator:policy:delete")
public R delete(@RequestBody Integer[] ids){
policyService.removeByIds(Arrays.asList(ids));
......
......@@ -89,11 +89,11 @@ public class PolicyEntity implements Serializable {
/**
* $column.comments
*/
private String publicdate;
private Date publicdate;
/**
* $column.comments
*/
private String startdate;
private Date startdate;
/**
* $column.comments
*/
......
......@@ -2,7 +2,9 @@ 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.PolicyEntity;
import io.office.modules.sys.entity.SysUserEntity;
import java.util.Map;
......@@ -16,5 +18,9 @@ import java.util.Map;
public interface PolicyService extends IService<PolicyEntity> {
PageUtils queryPage(Map<String, Object> params);
R inserPolicy(PolicyEntity policy, SysUserEntity user);
R updatePolicy(PolicyEntity policy, SysUserEntity user);
}
......@@ -2,10 +2,15 @@ package io.office.modules.manage.service.impl;
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.PolicyEntity;
import io.office.modules.manage.service.PolicyService;
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;
......@@ -25,4 +30,36 @@ public class PolicyServiceImpl extends ServiceImpl<PolicyDao, PolicyEntity> impl
return new PageUtils(page);
}
@Override
public R inserPolicy(PolicyEntity policy, SysUserEntity user) {
policy.setEditor(user.getUsername());
policy.setLasteditor(user.getUsername());
policy.setStartdate(new Date());
policy.setPublicdate(new Date());
//二级栏目不为空时 classid取值二级栏目id值
int insert = baseMapper.insert(policy);
if (insert>0){
return R.ok("新增成功!");
}else{
return R.error("新增失败!");
}
}
@Override
public R updatePolicy(PolicyEntity policy, SysUserEntity user) {
if(policy.getId() ==null){
return R.error("id不能为空!");
}
QueryWrapper<PolicyEntity> newsEntityQueryWrapper = new QueryWrapper<>();
newsEntityQueryWrapper.eq("id",policy.getId());
policy.setEditor(user.getUsername());
policy.setLasteditor(user.getUsername());
int update = baseMapper.update(policy, newsEntityQueryWrapper);
if (update>0){
return R.ok("修改成功!");
}else{
return R.error("修改失败!");
}
}
}
\ 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