青羊经侦大队-数据平台
11
baizonghao
2023-05-25 7ea5eece501c98a91555a5358931367e78e9d23b
src/main/java/com/example/jz/controller/PublicityController.java
@@ -22,6 +22,8 @@
import javax.annotation.Resource;
import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -56,9 +58,15 @@
        ArrayList<PublicityVo> publicityVos = new ArrayList<>();
        PageParam<Publicity> publicityPageParam ;
        if (publicity.getStatus()!=null ){
            publicityPageParam = publicityService.page(page, new QueryWrapper<Publicity>().like(StringUtils.isNotBlank(publicity.getPublicityTitle()),"publicity_title",publicity.getPublicityTitle()).eq("status",publicity.getStatus()).orderByDesc("ctime"));
            publicityPageParam = publicityService.page(page,
                    new QueryWrapper<Publicity>().like(StringUtils.isNotBlank(publicity.getPublicityTitle()),
                            "publicity_title",
                            publicity.getPublicityTitle()).eq("status",publicity.getStatus()).orderByDesc("ctime"));
        }else {
            publicityPageParam = publicityService.page(page, new QueryWrapper<Publicity>().like(StringUtils.isNotBlank(publicity.getPublicityTitle()),"publicity_title",publicity.getPublicityTitle()).orderByDesc("ctime"));
            publicityPageParam = publicityService.page(page,
                    new QueryWrapper<Publicity>().like(StringUtils.isNotBlank(publicity.getPublicityTitle()),
                            "publicity_title",
                            publicity.getPublicityTitle()).orderByDesc("ctime"));
        }
        publicityPageParam.getRecords().forEach(item->{
            PublicityVo publicityVo = new PublicityVo();
@@ -72,6 +80,20 @@
        return R.ok(publicityVoPageParam);
    }
    @GetMapping("changTime")
    @ApiOperation("修改时间")
    public R changeTime(@RequestParam Integer id, @RequestParam String time){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Publicity publicity = publicityService.getById(id);
        try {
            publicity.setReleaseTime(sdf.parse(time));
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
        boolean b = publicityService.updateById(publicity);
        return b ? R.ok("修改成功") : R.failed("修改失败");
    }
    /**
     * 通过主键查询单条数据
     *