|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.zy.acs.common.constant.CommonConstant; | 
|---|
|  |  |  | import com.zy.acs.common.utils.GsonUtils; | 
|---|
|  |  |  | import com.zy.acs.common.utils.Utils; | 
|---|
|  |  |  | import com.zy.acs.framework.common.Cools; | 
|---|
|  |  |  | import com.zy.acs.framework.common.R; | 
|---|
|  |  |  | import com.zy.acs.manager.common.annotation.OperationLog; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.servlet.http.HttpServletResponse; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  | import java.util.stream.Collectors; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping("/api") | 
|---|
|  |  |  | 
|---|
|  |  |  | @OperationLog("Create Code") | 
|---|
|  |  |  | @PostMapping("/code/save") | 
|---|
|  |  |  | public R save(@RequestBody Code code) { | 
|---|
|  |  |  | code.setData(Utils.zeroFill(code.getData(), CommonConstant.QR_CODE_LEN)); | 
|---|
|  |  |  | code.setUuid("code".concat(code.getData())); | 
|---|
|  |  |  | code.setCreateBy(getLoginUserId()); | 
|---|
|  |  |  | code.setCreateTime(new Date()); | 
|---|
|  |  |  | code.setUpdateBy(getLoginUserId()); | 
|---|
|  |  |  | 
|---|
|  |  |  | @OperationLog("Update Code") | 
|---|
|  |  |  | @PostMapping("/code/update") | 
|---|
|  |  |  | public R update(@RequestBody Code code) { | 
|---|
|  |  |  | code.setData(Utils.zeroFill(code.getData(), CommonConstant.QR_CODE_LEN)); | 
|---|
|  |  |  | code.setUpdateBy(getLoginUserId()); | 
|---|
|  |  |  | code.setUpdateTime(new Date()); | 
|---|
|  |  |  | if (!codeService.updateById(code)) { | 
|---|
|  |  |  | return R.error("Update Fail"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok("Update Success").add(code); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:loc:update')") | 
|---|
|  |  |  | @OperationLog("Update Code") | 
|---|
|  |  |  | @PostMapping("/code/update/many") | 
|---|
|  |  |  | public R updateMany(@RequestBody List<Code> list) { | 
|---|
|  |  |  | if (!Cools.isEmpty(list)) { | 
|---|
|  |  |  | for (Code code : list) { | 
|---|
|  |  |  | code.setUpdateBy(getLoginUserId()); | 
|---|
|  |  |  | code.setUpdateTime(new Date()); | 
|---|
|  |  |  | if (!codeService.updateById(code)) { | 
|---|
|  |  |  | return R.error("Update Fail"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok("Update Success").add(list.stream().map(Code::getId).collect(Collectors.toList())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PreAuthorize("hasAuthority('manager:code:remove')") | 
|---|
|  |  |  | 
|---|
|  |  |  | if (null != codeService.selectByData(code.getData())) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | code.setData(Utils.zeroFill(code.getData(), CommonConstant.QR_CODE_LEN)); | 
|---|
|  |  |  | code.setUuid("code".concat(code.getData())); | 
|---|
|  |  |  | code.setConcer(0); | 
|---|
|  |  |  | code.setScale(GsonUtils.toJson(Cools.add("x", 1).add("y", 1))); | 
|---|