easyui authentication extension

Problem Description:

As shown above: when users add information, they must ensure that a team can only have one piece of data a day. Therefore, when the report date is selected, you must query whether the data of the current team in the database exists. If it does not exist, i.e. the current date team has no data, data can be added; otherwise, it cannot be added again.

The foreground page, as shown above, is a table. The data option attribute contains its own validation: validType:'reportDate'. And this verification is written in js of the interface.

//Verification extension daily report verification (each team has only one daily report a day)
$.extend($.fn.validatebox.defaults.rules, {
	reportDate : {
        validator : function(value, param) {
        	 var response = $.ajax({
                 url: '/dh/rpt/fa/day/team/getDayTeam',
                 data: {reportDate:value},
                 async: false,
                 type: 'get'
        	  var obj = JSON.parse(response);
              if (obj.length==0){
                  return true;
              } else {
                  return false;
        message : 'Daily report of this date already exists'

The main purpose of js is to get the date we filled in and send it to the map of the controller in the background. Query in the background, and return the number of queried data.

 * Verification (each team can only have one daily report per day)
 * @param user
 * @return queryAll
@RequestMapping(value="/getDayTeam",method= {RequestMethod.GET})
public List<Map<String, Object>> getDayTeam( @RequestParam Map<String, Object> map, User user) {
	map.put("orgCode", user.getOrg().getOrgCode());
	List<Map<String, Object>> queryAll = queryService.queryAll("DhRptFaDayTeamMapper","selectDayTeamByDateAndOrgCode", map);
	return queryAll;

In the background controller, query queryAll by getting the date passed to the foreground.

    <!--Verify that each team can only have one daily report per day -Squad-->
    <select id="selectDayTeamByDateAndOrgCode" parameterType="hashmap" resultType="hashmap">
     select * 
         from dh_rpt_fa_day_team dt where dt.bsflag='0'
     and to_char(dt.report_date,'yyyy-mm-dd') = #{reportDate}
     and dt.org_code = #{orgCode}

The number of pieces of data queried through the database.

There is already a piece of data on 2018-02-02 in the database on the left. When adding data on the right and selecting this date, the text box will prompt that the daily report of this date already exists and cannot be reported.

Tags: Java Database Attribute JSON

Posted on Wed, 01 Apr 2020 09:11:13 -0700 by mmponline