Commit f9ed0dc1 by 吴迪

【修改】政府采购

parent 385c7acd
package io.office.modules.manage.controller;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import io.office.common.annotation.SysLog;
import io.office.common.utils.PageUtils;
import io.office.common.utils.R;
import io.office.common.validator.ValidatorUtils;
import io.office.common.validator.group.AddGroup;
import io.office.common.validator.group.UpdateGroup;
import io.office.modules.manage.entity.ApplicationCaseEntity;
import io.office.modules.manage.form.ApplicationCaseForm;
import io.office.modules.manage.entity.TokenCount;
import io.office.modules.manage.service.ApplicationCaseService;
import io.office.modules.manage.service.TokenCountService;
import io.office.modules.sys.controller.AbstractController;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Value;
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.RestController;
import java.util.Arrays;
import java.util.Map;
......@@ -30,19 +33,30 @@ import java.util.Map;
public class ApplicationCaseController extends AbstractController {
@Autowired
private ApplicationCaseService applicationCaseService;
@Autowired
private TokenCountService tokenCountService;
@Value("${token.count}")
private int tokenCountConfig;
/**
* 列表
*/
@RequestMapping("/list")
//@RequiresPermissions("manage:applicationcase:list")
public R list(@RequestParam Map<String, Object> params) {
public R list(@RequestBody Map<String, Object> params) {
PageUtils page = applicationCaseService.queryPage(params);
return R.ok().put("data", page);
}
@RequestMapping("/api/list")
//@RequiresPermissions("manage:applicationcase:list")
public R getList(@RequestBody Map<String, Object> params) {
PageUtils page = applicationCaseService.queryPage(params);
return R.ok().put("data", page);
}
/**
* 信息
*/
......@@ -56,15 +70,15 @@ public class ApplicationCaseController extends AbstractController {
/**
* 保存
*/
@SysLog("保存XXXX")
@SysLog("保存政府采购应用案例")
@RequestMapping("/save")
//@RequiresPermissions("manage:applicationcase:save")
public R save(@RequestBody ApplicationCaseForm applicationCase) {
public R save(@RequestBody ApplicationCaseEntity applicationCaseEntity) {
//校验参数
ValidatorUtils.validateEntity(applicationCase, AddGroup.class);
// ValidatorUtils.validateEntity(applicationCase, AddGroup.class);
//转化实体对象
ApplicationCaseEntity applicationCaseEntity = new ApplicationCaseEntity();
BeanUtil.copyProperties(applicationCase, applicationCaseEntity);
// ApplicationCaseEntity applicationCaseEntity = new ApplicationCaseEntity();
// BeanUtil.copyProperties(applicationCase, applicationCaseEntity);
applicationCaseService.saveApplicationCase(applicationCaseEntity, getUser());
return R.ok();
......@@ -73,15 +87,10 @@ public class ApplicationCaseController extends AbstractController {
/**
* 修改
*/
@SysLog("修改XXXX")
@SysLog("修改政府采购应用案例")
@RequestMapping("/update")
//@RequiresPermissions("manage:applicationcase:update")
public R update(@RequestBody ApplicationCaseForm applicationCase) {
ValidatorUtils.validateEntity(applicationCase, UpdateGroup.class);
//转化实体对象
ApplicationCaseEntity applicationCaseEntity = new ApplicationCaseEntity();
BeanUtil.copyProperties(applicationCase, applicationCaseEntity);
public R update(@RequestBody ApplicationCaseEntity applicationCaseEntity) {
applicationCaseService.updateApplicationCaseById(applicationCaseEntity, getUser());
return R.ok();
}
......@@ -89,12 +98,59 @@ public class ApplicationCaseController extends AbstractController {
/**
* 删除
*/
@SysLog("删除XXXX")
@SysLog("删除政府采购应用案例")
@RequestMapping("/delete")
//@RequiresPermissions("manage:applicationcase:delete")
public R delete(@RequestBody String[] ids) {
applicationCaseService.removeByIds(Arrays.asList(ids));
for(String id :ids) {
UpdateWrapper<ApplicationCaseEntity> applicationCaseEntityUpdateWrapper = new UpdateWrapper<>();
applicationCaseEntityUpdateWrapper.eq("id",id);
ApplicationCaseEntity applicationCaseEntity = new ApplicationCaseEntity();
applicationCaseEntity.setLevels("0");
applicationCaseService.update(applicationCaseEntity,applicationCaseEntityUpdateWrapper);
}
return R.ok();
}
@SysLog("审批政府采购应用案例")
@RequestMapping("/check")
//@RequiresPermissions("manage:applicationcase:delete")
public R check(@RequestBody ApplicationCaseEntity applicationCaseEntity) {
applicationCaseService.checkApplicationCaseById(applicationCaseEntity, getUser());
return R.ok();
}
@RequestMapping("api/getDetailInfo")
// @RequiresPermissions("manage:partners:info")
public R getDetailInfo(@RequestBody Map<String, String> params){
ApplicationCaseEntity applicationCaseEntity = applicationCaseService.getById(params.get("id"));
if (applicationCaseEntity == null) {
return R.error("没有可显示的内容");
}
if (params.get("token") != null && StringUtils.isNotBlank(params.get("token").toString())) {
QueryWrapper<TokenCount> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("token", params.get("token").toString());
TokenCount tokenCount = tokenCountService.getOne(queryWrapper);
if (tokenCount == null) {
return R.error("非法请求,请获取正确的预览链接!");
}
if (tokenCount.getCountFlag() > tokenCountConfig) {
//删除无用token
return R.error("预览链接次数已达上限,请联系相关人员重新获取预览链接!");
}
tokenCount.setCountFlag(tokenCount.getCountFlag() + 1);
tokenCountService.updateById(tokenCount);
} else {
if (!applicationCaseEntity.getStatus().equals("1")) {
return R.error("没有可显示的内容");
}
if (applicationCaseEntity.getLevels().equals("0") ) {
return R.error("没有可显示的内容");
}
}
return R.ok().put("data", applicationCaseEntity);
}
}
package io.office.modules.manage.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
......@@ -21,7 +22,7 @@ public class ApplicationCaseEntity implements Serializable {
/**
* 主键
*/
@TableId
@TableId(type = IdType.INPUT)
private String id;
/**
* 标题
......@@ -42,7 +43,7 @@ public class ApplicationCaseEntity implements Serializable {
/**
* 级别
*/
private Integer levels;
private String levels;
/**
* 跳转地址
*/
......@@ -54,7 +55,7 @@ public class ApplicationCaseEntity implements Serializable {
/**
* 点击量
*/
private Integer hits;
private int hits;
/**
* 审核人
*/
......@@ -74,6 +75,6 @@ public class ApplicationCaseEntity implements Serializable {
/**
* 状态 0 待审核 1 成功 2 失败
*/
private Integer status;
private String status;
}
......@@ -19,10 +19,16 @@ public interface ApplicationCaseService extends IService<ApplicationCaseEntity>
PageUtils queryPage(Map<String, Object> params);
PageUtils getList(Map<String, Object> params);
@Transactional
void saveApplicationCase(ApplicationCaseEntity applicationCaseEntity, SysUserEntity loginUser);
@Transactional
void updateApplicationCaseById(ApplicationCaseEntity applicationCaseEntity, SysUserEntity loginUser);
@Transactional
void checkApplicationCaseById(ApplicationCaseEntity applicationCaseEntity, SysUserEntity loginUser);
}
package io.office.modules.manage.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sitech.idworkstarter.IdWorkService;
import io.office.common.utils.DateUtils;
import io.office.common.utils.PageUtils;
import io.office.common.utils.Query;
import io.office.modules.manage.dao.ApplicationCaseDao;
import io.office.modules.manage.entity.ApplicationCaseEntity;
import io.office.modules.manage.service.ApplicationCaseService;
import io.office.modules.sys.entity.SysUserEntity;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.Map;
@Service("applicationCaseService")
public class ApplicationCaseServiceImpl extends ServiceImpl<ApplicationCaseDao, ApplicationCaseEntity> implements ApplicationCaseService {
......@@ -26,9 +28,43 @@ public class ApplicationCaseServiceImpl extends ServiceImpl<ApplicationCaseDao,
@Override
public PageUtils queryPage(Map<String, Object> params) {
QueryWrapper<ApplicationCaseEntity> applicationCaseEntityQueryWrapper = new QueryWrapper<>();
if (null != params.get("levels") && StringUtils.isNotBlank(params.get("levels").toString())) {
applicationCaseEntityQueryWrapper.eq("levels", params.get("levels").toString());
} else {
applicationCaseEntityQueryWrapper.gt("levels", 0);
}
if (null != params.get("title") && StringUtils.isNotBlank(params.get("title").toString())) {
applicationCaseEntityQueryWrapper.like("title", params.get("title").toString());
}
if (null != params.get("author") && StringUtils.isNotBlank(params.get("author").toString())) {
applicationCaseEntityQueryWrapper.eq("author", params.get("author").toString());
}
if (null != params.get("status") && StringUtils.isNotBlank(params.get("status").toString())) {
applicationCaseEntityQueryWrapper.eq("status", params.get("status").toString());
}
applicationCaseEntityQueryWrapper.orderByAsc("release_date");
IPage<ApplicationCaseEntity> page = this.page(
new Query<ApplicationCaseEntity>().getPage(params),
applicationCaseEntityQueryWrapper
);
return new PageUtils(page);
}
@Override
public PageUtils getList(Map<String, Object> params) {
QueryWrapper<ApplicationCaseEntity> applicationCaseEntityQueryWrapper = new QueryWrapper<>();
applicationCaseEntityQueryWrapper.gt("status", 0);
applicationCaseEntityQueryWrapper.orderByAsc("levels");
applicationCaseEntityQueryWrapper.orderByDesc("show_date");
IPage<ApplicationCaseEntity> page = this.page(
new Query<ApplicationCaseEntity>().getPage(params),
new QueryWrapper<ApplicationCaseEntity>().eq("is_publish",1)
applicationCaseEntityQueryWrapper
);
return new PageUtils(page);
......@@ -37,12 +73,30 @@ public class ApplicationCaseServiceImpl extends ServiceImpl<ApplicationCaseDao,
@Override
public void updateApplicationCaseById(ApplicationCaseEntity applicationCaseEntity, SysUserEntity loginUser) {
baseMapper.updateById(applicationCaseEntity);
UpdateWrapper<ApplicationCaseEntity> applicationCaseEntityUpdateWrapper = new UpdateWrapper<>();
applicationCaseEntityUpdateWrapper.eq("id", applicationCaseEntity.getId());
applicationCaseEntity.setUpdateUser(loginUser.getUsername());
applicationCaseEntity.setUpdateDate(DateUtils.format(new Date(), DateUtils.DATE_TIME_PATTERN));
baseMapper.update(applicationCaseEntity, applicationCaseEntityUpdateWrapper);
}
@Override
public void checkApplicationCaseById(ApplicationCaseEntity applicationCaseEntity, SysUserEntity loginUser) {
UpdateWrapper<ApplicationCaseEntity> applicationCaseEntityUpdateWrapper = new UpdateWrapper<>();
applicationCaseEntityUpdateWrapper.eq("id", applicationCaseEntity.getId());
applicationCaseEntity.setCheckUser(loginUser.getUsername());
applicationCaseEntity.setCheckDate(DateUtils.format(new Date(), DateUtils.DATE_TIME_PATTERN));
baseMapper.update(applicationCaseEntity, applicationCaseEntityUpdateWrapper);
}
@Override
public void saveApplicationCase(ApplicationCaseEntity applicationCaseEntity, SysUserEntity loginUser) {
applicationCaseEntity.setId(idWorkService.getSEQByKey("id_seq"));
applicationCaseEntity.setReleaseDate(DateUtils.format(new Date(), DateUtils.DATE_TIME_PATTERN));
//applicationCaseEntity.setAuthor(loginUser.getUsername());
applicationCaseEntity.setHits(0);
//applicationCaseEntity.set
baseMapper.insert(applicationCaseEntity);
}
......
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